@@ -1,253 +1,253 | |||||
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: |
|
3 | # Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Feb 17 07:55:25 2014 | |
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=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE |
|
13 | DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -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 -I../../LFR_basic-parameters |
|
16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters | |
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 | ../src/tc_acceptance.c \ |
|
55 | ../src/tc_acceptance.c \ | |
56 | ../../LFR_basic-parameters/basic_parameters.c |
|
56 | ../../LFR_basic-parameters/basic_parameters.c | |
57 | OBJECTS = obj/wf_handler.o \ |
|
57 | OBJECTS = obj/wf_handler.o \ | |
58 | obj/tc_handler.o \ |
|
58 | obj/tc_handler.o \ | |
59 | obj/fsw_processing.o \ |
|
59 | obj/fsw_processing.o \ | |
60 | obj/fsw_misc.o \ |
|
60 | obj/fsw_misc.o \ | |
61 | obj/fsw_init.o \ |
|
61 | obj/fsw_init.o \ | |
62 | obj/fsw_globals.o \ |
|
62 | obj/fsw_globals.o \ | |
63 | obj/fsw_spacewire.o \ |
|
63 | obj/fsw_spacewire.o \ | |
64 | obj/tc_load_dump_parameters.o \ |
|
64 | obj/tc_load_dump_parameters.o \ | |
65 | obj/tm_lfr_tc_exe.o \ |
|
65 | obj/tm_lfr_tc_exe.o \ | |
66 | obj/tc_acceptance.o \ |
|
66 | obj/tc_acceptance.o \ | |
67 | obj/basic_parameters.o |
|
67 | obj/basic_parameters.o | |
68 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
68 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ | |
69 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
69 | /usr/lib64/qt4/mkspecs/common/linux.conf \ | |
70 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
70 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ | |
71 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
71 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ | |
72 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
72 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ | |
73 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
73 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ | |
74 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
74 | /usr/lib64/qt4/mkspecs/qconfig.pri \ | |
75 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
75 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ | |
76 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
76 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ | |
77 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
77 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ | |
78 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
78 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ | |
79 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
79 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ | |
80 | sparc.pri \ |
|
80 | sparc.pri \ | |
81 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
81 | /usr/lib64/qt4/mkspecs/features/release.prf \ | |
82 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
82 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ | |
83 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
83 | /usr/lib64/qt4/mkspecs/features/shared.prf \ | |
84 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
84 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ | |
85 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
85 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ | |
86 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
86 | /usr/lib64/qt4/mkspecs/features/resources.prf \ | |
87 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
87 | /usr/lib64/qt4/mkspecs/features/uic.prf \ | |
88 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
88 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ | |
89 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
89 | /usr/lib64/qt4/mkspecs/features/lex.prf \ | |
90 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
90 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ | |
91 | fsw-qt.pro |
|
91 | fsw-qt.pro | |
92 |
QMAKE_TARGET = fsw |
|
92 | QMAKE_TARGET = fsw | |
93 | DESTDIR = bin/ |
|
93 | DESTDIR = bin/ | |
94 |
TARGET = bin/fsw |
|
94 | TARGET = bin/fsw | |
95 |
|
95 | |||
96 | first: all |
|
96 | first: all | |
97 | ####### Implicit rules |
|
97 | ####### Implicit rules | |
98 |
|
98 | |||
99 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
99 | .SUFFIXES: .o .c .cpp .cc .cxx .C | |
100 |
|
100 | |||
101 | .cpp.o: |
|
101 | .cpp.o: | |
102 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
102 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
103 |
|
103 | |||
104 | .cc.o: |
|
104 | .cc.o: | |
105 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
105 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
106 |
|
106 | |||
107 | .cxx.o: |
|
107 | .cxx.o: | |
108 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
108 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
109 |
|
109 | |||
110 | .C.o: |
|
110 | .C.o: | |
111 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
111 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
112 |
|
112 | |||
113 | .c.o: |
|
113 | .c.o: | |
114 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
114 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" | |
115 |
|
115 | |||
116 | ####### Build rules |
|
116 | ####### Build rules | |
117 |
|
117 | |||
118 | all: Makefile $(TARGET) |
|
118 | all: Makefile $(TARGET) | |
119 |
|
119 | |||
120 | $(TARGET): $(OBJECTS) |
|
120 | $(TARGET): $(OBJECTS) | |
121 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
121 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ | |
122 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
122 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) | |
123 |
|
123 | |||
124 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
124 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ | |
125 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
125 | /usr/lib64/qt4/mkspecs/common/linux.conf \ | |
126 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
126 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ | |
127 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
127 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ | |
128 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
128 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ | |
129 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
129 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ | |
130 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
130 | /usr/lib64/qt4/mkspecs/qconfig.pri \ | |
131 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
131 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ | |
132 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
132 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ | |
133 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
133 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ | |
134 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
134 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ | |
135 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
135 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ | |
136 | sparc.pri \ |
|
136 | sparc.pri \ | |
137 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
137 | /usr/lib64/qt4/mkspecs/features/release.prf \ | |
138 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
138 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ | |
139 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
139 | /usr/lib64/qt4/mkspecs/features/shared.prf \ | |
140 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
140 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ | |
141 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
141 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ | |
142 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
142 | /usr/lib64/qt4/mkspecs/features/resources.prf \ | |
143 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
143 | /usr/lib64/qt4/mkspecs/features/uic.prf \ | |
144 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
144 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ | |
145 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
145 | /usr/lib64/qt4/mkspecs/features/lex.prf \ | |
146 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
146 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf | |
147 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
147 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro | |
148 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
148 | /usr/lib64/qt4/mkspecs/common/unix.conf: | |
149 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
149 | /usr/lib64/qt4/mkspecs/common/linux.conf: | |
150 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
150 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: | |
151 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
151 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: | |
152 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
152 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: | |
153 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
153 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: | |
154 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
154 | /usr/lib64/qt4/mkspecs/qconfig.pri: | |
155 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
155 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: | |
156 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
156 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: | |
157 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
157 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: | |
158 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
158 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: | |
159 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
159 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: | |
160 | sparc.pri: |
|
160 | sparc.pri: | |
161 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
161 | /usr/lib64/qt4/mkspecs/features/release.prf: | |
162 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
162 | /usr/lib64/qt4/mkspecs/features/default_post.prf: | |
163 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
163 | /usr/lib64/qt4/mkspecs/features/shared.prf: | |
164 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
164 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: | |
165 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
165 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: | |
166 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
166 | /usr/lib64/qt4/mkspecs/features/resources.prf: | |
167 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
167 | /usr/lib64/qt4/mkspecs/features/uic.prf: | |
168 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
168 | /usr/lib64/qt4/mkspecs/features/yacc.prf: | |
169 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
169 | /usr/lib64/qt4/mkspecs/features/lex.prf: | |
170 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
170 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: | |
171 | qmake: FORCE |
|
171 | qmake: FORCE | |
172 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
172 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro | |
173 |
|
173 | |||
174 | dist: |
|
174 | dist: | |
175 |
@$(CHK_DIR_EXISTS) obj/fsw |
|
175 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 | |
176 |
$(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw |
|
176 | $(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 | |
177 |
|
177 | |||
178 |
|
178 | |||
179 | clean:compiler_clean |
|
179 | clean:compiler_clean | |
180 | -$(DEL_FILE) $(OBJECTS) |
|
180 | -$(DEL_FILE) $(OBJECTS) | |
181 | -$(DEL_FILE) *~ core *.core |
|
181 | -$(DEL_FILE) *~ core *.core | |
182 |
|
182 | |||
183 |
|
183 | |||
184 | ####### Sub-libraries |
|
184 | ####### Sub-libraries | |
185 |
|
185 | |||
186 | distclean: clean |
|
186 | distclean: clean | |
187 | -$(DEL_FILE) $(TARGET) |
|
187 | -$(DEL_FILE) $(TARGET) | |
188 | -$(DEL_FILE) Makefile |
|
188 | -$(DEL_FILE) Makefile | |
189 |
|
189 | |||
190 |
|
190 | |||
191 | grmon: |
|
191 | grmon: | |
192 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
192 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u | |
193 |
|
193 | |||
194 | check: first |
|
194 | check: first | |
195 |
|
195 | |||
196 | compiler_rcc_make_all: |
|
196 | compiler_rcc_make_all: | |
197 | compiler_rcc_clean: |
|
197 | compiler_rcc_clean: | |
198 | compiler_uic_make_all: |
|
198 | compiler_uic_make_all: | |
199 | compiler_uic_clean: |
|
199 | compiler_uic_clean: | |
200 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
200 | compiler_image_collection_make_all: qmake_image_collection.cpp | |
201 | compiler_image_collection_clean: |
|
201 | compiler_image_collection_clean: | |
202 | -$(DEL_FILE) qmake_image_collection.cpp |
|
202 | -$(DEL_FILE) qmake_image_collection.cpp | |
203 | compiler_yacc_decl_make_all: |
|
203 | compiler_yacc_decl_make_all: | |
204 | compiler_yacc_decl_clean: |
|
204 | compiler_yacc_decl_clean: | |
205 | compiler_yacc_impl_make_all: |
|
205 | compiler_yacc_impl_make_all: | |
206 | compiler_yacc_impl_clean: |
|
206 | compiler_yacc_impl_clean: | |
207 | compiler_lex_make_all: |
|
207 | compiler_lex_make_all: | |
208 | compiler_lex_clean: |
|
208 | compiler_lex_clean: | |
209 | compiler_clean: |
|
209 | compiler_clean: | |
210 |
|
210 | |||
211 | ####### Compile |
|
211 | ####### Compile | |
212 |
|
212 | |||
213 | obj/wf_handler.o: ../src/wf_handler.c |
|
213 | obj/wf_handler.o: ../src/wf_handler.c | |
214 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c |
|
214 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c | |
215 |
|
215 | |||
216 | obj/tc_handler.o: ../src/tc_handler.c |
|
216 | obj/tc_handler.o: ../src/tc_handler.c | |
217 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c |
|
217 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c | |
218 |
|
218 | |||
219 | obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c |
|
219 | obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c | |
220 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c |
|
220 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c | |
221 |
|
221 | |||
222 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
222 | obj/fsw_misc.o: ../src/fsw_misc.c | |
223 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
223 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c | |
224 |
|
224 | |||
225 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c |
|
225 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c | |
226 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c |
|
226 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c | |
227 |
|
227 | |||
228 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
228 | obj/fsw_globals.o: ../src/fsw_globals.c | |
229 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
229 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c | |
230 |
|
230 | |||
231 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c |
|
231 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c | |
232 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c |
|
232 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c | |
233 |
|
233 | |||
234 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c |
|
234 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c | |
235 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c |
|
235 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c | |
236 |
|
236 | |||
237 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c |
|
237 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c | |
238 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c |
|
238 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c | |
239 |
|
239 | |||
240 | obj/tc_acceptance.o: ../src/tc_acceptance.c |
|
240 | obj/tc_acceptance.o: ../src/tc_acceptance.c | |
241 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c |
|
241 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c | |
242 |
|
242 | |||
243 | obj/basic_parameters.o: ../../LFR_basic-parameters/basic_parameters.c ../../LFR_basic-parameters/basic_parameters.h |
|
243 | obj/basic_parameters.o: ../../LFR_basic-parameters/basic_parameters.c ../../LFR_basic-parameters/basic_parameters.h | |
244 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../../LFR_basic-parameters/basic_parameters.c |
|
244 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../../LFR_basic-parameters/basic_parameters.c | |
245 |
|
245 | |||
246 | ####### Install |
|
246 | ####### Install | |
247 |
|
247 | |||
248 | install: FORCE |
|
248 | install: FORCE | |
249 |
|
249 | |||
250 | uninstall: FORCE |
|
250 | uninstall: FORCE | |
251 |
|
251 | |||
252 | FORCE: |
|
252 | FORCE: | |
253 |
|
253 |
@@ -1,13 +1,13 | |||||
1 | #!/usr/bin/lppmon -e |
|
1 | #!/usr/bin/lppmon -e | |
2 |
|
2 | |||
3 | proxy.loadSysDriver("RMAPPlugin","RMAPplugin0"); |
|
3 | proxy.loadSysDriver("RMAPPlugin","RMAPplugin0"); | |
4 | proxy.loadSysDriverToParent("dsu3plugin","RMAPplugin0"); |
|
4 | proxy.loadSysDriverToParent("dsu3plugin","RMAPplugin0"); | |
5 |
|
5 | |||
6 | #BUTTON_selectStarDundee.click() |
|
6 | #BUTTON_selectStarDundee.click() | |
7 | BUTTON_selectGRESB.click() |
|
7 | BUTTON_selectGRESB.click() | |
8 |
|
8 | |||
9 | BUTTON_rmapOpenCommunication.click() |
|
9 | BUTTON_rmapOpenCommunication.click() | |
10 |
dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw |
|
10 | dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw") | |
11 | dsu3plugin0.loadFile() |
|
11 | dsu3plugin0.loadFile() | |
12 | dsu3plugin0.run() |
|
12 | dsu3plugin0.run() | |
13 |
|
13 |
@@ -1,6 +1,6 | |||||
1 | #!/usr/bin/lppmon -e |
|
1 | #!/usr/bin/lppmon -e | |
2 |
|
2 | |||
3 |
dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw |
|
3 | dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw") | |
4 | dsu3plugin0.loadFile() |
|
4 | dsu3plugin0.loadFile() | |
5 | dsu3plugin0.run() |
|
5 | dsu3plugin0.run() | |
6 |
|
6 |
@@ -1,88 +1,78 | |||||
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 |
|
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report | |
4 | CONFIG += console verbose debug_messages vhdl_dev cpu_usage_report |
|
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=-1-0 |
|
10 | SWVERSION=-1-0 | |
11 | DEFINES += SW_VERSION_N1=1 # major |
|
11 | DEFINES += SW_VERSION_N1=1 # major | |
12 | DEFINES += SW_VERSION_N2=0 # minor |
|
12 | DEFINES += SW_VERSION_N2=0 # minor | |
13 | DEFINES += SW_VERSION_N3=0 # patch |
|
13 | DEFINES += SW_VERSION_N3=0 # patch | |
14 | DEFINES += SW_VERSION_N4=1 # internal |
|
14 | DEFINES += SW_VERSION_N4=1 # internal | |
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, debug_messages ) { |
|
20 | contains( CONFIG, debug_messages ) { | |
21 | DEFINES += DEBUG_MESSAGES |
|
21 | DEFINES += DEBUG_MESSAGES | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | contains( CONFIG, cpu_usage_report ) { |
|
24 | contains( CONFIG, cpu_usage_report ) { | |
25 | DEFINES += PRINT_TASK_STATISTICS |
|
25 | DEFINES += PRINT_TASK_STATISTICS | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | contains( CONFIG, stack_report ) { |
|
28 | contains( CONFIG, stack_report ) { | |
29 | DEFINES += PRINT_STACK_REPORT |
|
29 | DEFINES += PRINT_STACK_REPORT | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | contains( CONFIG, boot_messages ) { |
|
32 | contains( CONFIG, boot_messages ) { | |
33 | DEFINES += BOOT_MESSAGES |
|
33 | DEFINES += BOOT_MESSAGES | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | #doxygen.target = doxygen |
|
36 | #doxygen.target = doxygen | |
37 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
37 | #doxygen.commands = doxygen ../doc/Doxyfile | |
38 | #QMAKE_EXTRA_TARGETS += doxygen |
|
38 | #QMAKE_EXTRA_TARGETS += doxygen | |
39 |
|
39 | |||
40 | TARGET = fsw |
|
40 | TARGET = fsw | |
41 | contains( CONFIG, gsa ) { |
|
|||
42 | DEFINES += GSA |
|
|||
43 | TARGET = fsw-gsa |
|
|||
44 | } |
|
|||
45 |
|
||||
46 | TARGET = fsw |
|
|||
47 | contains( CONFIG, vhdl_dev ) { |
|
|||
48 | DEFINES += VHDL_DEV |
|
|||
49 | TARGET = fsw-vhdl-dev |
|
|||
50 | } |
|
|||
51 |
|
41 | |||
52 | INCLUDEPATH += \ |
|
42 | INCLUDEPATH += \ | |
53 | ../src \ |
|
43 | ../src \ | |
54 | ../header \ |
|
44 | ../header \ | |
55 | ../../LFR_basic-parameters |
|
45 | ../../LFR_basic-parameters | |
56 |
|
46 | |||
57 | SOURCES += \ |
|
47 | SOURCES += \ | |
58 | ../src/wf_handler.c \ |
|
48 | ../src/wf_handler.c \ | |
59 | ../src/tc_handler.c \ |
|
49 | ../src/tc_handler.c \ | |
60 | ../src/fsw_processing.c \ |
|
50 | ../src/fsw_processing.c \ | |
61 | ../src/fsw_misc.c \ |
|
51 | ../src/fsw_misc.c \ | |
62 | ../src/fsw_init.c \ |
|
52 | ../src/fsw_init.c \ | |
63 | ../src/fsw_globals.c \ |
|
53 | ../src/fsw_globals.c \ | |
64 | ../src/fsw_spacewire.c \ |
|
54 | ../src/fsw_spacewire.c \ | |
65 | ../src/tc_load_dump_parameters.c \ |
|
55 | ../src/tc_load_dump_parameters.c \ | |
66 | ../src/tm_lfr_tc_exe.c \ |
|
56 | ../src/tm_lfr_tc_exe.c \ | |
67 | ../src/tc_acceptance.c \ |
|
57 | ../src/tc_acceptance.c \ | |
68 | ../../LFR_basic-parameters/basic_parameters.c |
|
58 | ../../LFR_basic-parameters/basic_parameters.c | |
69 |
|
59 | |||
70 |
|
60 | |||
71 | HEADERS += \ |
|
61 | HEADERS += \ | |
72 | ../header/wf_handler.h \ |
|
62 | ../header/wf_handler.h \ | |
73 | ../header/tc_handler.h \ |
|
63 | ../header/tc_handler.h \ | |
74 | ../header/grlib_regs.h \ |
|
64 | ../header/grlib_regs.h \ | |
75 | ../header/fsw_processing.h \ |
|
65 | ../header/fsw_processing.h \ | |
76 | ../header/fsw_params.h \ |
|
66 | ../header/fsw_params.h \ | |
77 | ../header/fsw_misc.h \ |
|
67 | ../header/fsw_misc.h \ | |
78 | ../header/fsw_init.h \ |
|
68 | ../header/fsw_init.h \ | |
79 | ../header/ccsds_types.h \ |
|
69 | ../header/ccsds_types.h \ | |
80 | ../header/fsw_params_processing.h \ |
|
70 | ../header/fsw_params_processing.h \ | |
81 | ../header/fsw_spacewire.h \ |
|
71 | ../header/fsw_spacewire.h \ | |
82 | ../header/tm_byte_positions.h \ |
|
72 | ../header/tm_byte_positions.h \ | |
83 | ../header/tc_load_dump_parameters.h \ |
|
73 | ../header/tc_load_dump_parameters.h \ | |
84 | ../header/tm_lfr_tc_exe.h \ |
|
74 | ../header/tm_lfr_tc_exe.h \ | |
85 | ../header/tc_acceptance.h \ |
|
75 | ../header/tc_acceptance.h \ | |
86 | ../header/fsw_params_nb_bytes.h \ |
|
76 | ../header/fsw_params_nb_bytes.h \ | |
87 | ../../LFR_basic-parameters/basic_parameters.h |
|
77 | ../../LFR_basic-parameters/basic_parameters.h | |
88 |
|
78 |
@@ -1,230 +1,228 | |||||
1 | #ifndef FSW_PARAMS_H_INCLUDED |
|
1 | #ifndef FSW_PARAMS_H_INCLUDED | |
2 | #define FSW_PARAMS_H_INCLUDED |
|
2 | #define FSW_PARAMS_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 | typedef struct ring_node |
|
12 | typedef struct ring_node | |
13 | { |
|
13 | { | |
14 | struct ring_node *previous; |
|
14 | struct ring_node *previous; | |
15 | int buffer_address; |
|
15 | int buffer_address; | |
16 | struct ring_node *next; |
|
16 | struct ring_node *next; | |
17 | unsigned int status; |
|
17 | unsigned int status; | |
18 | } ring_node; |
|
18 | } ring_node; | |
19 |
|
19 | |||
20 | typedef struct ring_node_sm |
|
20 | typedef struct ring_node_sm | |
21 | { |
|
21 | { | |
22 | struct ring_node *previous; |
|
22 | struct ring_node *previous; | |
23 | volatile int *buffer_address; |
|
23 | volatile int *buffer_address; | |
24 | struct ring_node *next; |
|
24 | struct ring_node *next; | |
25 | unsigned int status; |
|
25 | unsigned int status; | |
26 | } ring_node_sm; |
|
26 | } ring_node_sm; | |
27 |
|
27 | |||
28 | //************************ |
|
28 | //************************ | |
29 | // flight software version |
|
29 | // flight software version | |
30 | // this parameters is handled by the Qt project options |
|
30 | // this parameters is handled by the Qt project options | |
31 |
|
31 | |||
32 | //#define NB_SAMPLES_PER_SNAPSHOT 2048 |
|
32 | #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk | |
33 | #define NB_SAMPLES_PER_SNAPSHOT 2352 // 336 * 7 = 2352 |
|
33 | #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk | |
|
34 | #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 | |||
34 | #define TIME_OFFSET 2 |
|
35 | #define TIME_OFFSET 2 | |
35 | #define TIME_OFFSET_IN_BYTES 8 |
|
36 | #define TIME_OFFSET_IN_BYTES 8 | |
36 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
37 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 | |
37 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
38 | #define NB_BYTES_SWF_BLK (2 * 6) | |
38 | #define NB_WORDS_SWF_BLK 3 |
|
39 | #define NB_WORDS_SWF_BLK 3 | |
39 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
40 | #define NB_BYTES_CWF3_LIGHT_BLK 6 | |
40 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 |
|
41 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 | |
41 | #define NB_RING_NODES_F0 3 // AT LEAST 3 |
|
42 | #define NB_RING_NODES_F0 3 // AT LEAST 3 | |
42 | #define NB_RING_NODES_F1 5 // AT LEAST 3 |
|
43 | #define NB_RING_NODES_F1 5 // AT LEAST 3 | |
43 | #define NB_RING_NODES_F2 5 // AT LEAST 3 |
|
44 | #define NB_RING_NODES_F2 5 // AT LEAST 3 | |
44 | #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3 |
|
45 | #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3 | |
45 | #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3 |
|
46 | #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3 | |
46 | #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3 |
|
47 | #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3 | |
47 |
|
48 | |||
48 | //********** |
|
49 | //********** | |
49 | // LFR MODES |
|
50 | // LFR MODES | |
50 | #define LFR_MODE_STANDBY 0 |
|
51 | #define LFR_MODE_STANDBY 0 | |
51 | #define LFR_MODE_NORMAL 1 |
|
52 | #define LFR_MODE_NORMAL 1 | |
52 | #define LFR_MODE_BURST 2 |
|
53 | #define LFR_MODE_BURST 2 | |
53 | #define LFR_MODE_SBM1 3 |
|
54 | #define LFR_MODE_SBM1 3 | |
54 | #define LFR_MODE_SBM2 4 |
|
55 | #define LFR_MODE_SBM2 4 | |
55 | #define LFR_MODE_NORMAL_CWF_F3 5 |
|
56 | #define LFR_MODE_NORMAL_CWF_F3 5 | |
56 |
|
57 | |||
57 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
58 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 | |
58 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
59 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 | |
59 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
60 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 | |
60 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
61 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 | |
61 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
62 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 | |
62 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
63 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 | |
63 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6 |
|
64 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6 | |
64 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7 |
|
65 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7 | |
65 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8 |
|
66 | #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8 | |
66 |
|
67 | |||
67 | //**************************** |
|
68 | //**************************** | |
68 | // LFR DEFAULT MODE PARAMETERS |
|
69 | // LFR DEFAULT MODE PARAMETERS | |
69 | // COMMON |
|
70 | // COMMON | |
70 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
71 | #define DEFAULT_SY_LFR_COMMON0 0x00 | |
71 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
72 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 | |
72 | // NORM |
|
73 | // NORM | |
73 | #define SY_LFR_N_SWF_L 2048 // nb sample |
|
74 | #define SY_LFR_N_SWF_L 2048 // nb sample | |
74 | #define SY_LFR_N_SWF_P 300 // sec |
|
75 | #define SY_LFR_N_SWF_P 300 // sec | |
75 | #define SY_LFR_N_ASM_P 3600 // sec |
|
76 | #define SY_LFR_N_ASM_P 3600 // sec | |
76 | #define SY_LFR_N_BP_P0 4 // sec |
|
77 | #define SY_LFR_N_BP_P0 4 // sec | |
77 | #define SY_LFR_N_BP_P1 20 // sec |
|
78 | #define SY_LFR_N_BP_P1 20 // sec | |
|
79 | #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 | |||
78 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
80 | #define MIN_DELTA_SNAPSHOT 16 // sec | |
79 | // BURST |
|
81 | // BURST | |
80 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
82 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec | |
81 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
83 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec | |
82 | // SBM1 |
|
84 | // SBM1 | |
83 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
85 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec | |
84 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
86 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec | |
85 | // SBM2 |
|
87 | // SBM2 | |
86 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
88 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec | |
87 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
89 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec | |
88 | // ADDITIONAL PARAMETERS |
|
90 | // ADDITIONAL PARAMETERS | |
89 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
91 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms | |
90 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
92 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s | |
91 | // STATUS WORD |
|
93 | // STATUS WORD | |
92 | #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits |
|
94 | #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits | |
93 | #define DEFAULT_STATUS_WORD_BYTE1 0x00 |
|
95 | #define DEFAULT_STATUS_WORD_BYTE1 0x00 | |
94 | // |
|
96 | // | |
95 | #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s |
|
97 | #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s | |
96 | #define SY_LFR_DPU_CONNECT_ATTEMPT 3 |
|
98 | #define SY_LFR_DPU_CONNECT_ATTEMPT 3 | |
97 | //**************************** |
|
99 | //**************************** | |
98 |
|
100 | |||
99 | //***************************** |
|
101 | //***************************** | |
100 | // APB REGISTERS BASE ADDRESSES |
|
102 | // APB REGISTERS BASE ADDRESSES | |
101 | #define REGS_ADDR_APBUART 0x80000100 |
|
103 | #define REGS_ADDR_APBUART 0x80000100 | |
102 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
104 | #define REGS_ADDR_GPTIMER 0x80000300 | |
103 | #define REGS_ADDR_GRSPW 0x80000500 |
|
105 | #define REGS_ADDR_GRSPW 0x80000500 | |
104 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
106 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 | |
105 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
107 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 | |
|
108 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 | |||
106 |
|
109 | |||
107 | #ifdef GSA |
|
110 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff | |
108 | #else |
|
111 | #define APBUART_CTRL_REG_MASK_TE 0x00000002 | |
109 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 |
|
|||
110 | #endif |
|
|||
111 |
|
||||
112 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
|||
113 | #define APBUART_CTRL_REG_MASK_TE 0x00000002 |
|
|||
114 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
112 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) | |
115 |
|
113 | |||
116 | //********** |
|
114 | //********** | |
117 | // IRQ LINES |
|
115 | // IRQ LINES | |
118 | #define IRQ_SM 9 |
|
116 | #define IRQ_SM 9 | |
119 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
117 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels | |
120 | #define IRQ_WF 10 |
|
118 | #define IRQ_WF 10 | |
121 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels |
|
119 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels | |
122 | #define IRQ_TIME1 12 |
|
120 | #define IRQ_TIME1 12 | |
123 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels |
|
121 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels | |
124 | #define IRQ_TIME2 13 |
|
122 | #define IRQ_TIME2 13 | |
125 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels |
|
123 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels | |
126 | #define IRQ_WAVEFORM_PICKER 14 |
|
124 | #define IRQ_WAVEFORM_PICKER 14 | |
127 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
125 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels | |
128 | #define IRQ_SPECTRAL_MATRIX 6 |
|
126 | #define IRQ_SPECTRAL_MATRIX 6 | |
129 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
127 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels | |
130 |
|
128 | |||
131 | //***** |
|
129 | //***** | |
132 | // TIME |
|
130 | // TIME | |
133 | #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms |
|
131 | #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms | |
134 | #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s |
|
132 | #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s | |
135 | #define TIMER_SM_SIMULATOR 1 |
|
133 | #define TIMER_SM_SIMULATOR 1 | |
136 | #define TIMER_WF_SIMULATOR 2 |
|
134 | #define TIMER_WF_SIMULATOR 2 | |
137 | #define HK_PERIOD 100 // 100 * 10ms => 1sec |
|
135 | #define HK_PERIOD 100 // 100 * 10ms => 1sec | |
138 |
|
136 | |||
139 | //********** |
|
137 | //********** | |
140 | // LPP CODES |
|
138 | // LPP CODES | |
141 | #define LFR_SUCCESSFUL 0 |
|
139 | #define LFR_SUCCESSFUL 0 | |
142 | #define LFR_DEFAULT 1 |
|
140 | #define LFR_DEFAULT 1 | |
143 |
|
141 | |||
144 | //****** |
|
142 | //****** | |
145 | // RTEMS |
|
143 | // RTEMS | |
146 | #define TASKID_RECV 1 |
|
144 | #define TASKID_RECV 1 | |
147 | #define TASKID_ACTN 2 |
|
145 | #define TASKID_ACTN 2 | |
148 | #define TASKID_SPIQ 3 |
|
146 | #define TASKID_SPIQ 3 | |
149 | #define TASKID_SMIQ 4 |
|
147 | #define TASKID_SMIQ 4 | |
150 | #define TASKID_STAT 5 |
|
148 | #define TASKID_STAT 5 | |
151 | #define TASKID_AVF0 6 |
|
149 | #define TASKID_AVF0 6 | |
152 | #define TASKID_BPF0 7 |
|
150 | #define TASKID_BPF0 7 | |
153 | #define TASKID_WFRM 8 |
|
151 | #define TASKID_WFRM 8 | |
154 | #define TASKID_DUMB 9 |
|
152 | #define TASKID_DUMB 9 | |
155 | #define TASKID_HOUS 10 |
|
153 | #define TASKID_HOUS 10 | |
156 | #define TASKID_MATR 11 |
|
154 | #define TASKID_MATR 11 | |
157 | #define TASKID_CWF3 12 |
|
155 | #define TASKID_CWF3 12 | |
158 | #define TASKID_CWF2 13 |
|
156 | #define TASKID_CWF2 13 | |
159 | #define TASKID_CWF1 14 |
|
157 | #define TASKID_CWF1 14 | |
160 | #define TASKID_SEND 15 |
|
158 | #define TASKID_SEND 15 | |
161 | #define TASKID_WTDG 16 |
|
159 | #define TASKID_WTDG 16 | |
162 |
|
160 | |||
163 | #define TASK_PRIORITY_SPIQ 5 |
|
161 | #define TASK_PRIORITY_SPIQ 5 | |
164 | #define TASK_PRIORITY_SMIQ 10 |
|
162 | #define TASK_PRIORITY_SMIQ 10 | |
165 | #define TASK_PRIORITY_WTDG 20 |
|
163 | #define TASK_PRIORITY_WTDG 20 | |
166 | #define TASK_PRIORITY_HOUS 30 |
|
164 | #define TASK_PRIORITY_HOUS 30 | |
167 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together |
|
165 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together | |
168 | #define TASK_PRIORITY_CWF2 35 // |
|
166 | #define TASK_PRIORITY_CWF2 35 // | |
169 | #define TASK_PRIORITY_WFRM 40 |
|
167 | #define TASK_PRIORITY_WFRM 40 | |
170 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 |
|
168 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 | |
171 | #define TASK_PRIORITY_SEND 45 |
|
169 | #define TASK_PRIORITY_SEND 45 | |
172 | #define TASK_PRIORITY_RECV 50 |
|
170 | #define TASK_PRIORITY_RECV 50 | |
173 | #define TASK_PRIORITY_ACTN 50 |
|
171 | #define TASK_PRIORITY_ACTN 50 | |
174 | #define TASK_PRIORITY_AVF0 60 |
|
172 | #define TASK_PRIORITY_AVF0 60 | |
175 | #define TASK_PRIORITY_BPF0 60 |
|
173 | #define TASK_PRIORITY_BPF0 60 | |
176 | #define TASK_PRIORITY_MATR 100 |
|
174 | #define TASK_PRIORITY_MATR 100 | |
177 | #define TASK_PRIORITY_STAT 200 |
|
175 | #define TASK_PRIORITY_STAT 200 | |
178 | #define TASK_PRIORITY_DUMB 200 |
|
176 | #define TASK_PRIORITY_DUMB 200 | |
179 |
|
177 | |||
180 | #define ACTION_MSG_QUEUE_COUNT 10 |
|
178 | #define ACTION_MSG_QUEUE_COUNT 10 | |
181 | #define ACTION_MSG_PKTS_COUNT 50 |
|
179 | #define ACTION_MSG_PKTS_COUNT 50 | |
182 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) |
|
180 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |
183 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
181 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options | |
184 |
|
182 | |||
185 | #define QUEUE_RECV 0 |
|
183 | #define QUEUE_RECV 0 | |
186 | #define QUEUE_SEND 1 |
|
184 | #define QUEUE_SEND 1 | |
187 |
|
185 | |||
188 | //******* |
|
186 | //******* | |
189 | // MACROS |
|
187 | // MACROS | |
190 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
188 | #ifdef PRINT_MESSAGES_ON_CONSOLE | |
191 | #define PRINTF(x) printf(x); |
|
189 | #define PRINTF(x) printf(x); | |
192 | #define PRINTF1(x,y) printf(x,y); |
|
190 | #define PRINTF1(x,y) printf(x,y); | |
193 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
191 | #define PRINTF2(x,y,z) printf(x,y,z); | |
194 | #else |
|
192 | #else | |
195 | #define PRINTF(x) ; |
|
193 | #define PRINTF(x) ; | |
196 | #define PRINTF1(x,y) ; |
|
194 | #define PRINTF1(x,y) ; | |
197 | #define PRINTF2(x,y,z) ; |
|
195 | #define PRINTF2(x,y,z) ; | |
198 | #endif |
|
196 | #endif | |
199 |
|
197 | |||
200 | #ifdef BOOT_MESSAGES |
|
198 | #ifdef BOOT_MESSAGES | |
201 | #define BOOT_PRINTF(x) printf(x); |
|
199 | #define BOOT_PRINTF(x) printf(x); | |
202 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
200 | #define BOOT_PRINTF1(x,y) printf(x,y); | |
203 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
201 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); | |
204 | #else |
|
202 | #else | |
205 | #define BOOT_PRINTF(x) ; |
|
203 | #define BOOT_PRINTF(x) ; | |
206 | #define BOOT_PRINTF1(x,y) ; |
|
204 | #define BOOT_PRINTF1(x,y) ; | |
207 | #define BOOT_PRINTF2(x,y,z) ; |
|
205 | #define BOOT_PRINTF2(x,y,z) ; | |
208 | #endif |
|
206 | #endif | |
209 |
|
207 | |||
210 | #ifdef DEBUG_MESSAGES |
|
208 | #ifdef DEBUG_MESSAGES | |
211 | #define DEBUG_PRINTF(x) printf(x); |
|
209 | #define DEBUG_PRINTF(x) printf(x); | |
212 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
210 | #define DEBUG_PRINTF1(x,y) printf(x,y); | |
213 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
211 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); | |
214 | #else |
|
212 | #else | |
215 | #define DEBUG_PRINTF(x) ; |
|
213 | #define DEBUG_PRINTF(x) ; | |
216 | #define DEBUG_PRINTF1(x,y) ; |
|
214 | #define DEBUG_PRINTF1(x,y) ; | |
217 | #define DEBUG_PRINTF2(x,y,z) ; |
|
215 | #define DEBUG_PRINTF2(x,y,z) ; | |
218 | #endif |
|
216 | #endif | |
219 |
|
217 | |||
220 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
218 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period | |
221 |
|
219 | |||
222 | struct param_local_str{ |
|
220 | struct param_local_str{ | |
223 | unsigned int local_sbm1_nb_cwf_sent; |
|
221 | unsigned int local_sbm1_nb_cwf_sent; | |
224 | unsigned int local_sbm1_nb_cwf_max; |
|
222 | unsigned int local_sbm1_nb_cwf_max; | |
225 | unsigned int local_sbm2_nb_cwf_sent; |
|
223 | unsigned int local_sbm2_nb_cwf_sent; | |
226 | unsigned int local_sbm2_nb_cwf_max; |
|
224 | unsigned int local_sbm2_nb_cwf_max; | |
227 | unsigned int local_nb_interrupt_f0_MAX; |
|
225 | unsigned int local_nb_interrupt_f0_MAX; | |
228 | }; |
|
226 | }; | |
229 |
|
227 | |||
230 | #endif // FSW_PARAMS_H_INCLUDED |
|
228 | #endif // FSW_PARAMS_H_INCLUDED |
@@ -1,60 +1,55 | |||||
1 | #ifndef TC_HANDLER_H_INCLUDED |
|
1 | #ifndef TC_HANDLER_H_INCLUDED | |
2 | #define TC_HANDLER_H_INCLUDED |
|
2 | #define TC_HANDLER_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <leon.h> |
|
5 | #include <leon.h> | |
6 |
|
6 | |||
7 | #include "tc_load_dump_parameters.h" |
|
7 | #include "tc_load_dump_parameters.h" | |
8 | #include "tc_acceptance.h" |
|
8 | #include "tc_acceptance.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 | #include "fsw_processing.h" |
|
11 | #include "fsw_processing.h" | |
12 |
|
12 | |||
13 | // MODE PARAMETERS |
|
13 | // MODE PARAMETERS | |
14 | extern unsigned int maxCount; |
|
14 | extern unsigned int maxCount; | |
15 |
|
15 | |||
16 | //**** |
|
16 | //**** | |
17 | // ISR |
|
17 | // ISR | |
18 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
18 | rtems_isr commutation_isr1( rtems_vector_number vector ); | |
19 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
19 | rtems_isr commutation_isr2( rtems_vector_number vector ); | |
20 |
|
20 | |||
21 | //*********** |
|
21 | //*********** | |
22 | // RTEMS TASK |
|
22 | // RTEMS TASK | |
23 | rtems_task actn_task( rtems_task_argument unused ); |
|
23 | rtems_task actn_task( rtems_task_argument unused ); | |
24 |
|
24 | |||
25 | //*********** |
|
25 | //*********** | |
26 | // TC ACTIONS |
|
26 | // TC ACTIONS | |
27 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
27 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
28 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
28 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
29 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
29 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
30 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
31 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
31 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
32 | int action_update_time(ccsdsTelecommandPacket_t *TC); |
|
32 | int action_update_time(ccsdsTelecommandPacket_t *TC); | |
33 |
|
33 | |||
34 | // mode transition |
|
34 | // mode transition | |
35 | int transition_validation(unsigned char requestedMode); |
|
35 | int transition_validation(unsigned char requestedMode); | |
36 | int stop_current_mode(); |
|
36 | int stop_current_mode( void ); | |
37 | int enter_mode(unsigned char mode); |
|
37 | int enter_mode(unsigned char mode); | |
38 | int enter_standby_mode(); |
|
|||
39 | int enter_normal_mode(); |
|
|||
40 | int enter_burst_mode(); |
|
|||
41 | int enter_sbm1_mode(); |
|
|||
42 | int enter_sbm2_mode(); |
|
|||
43 | int restart_science_tasks(); |
|
38 | int restart_science_tasks(); | |
44 | int suspend_science_tasks(); |
|
39 | int suspend_science_tasks(); | |
45 | void launch_waveform_picker( unsigned char mode ); |
|
40 | void launch_waveform_picker( unsigned char mode ); | |
46 | void launch_spectral_matrix( unsigned char mode ); |
|
41 | void launch_spectral_matrix( unsigned char mode ); | |
47 |
|
42 | |||
48 | // other functions |
|
43 | // other functions | |
49 | void updateLFRCurrentMode(); |
|
44 | void updateLFRCurrentMode(); | |
50 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time); |
|
45 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time); | |
51 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time); |
|
46 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time); | |
52 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time); |
|
47 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time); | |
53 |
|
48 | |||
54 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
49 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); | |
55 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
50 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); | |
56 |
|
51 | |||
57 | #endif // TC_HANDLER_H_INCLUDED |
|
52 | #endif // TC_HANDLER_H_INCLUDED | |
58 |
|
53 | |||
59 |
|
54 | |||
60 |
|
55 |
@@ -1,93 +1,90 | |||||
1 | #ifndef WF_HANDLER_H_INCLUDED |
|
1 | #ifndef WF_HANDLER_H_INCLUDED | |
2 | #define WF_HANDLER_H_INCLUDED |
|
2 | #define WF_HANDLER_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <grspw.h> |
|
5 | #include <grspw.h> | |
6 | #include <stdio.h> |
|
6 | #include <stdio.h> | |
7 | #include <math.h> |
|
7 | #include <math.h> | |
8 |
|
8 | |||
9 | #include "fsw_params.h" |
|
9 | #include "fsw_params.h" | |
10 | #include "fsw_spacewire.h" |
|
10 | #include "fsw_spacewire.h" | |
11 | #include "fsw_misc.h" |
|
11 | #include "fsw_misc.h" | |
12 |
|
12 | |||
13 | #define pi 3.1415 |
|
13 | #define pi 3.1415 | |
14 |
|
14 | |||
15 | extern int fdSPW; |
|
15 | extern int fdSPW; | |
16 |
|
16 | |||
17 | //***************** |
|
17 | //***************** | |
18 | // waveform buffers |
|
18 | // waveform buffers | |
19 | // F0 |
|
19 | // F0 | |
20 | //extern volatile int wf_snap_f0[ ]; |
|
20 | //extern volatile int wf_snap_f0[ ]; | |
21 | // F1 F2 |
|
21 | // F1 F2 | |
22 | extern volatile int wf_snap_f0[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ]; |
|
22 | extern volatile int wf_snap_f0[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ]; | |
23 | extern volatile int wf_snap_f1[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ]; |
|
23 | extern volatile int wf_snap_f1[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ]; | |
24 | extern volatile int wf_snap_f2[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ]; |
|
24 | extern volatile int wf_snap_f2[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ]; | |
25 | // F3 |
|
25 | // F3 | |
26 | extern volatile int wf_cont_f3_a[ ]; |
|
26 | extern volatile int wf_cont_f3_a[ ]; | |
27 | extern volatile int wf_cont_f3_b[ ]; |
|
27 | extern volatile int wf_cont_f3_b[ ]; | |
28 | extern char wf_cont_f3_light[ ]; |
|
28 | extern char wf_cont_f3_light[ ]; | |
29 |
|
29 | |||
30 | #ifdef VHDL_DEV |
|
|||
31 | extern waveform_picker_regs_new_t *waveform_picker_regs; |
|
30 | extern waveform_picker_regs_new_t *waveform_picker_regs; | |
32 | #else |
|
|||
33 | extern waveform_picker_regs_t *waveform_picker_regs; |
|
|||
34 | #endif |
|
|||
35 | extern time_management_regs_t *time_management_regs; |
|
31 | extern time_management_regs_t *time_management_regs; | |
36 | extern Packet_TM_LFR_HK_t housekeeping_packet; |
|
32 | extern Packet_TM_LFR_HK_t housekeeping_packet; | |
37 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
33 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
38 | extern struct param_local_str param_local; |
|
34 | extern struct param_local_str param_local; | |
39 |
|
35 | |||
40 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
36 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | |
41 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
37 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
42 |
|
38 | |||
43 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
39 | extern rtems_id Task_id[20]; /* array of task ids */ | |
44 |
|
40 | |||
45 | extern unsigned char lfrCurrentMode; |
|
41 | extern unsigned char lfrCurrentMode; | |
46 |
|
42 | |||
47 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
43 | rtems_isr waveforms_isr( rtems_vector_number vector ); | |
48 | rtems_isr waveforms_isr_alt( rtems_vector_number vector ); |
|
44 | rtems_isr waveforms_isr_alt( rtems_vector_number vector ); | |
49 | rtems_task wfrm_task( rtems_task_argument argument ); |
|
45 | rtems_task wfrm_task( rtems_task_argument argument ); | |
50 | rtems_task cwf3_task( rtems_task_argument argument ); |
|
46 | rtems_task cwf3_task( rtems_task_argument argument ); | |
51 | rtems_task cwf2_task( rtems_task_argument argument ); |
|
47 | rtems_task cwf2_task( rtems_task_argument argument ); | |
52 | rtems_task cwf1_task( rtems_task_argument argument ); |
|
48 | rtems_task cwf1_task( rtems_task_argument argument ); | |
53 |
|
49 | |||
54 | //****************** |
|
50 | //****************** | |
55 | // general functions |
|
51 | // general functions | |
56 | void init_waveforms( void ); |
|
52 | void init_waveforms( void ); | |
57 | void init_waveform_rings( void ); |
|
53 | void init_waveform_rings( void ); | |
58 | void reset_current_ring_nodes( void ); |
|
54 | void reset_current_ring_nodes( void ); | |
59 | // |
|
55 | // | |
60 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); |
|
56 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); | |
61 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
57 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); | |
62 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
58 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); | |
63 | // |
|
59 | // | |
64 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ); |
|
60 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ); | |
65 | int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
61 | int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); | |
66 | int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
62 | int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); | |
67 | int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
63 | int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); | |
68 | // |
|
64 | // | |
69 |
void compute_acquisition_time(unsigned int |
|
65 | void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, | |
|
66 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); | |||
70 | // |
|
67 | // | |
71 | rtems_id get_pkts_queue_id( void ); |
|
68 | rtems_id get_pkts_queue_id( void ); | |
72 |
|
69 | |||
73 | //************** |
|
70 | //************** | |
74 | // wfp registers |
|
71 | // wfp registers | |
75 | // RESET |
|
72 | // RESET | |
76 | void reset_wfp_burst_enable( void ); |
|
73 | void reset_wfp_burst_enable( void ); | |
77 | void reset_wfp_status(void); |
|
74 | void reset_wfp_status(void); | |
78 | void reset_waveform_picker_regs( void ); |
|
75 | void reset_waveform_picker_regs( void ); | |
79 | // SET |
|
76 | // SET | |
80 | void set_wfp_data_shaping(void); |
|
77 | void set_wfp_data_shaping(void); | |
81 | void set_wfp_burst_enable_register( unsigned char mode ); |
|
78 | void set_wfp_burst_enable_register( unsigned char mode ); | |
82 | void set_wfp_delta_snapshot( void ); |
|
79 | void set_wfp_delta_snapshot( void ); | |
83 | void set_wfp_delta_f0_f0_2( void ); |
|
80 | void set_wfp_delta_f0_f0_2( void ); | |
84 | void set_wfp_delta_f1( void ); |
|
81 | void set_wfp_delta_f1( void ); | |
85 | void set_wfp_delta_f2( void ); |
|
82 | void set_wfp_delta_f2( void ); | |
86 |
|
83 | |||
87 | //***************** |
|
84 | //***************** | |
88 | // local parameters |
|
85 | // local parameters | |
89 | void set_local_nb_interrupt_f0_MAX( void ); |
|
86 | void set_local_nb_interrupt_f0_MAX( void ); | |
90 |
|
87 | |||
91 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); |
|
88 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); | |
92 |
|
89 | |||
93 | #endif // WF_HANDLER_H_INCLUDED |
|
90 | #endif // WF_HANDLER_H_INCLUDED |
@@ -1,75 +1,70 | |||||
1 | /** Global variables of the LFR flight software. |
|
1 | /** Global variables of the LFR flight software. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * Among global variables, there are: |
|
6 | * Among global variables, there are: | |
7 | * - RTEMS names and id. |
|
7 | * - RTEMS names and id. | |
8 | * - APB configuration registers. |
|
8 | * - APB configuration registers. | |
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. |
|
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. | |
10 | * - spectral matrices buffesr, used by the hardware module to store data. |
|
10 | * - spectral matrices buffesr, used by the hardware module to store data. | |
11 | * - variable related to LFR modes parameters. |
|
11 | * - variable related to LFR modes parameters. | |
12 | * - the global HK packet buffer. |
|
12 | * - the global HK packet buffer. | |
13 | * - the global dump parameter buffer. |
|
13 | * - the global dump parameter buffer. | |
14 | * |
|
14 | * | |
15 | */ |
|
15 | */ | |
16 |
|
16 | |||
17 | #include <rtems.h> |
|
17 | #include <rtems.h> | |
18 | #include <grspw.h> |
|
18 | #include <grspw.h> | |
19 |
|
19 | |||
20 | #include "ccsds_types.h" |
|
20 | #include "ccsds_types.h" | |
21 | #include "grlib_regs.h" |
|
21 | #include "grlib_regs.h" | |
22 | #include "fsw_params.h" |
|
22 | #include "fsw_params.h" | |
23 |
|
23 | |||
24 | // RTEMS GLOBAL VARIABLES |
|
24 | // RTEMS GLOBAL VARIABLES | |
25 | rtems_name misc_name[5]; |
|
25 | rtems_name misc_name[5]; | |
26 | rtems_id misc_id[5]; |
|
26 | rtems_id misc_id[5]; | |
27 | rtems_name Task_name[20]; /* array of task names */ |
|
27 | rtems_name Task_name[20]; /* array of task names */ | |
28 | rtems_id Task_id[20]; /* array of task ids */ |
|
28 | rtems_id Task_id[20]; /* array of task ids */ | |
29 | unsigned int maxCount; |
|
29 | unsigned int maxCount; | |
30 | int fdSPW = 0; |
|
30 | int fdSPW = 0; | |
31 | int fdUART = 0; |
|
31 | int fdUART = 0; | |
32 | unsigned char lfrCurrentMode; |
|
32 | unsigned char lfrCurrentMode; | |
33 |
|
33 | |||
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes |
|
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes | |
35 | // F0 |
|
35 | // F0 | |
36 | //volatile int wf_snap_f0 [ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); |
|
36 | //volatile int wf_snap_f0 [ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); | |
37 | volatile int wf_snap_f0[ NB_RING_NODES_F0 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); |
|
37 | volatile int wf_snap_f0[ NB_RING_NODES_F0 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); | |
38 | // F1 F2 |
|
38 | // F1 F2 | |
39 | volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); |
|
39 | volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); | |
40 | volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); |
|
40 | volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); | |
41 | // F3 |
|
41 | // F3 | |
42 | volatile int wf_cont_f3_a [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); |
|
42 | volatile int wf_cont_f3_a [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); | |
43 | volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); |
|
43 | volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); | |
44 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100))); |
|
44 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100))); | |
45 |
|
45 | |||
46 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
46 | // SPECTRAL MATRICES GLOBAL VARIABLES | |
47 | volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ SM_HEADER + TOTAL_SIZE_SM ]; |
|
47 | volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ SM_HEADER + TOTAL_SIZE_SM ]; | |
48 | volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ SM_HEADER + TOTAL_SIZE_SM ]; |
|
48 | volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ SM_HEADER + TOTAL_SIZE_SM ]; | |
49 | volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ SM_HEADER + TOTAL_SIZE_SM ]; |
|
49 | volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ SM_HEADER + TOTAL_SIZE_SM ]; | |
50 |
|
50 | |||
51 | // APB CONFIGURATION REGISTERS |
|
51 | // APB CONFIGURATION REGISTERS | |
52 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
52 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; | |
53 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
53 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |
54 |
|
||||
55 | #ifdef VHDL_DEV |
|
|||
56 | waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
54 | waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER; | |
57 | #else |
|
|||
58 | waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
|||
59 | #endif |
|
|||
60 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
55 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; | |
61 |
|
56 | |||
62 | // MODE PARAMETERS |
|
57 | // MODE PARAMETERS | |
63 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
58 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
64 | struct param_local_str param_local; |
|
59 | struct param_local_str param_local; | |
65 |
|
60 | |||
66 | // HK PACKETS |
|
61 | // HK PACKETS | |
67 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
62 | Packet_TM_LFR_HK_t housekeeping_packet; | |
68 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
63 | // sequence counters are incremented by APID (PID + CAT) and destination ID | |
69 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
64 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | |
70 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
65 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
71 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; |
|
66 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; | |
72 | spw_stats spacewire_stats; |
|
67 | spw_stats spacewire_stats; | |
73 | spw_stats spacewire_stats_backup; |
|
68 | spw_stats spacewire_stats_backup; | |
74 |
|
69 | |||
75 |
|
70 |
@@ -1,610 +1,611 | |||||
1 | /** This is the RTEMS initialization module. |
|
1 | /** This is the RTEMS initialization module. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * This module contains two very different information: |
|
6 | * This module contains two very different information: | |
7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
7 | * - specific instructions to configure the compilation of the RTEMS executive | |
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task | |
9 | * |
|
9 | * | |
10 | */ |
|
10 | */ | |
11 |
|
11 | |||
12 | //************************* |
|
12 | //************************* | |
13 | // GPL reminder to be added |
|
13 | // GPL reminder to be added | |
14 | //************************* |
|
14 | //************************* | |
15 |
|
15 | |||
16 | #include <rtems.h> |
|
16 | #include <rtems.h> | |
17 |
|
17 | |||
18 | /* configuration information */ |
|
18 | /* configuration information */ | |
19 |
|
19 | |||
20 | #define CONFIGURE_INIT |
|
20 | #define CONFIGURE_INIT | |
21 |
|
21 | |||
22 | #include <bsp.h> /* for device driver prototypes */ |
|
22 | #include <bsp.h> /* for device driver prototypes */ | |
23 |
|
23 | |||
24 | /* configuration information */ |
|
24 | /* configuration information */ | |
25 |
|
25 | |||
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
28 |
|
28 | |||
29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
29 | #define CONFIGURE_MAXIMUM_TASKS 20 | |
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
35 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
35 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
36 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
36 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
37 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
37 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) | |
38 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 |
|
38 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 | |
39 | #ifdef PRINT_STACK_REPORT |
|
39 | #ifdef PRINT_STACK_REPORT | |
40 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
40 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
41 | #endif |
|
41 | #endif | |
42 |
|
42 | |||
43 | #include <rtems/confdefs.h> |
|
43 | #include <rtems/confdefs.h> | |
44 |
|
44 | |||
45 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
45 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
46 | #ifdef RTEMS_DRVMGR_STARTUP |
|
46 | #ifdef RTEMS_DRVMGR_STARTUP | |
47 | #ifdef LEON3 |
|
47 | #ifdef LEON3 | |
48 | /* Add Timer and UART Driver */ |
|
48 | /* Add Timer and UART Driver */ | |
49 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
49 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
50 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
50 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
51 | #endif |
|
51 | #endif | |
52 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
52 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
53 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
53 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
54 | #endif |
|
54 | #endif | |
55 | #endif |
|
55 | #endif | |
56 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
56 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
57 | #include <drvmgr/drvmgr_confdefs.h> |
|
57 | #include <drvmgr/drvmgr_confdefs.h> | |
58 | #endif |
|
58 | #endif | |
59 |
|
59 | |||
60 | #include "fsw_init.h" |
|
60 | #include "fsw_init.h" | |
61 | #include "fsw_config.c" |
|
61 | #include "fsw_config.c" | |
62 |
|
62 | |||
63 | rtems_task Init( rtems_task_argument ignored ) |
|
63 | rtems_task Init( rtems_task_argument ignored ) | |
64 | { |
|
64 | { | |
65 | /** This is the RTEMS INIT taks, it the first task launched by the system. |
|
65 | /** This is the RTEMS INIT taks, it the first task launched by the system. | |
66 | * |
|
66 | * | |
67 | * @param unused is the starting argument of the RTEMS task |
|
67 | * @param unused is the starting argument of the RTEMS task | |
68 | * |
|
68 | * | |
69 | * The INIT task create and run all other RTEMS tasks. |
|
69 | * The INIT task create and run all other RTEMS tasks. | |
70 | * |
|
70 | * | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | rtems_status_code status; |
|
74 | rtems_status_code status; | |
75 | rtems_status_code status_spw; |
|
75 | rtems_status_code status_spw; | |
76 | rtems_isr_entry old_isr_handler; |
|
76 | rtems_isr_entry old_isr_handler; | |
77 |
|
77 | |||
78 | // UART settings |
|
78 | // UART settings | |
79 | send_console_outputs_on_apbuart_port(); |
|
79 | send_console_outputs_on_apbuart_port(); | |
80 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
80 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
81 | enable_apbuart_transmitter(); |
|
81 | enable_apbuart_transmitter(); | |
82 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
82 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
83 |
|
83 | |||
84 |
|
|
84 | PRINTF("\n\n\n\n\n") | |
85 |
|
|
85 | PRINTF("*************************\n") | |
86 |
|
|
86 | PRINTF("** LFR Flight Software **\n") | |
87 | #ifdef VHDL_DEV |
|
87 | PRINTF1("** %d.", SW_VERSION_N1) | |
88 | PRINTF("/!\\ this is the VHDL_DEV flight software /!\\ \n") |
|
88 | PRINTF1("%d.", SW_VERSION_N2) | |
89 | #endif |
|
89 | PRINTF1("%d.", SW_VERSION_N3) | |
90 | BOOT_PRINTF("***************************\n") |
|
90 | PRINTF1("%d\n", SW_VERSION_N4) | |
91 | BOOT_PRINTF("\n\n") |
|
91 | PRINTF("*************************\n") | |
|
92 | PRINTF("\n\n") | |||
92 |
|
93 | |||
93 | reset_wfp_burst_enable(); // stop the waveform picker if it was running |
|
94 | reset_wfp_burst_enable(); // stop the waveform picker if it was running | |
94 | init_waveform_rings(); // initialize the waveform rings |
|
95 | init_waveform_rings(); // initialize the waveform rings | |
95 | init_sm_rings(); |
|
96 | init_sm_rings(); | |
96 |
|
97 | |||
97 | init_parameter_dump(); |
|
98 | init_parameter_dump(); | |
98 | init_local_mode_parameters(); |
|
99 | init_local_mode_parameters(); | |
99 | init_housekeeping_parameters(); |
|
100 | init_housekeeping_parameters(); | |
100 |
|
101 | |||
101 | updateLFRCurrentMode(); |
|
102 | updateLFRCurrentMode(); | |
102 |
|
103 | |||
103 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
104 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
104 |
|
105 | |||
105 | create_names(); // create all names |
|
106 | create_names(); // create all names | |
106 |
|
107 | |||
107 | status = create_message_queues(); // create message queues |
|
108 | status = create_message_queues(); // create message queues | |
108 | if (status != RTEMS_SUCCESSFUL) |
|
109 | if (status != RTEMS_SUCCESSFUL) | |
109 | { |
|
110 | { | |
110 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
111 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
111 | } |
|
112 | } | |
112 |
|
113 | |||
113 | status = create_all_tasks(); // create all tasks |
|
114 | status = create_all_tasks(); // create all tasks | |
114 | if (status != RTEMS_SUCCESSFUL) |
|
115 | if (status != RTEMS_SUCCESSFUL) | |
115 | { |
|
116 | { | |
116 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) |
|
117 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) | |
117 | } |
|
118 | } | |
118 |
|
119 | |||
119 | // ************************** |
|
120 | // ************************** | |
120 | // <SPACEWIRE INITIALIZATION> |
|
121 | // <SPACEWIRE INITIALIZATION> | |
121 | grspw_timecode_callback = &timecode_irq_handler; |
|
122 | grspw_timecode_callback = &timecode_irq_handler; | |
122 |
|
123 | |||
123 | status_spw = spacewire_open_link(); // (1) open the link |
|
124 | status_spw = spacewire_open_link(); // (1) open the link | |
124 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
125 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
125 | { |
|
126 | { | |
126 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
127 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) | |
127 | } |
|
128 | } | |
128 |
|
129 | |||
129 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
130 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
130 | { |
|
131 | { | |
131 | status_spw = spacewire_configure_link( fdSPW ); |
|
132 | status_spw = spacewire_configure_link( fdSPW ); | |
132 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
133 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
133 | { |
|
134 | { | |
134 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
135 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) | |
135 | } |
|
136 | } | |
136 | } |
|
137 | } | |
137 |
|
138 | |||
138 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
139 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
139 | { |
|
140 | { | |
140 | status_spw = spacewire_start_link( fdSPW ); |
|
141 | status_spw = spacewire_start_link( fdSPW ); | |
141 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
142 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
142 | { |
|
143 | { | |
143 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
144 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) | |
144 | } |
|
145 | } | |
145 | } |
|
146 | } | |
146 | // </SPACEWIRE INITIALIZATION> |
|
147 | // </SPACEWIRE INITIALIZATION> | |
147 | // *************************** |
|
148 | // *************************** | |
148 |
|
149 | |||
149 | status = start_all_tasks(); // start all tasks |
|
150 | status = start_all_tasks(); // start all tasks | |
150 | if (status != RTEMS_SUCCESSFUL) |
|
151 | if (status != RTEMS_SUCCESSFUL) | |
151 | { |
|
152 | { | |
152 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
153 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
153 | } |
|
154 | } | |
154 |
|
155 | |||
155 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
156 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization | |
156 | status = start_recv_send_tasks(); |
|
157 | status = start_recv_send_tasks(); | |
157 | if ( status != RTEMS_SUCCESSFUL ) |
|
158 | if ( status != RTEMS_SUCCESSFUL ) | |
158 | { |
|
159 | { | |
159 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
160 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) | |
160 | } |
|
161 | } | |
161 |
|
162 | |||
162 | // suspend science tasks. they will be restarted later depending on the mode |
|
163 | // suspend science tasks. they will be restarted later depending on the mode | |
163 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
164 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
164 | if (status != RTEMS_SUCCESSFUL) |
|
165 | if (status != RTEMS_SUCCESSFUL) | |
165 | { |
|
166 | { | |
166 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
167 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 |
|
170 | |||
170 | //****************************** |
|
171 | //****************************** | |
171 | // <SPECTRAL MATRICES SIMULATOR> |
|
172 | // <SPECTRAL MATRICES SIMULATOR> | |
172 | LEON_Mask_interrupt( IRQ_SM ); |
|
173 | LEON_Mask_interrupt( IRQ_SM ); | |
173 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
174 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |
174 | IRQ_SPARC_SM, spectral_matrices_isr_simu ); |
|
175 | IRQ_SPARC_SM, spectral_matrices_isr_simu ); | |
175 | // </SPECTRAL MATRICES SIMULATOR> |
|
176 | // </SPECTRAL MATRICES SIMULATOR> | |
176 | //******************************* |
|
177 | //******************************* | |
177 |
|
178 | |||
178 | // configure IRQ handling for the waveform picker unit |
|
179 | // configure IRQ handling for the waveform picker unit | |
179 | status = rtems_interrupt_catch( waveforms_isr, |
|
180 | status = rtems_interrupt_catch( waveforms_isr, | |
180 | IRQ_SPARC_WAVEFORM_PICKER, |
|
181 | IRQ_SPARC_WAVEFORM_PICKER, | |
181 | &old_isr_handler) ; |
|
182 | &old_isr_handler) ; | |
182 |
|
183 | |||
183 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
184 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery | |
184 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
185 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
185 | { |
|
186 | { | |
186 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
187 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
187 | if ( status != RTEMS_SUCCESSFUL ) { |
|
188 | if ( status != RTEMS_SUCCESSFUL ) { | |
188 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
189 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) | |
189 | } |
|
190 | } | |
190 | } |
|
191 | } | |
191 |
|
192 | |||
192 | BOOT_PRINTF("delete INIT\n") |
|
193 | BOOT_PRINTF("delete INIT\n") | |
193 |
|
194 | |||
194 | status = rtems_task_delete(RTEMS_SELF); |
|
195 | status = rtems_task_delete(RTEMS_SELF); | |
195 |
|
196 | |||
196 | } |
|
197 | } | |
197 |
|
198 | |||
198 | void init_local_mode_parameters( void ) |
|
199 | void init_local_mode_parameters( void ) | |
199 | { |
|
200 | { | |
200 | /** This function initialize the param_local global variable with default values. |
|
201 | /** This function initialize the param_local global variable with default values. | |
201 | * |
|
202 | * | |
202 | */ |
|
203 | */ | |
203 |
|
204 | |||
204 | unsigned int i; |
|
205 | unsigned int i; | |
205 |
|
206 | |||
206 | // LOCAL PARAMETERS |
|
207 | // LOCAL PARAMETERS | |
207 | set_local_nb_interrupt_f0_MAX(); |
|
208 | set_local_nb_interrupt_f0_MAX(); | |
208 |
|
209 | |||
209 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
210 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
210 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
211 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
211 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
212 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
212 |
|
213 | |||
213 | // init sequence counters |
|
214 | // init sequence counters | |
214 |
|
215 | |||
215 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
216 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
216 | { |
|
217 | { | |
217 | sequenceCounters_TC_EXE[i] = 0x00; |
|
218 | sequenceCounters_TC_EXE[i] = 0x00; | |
218 | } |
|
219 | } | |
219 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
220 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
220 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
221 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
221 | } |
|
222 | } | |
222 |
|
223 | |||
223 | void create_names( void ) // create all names for tasks and queues |
|
224 | void create_names( void ) // create all names for tasks and queues | |
224 | { |
|
225 | { | |
225 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
226 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
226 | * |
|
227 | * | |
227 | * @return RTEMS directive status codes: |
|
228 | * @return RTEMS directive status codes: | |
228 | * - RTEMS_SUCCESSFUL - successful completion |
|
229 | * - RTEMS_SUCCESSFUL - successful completion | |
229 | * |
|
230 | * | |
230 | */ |
|
231 | */ | |
231 |
|
232 | |||
232 | // task names |
|
233 | // task names | |
233 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
234 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
234 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
235 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
235 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
236 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
236 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
237 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); | |
237 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
238 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
238 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
239 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
239 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); |
|
240 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); | |
240 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
241 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
241 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
242 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
242 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
243 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
243 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); |
|
244 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); | |
244 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
245 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
245 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
246 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
246 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
247 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
247 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
248 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
248 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
249 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
249 |
|
250 | |||
250 | // rate monotonic period names |
|
251 | // rate monotonic period names | |
251 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
252 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
252 |
|
253 | |||
253 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
254 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
254 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
255 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
255 | } |
|
256 | } | |
256 |
|
257 | |||
257 | int create_all_tasks( void ) // create all tasks which run in the software |
|
258 | int create_all_tasks( void ) // create all tasks which run in the software | |
258 | { |
|
259 | { | |
259 | /** This function creates all RTEMS tasks used in the software. |
|
260 | /** This function creates all RTEMS tasks used in the software. | |
260 | * |
|
261 | * | |
261 | * @return RTEMS directive status codes: |
|
262 | * @return RTEMS directive status codes: | |
262 | * - RTEMS_SUCCESSFUL - task created successfully |
|
263 | * - RTEMS_SUCCESSFUL - task created successfully | |
263 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
264 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
264 | * - RTEMS_INVALID_NAME - invalid task name |
|
265 | * - RTEMS_INVALID_NAME - invalid task name | |
265 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
266 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
266 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
267 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
267 | * - RTEMS_TOO_MANY - too many tasks created |
|
268 | * - RTEMS_TOO_MANY - too many tasks created | |
268 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
269 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
269 | * - RTEMS_TOO_MANY - too many global objects |
|
270 | * - RTEMS_TOO_MANY - too many global objects | |
270 | * |
|
271 | * | |
271 | */ |
|
272 | */ | |
272 |
|
273 | |||
273 | rtems_status_code status; |
|
274 | rtems_status_code status; | |
274 |
|
275 | |||
275 | // RECV |
|
276 | // RECV | |
276 | status = rtems_task_create( |
|
277 | status = rtems_task_create( | |
277 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
278 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
278 | RTEMS_DEFAULT_MODES, |
|
279 | RTEMS_DEFAULT_MODES, | |
279 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
280 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
280 | ); |
|
281 | ); | |
281 |
|
282 | |||
282 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
283 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
283 | { |
|
284 | { | |
284 | status = rtems_task_create( |
|
285 | status = rtems_task_create( | |
285 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
286 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
286 | RTEMS_DEFAULT_MODES, |
|
287 | RTEMS_DEFAULT_MODES, | |
287 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
288 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
288 | ); |
|
289 | ); | |
289 | } |
|
290 | } | |
290 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
291 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
291 | { |
|
292 | { | |
292 | status = rtems_task_create( |
|
293 | status = rtems_task_create( | |
293 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
294 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
294 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
295 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
295 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
296 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
296 | ); |
|
297 | ); | |
297 | } |
|
298 | } | |
298 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
299 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
299 | { |
|
300 | { | |
300 | status = rtems_task_create( |
|
301 | status = rtems_task_create( | |
301 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
302 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, | |
302 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
303 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
303 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] |
|
304 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] | |
304 | ); |
|
305 | ); | |
305 | } |
|
306 | } | |
306 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
307 | if (status == RTEMS_SUCCESSFUL) // STAT | |
307 | { |
|
308 | { | |
308 | status = rtems_task_create( |
|
309 | status = rtems_task_create( | |
309 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
310 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
310 | RTEMS_DEFAULT_MODES, |
|
311 | RTEMS_DEFAULT_MODES, | |
311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
312 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
312 | ); |
|
313 | ); | |
313 | } |
|
314 | } | |
314 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
315 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
315 | { |
|
316 | { | |
316 | status = rtems_task_create( |
|
317 | status = rtems_task_create( | |
317 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
318 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
318 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
319 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
319 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
320 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
320 | ); |
|
321 | ); | |
321 | } |
|
322 | } | |
322 | if (status == RTEMS_SUCCESSFUL) // BPF0 |
|
323 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
323 | { |
|
324 | { | |
324 | status = rtems_task_create( |
|
325 | status = rtems_task_create( | |
325 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, |
|
326 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, | |
326 | RTEMS_DEFAULT_MODES, |
|
327 | RTEMS_DEFAULT_MODES, | |
327 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] |
|
328 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] | |
328 | ); |
|
329 | ); | |
329 | } |
|
330 | } | |
330 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
331 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
331 | { |
|
332 | { | |
332 | status = rtems_task_create( |
|
333 | status = rtems_task_create( | |
333 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
334 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
334 | RTEMS_DEFAULT_MODES, |
|
335 | RTEMS_DEFAULT_MODES, | |
335 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
336 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
336 | ); |
|
337 | ); | |
337 | } |
|
338 | } | |
338 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
339 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
339 | { |
|
340 | { | |
340 | status = rtems_task_create( |
|
341 | status = rtems_task_create( | |
341 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
342 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
342 | RTEMS_DEFAULT_MODES, |
|
343 | RTEMS_DEFAULT_MODES, | |
343 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
344 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
344 | ); |
|
345 | ); | |
345 | } |
|
346 | } | |
346 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
347 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
347 | { |
|
348 | { | |
348 | status = rtems_task_create( |
|
349 | status = rtems_task_create( | |
349 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
350 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
350 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
351 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
351 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] |
|
352 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] | |
352 | ); |
|
353 | ); | |
353 | } |
|
354 | } | |
354 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
355 | if (status == RTEMS_SUCCESSFUL) // MATR | |
355 | { |
|
356 | { | |
356 | status = rtems_task_create( |
|
357 | status = rtems_task_create( | |
357 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, |
|
358 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, | |
358 | RTEMS_DEFAULT_MODES, |
|
359 | RTEMS_DEFAULT_MODES, | |
359 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] |
|
360 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] | |
360 | ); |
|
361 | ); | |
361 | } |
|
362 | } | |
362 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
363 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
363 | { |
|
364 | { | |
364 | status = rtems_task_create( |
|
365 | status = rtems_task_create( | |
365 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
366 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
366 | RTEMS_DEFAULT_MODES, |
|
367 | RTEMS_DEFAULT_MODES, | |
367 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] |
|
368 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
368 | ); |
|
369 | ); | |
369 | } |
|
370 | } | |
370 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
371 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
371 | { |
|
372 | { | |
372 | status = rtems_task_create( |
|
373 | status = rtems_task_create( | |
373 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
374 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
374 | RTEMS_DEFAULT_MODES, |
|
375 | RTEMS_DEFAULT_MODES, | |
375 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] |
|
376 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
376 | ); |
|
377 | ); | |
377 | } |
|
378 | } | |
378 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
379 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
379 | { |
|
380 | { | |
380 | status = rtems_task_create( |
|
381 | status = rtems_task_create( | |
381 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
382 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
382 | RTEMS_DEFAULT_MODES, |
|
383 | RTEMS_DEFAULT_MODES, | |
383 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] |
|
384 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
384 | ); |
|
385 | ); | |
385 | } |
|
386 | } | |
386 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
387 | if (status == RTEMS_SUCCESSFUL) // SEND | |
387 | { |
|
388 | { | |
388 | status = rtems_task_create( |
|
389 | status = rtems_task_create( | |
389 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
390 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, | |
390 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
391 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
391 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
392 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] | |
392 | ); |
|
393 | ); | |
393 | } |
|
394 | } | |
394 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
395 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
395 | { |
|
396 | { | |
396 | status = rtems_task_create( |
|
397 | status = rtems_task_create( | |
397 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
398 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
398 | RTEMS_DEFAULT_MODES, |
|
399 | RTEMS_DEFAULT_MODES, | |
399 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
400 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
400 | ); |
|
401 | ); | |
401 | } |
|
402 | } | |
402 |
|
403 | |||
403 | return status; |
|
404 | return status; | |
404 | } |
|
405 | } | |
405 |
|
406 | |||
406 | int start_recv_send_tasks( void ) |
|
407 | int start_recv_send_tasks( void ) | |
407 | { |
|
408 | { | |
408 | rtems_status_code status; |
|
409 | rtems_status_code status; | |
409 |
|
410 | |||
410 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
411 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
411 | if (status!=RTEMS_SUCCESSFUL) { |
|
412 | if (status!=RTEMS_SUCCESSFUL) { | |
412 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
413 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
413 | } |
|
414 | } | |
414 |
|
415 | |||
415 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
416 | if (status == RTEMS_SUCCESSFUL) // SEND | |
416 | { |
|
417 | { | |
417 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
418 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
418 | if (status!=RTEMS_SUCCESSFUL) { |
|
419 | if (status!=RTEMS_SUCCESSFUL) { | |
419 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
420 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
420 | } |
|
421 | } | |
421 | } |
|
422 | } | |
422 |
|
423 | |||
423 | return status; |
|
424 | return status; | |
424 | } |
|
425 | } | |
425 |
|
426 | |||
426 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
427 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
427 | { |
|
428 | { | |
428 | /** This function starts all RTEMS tasks used in the software. |
|
429 | /** This function starts all RTEMS tasks used in the software. | |
429 | * |
|
430 | * | |
430 | * @return RTEMS directive status codes: |
|
431 | * @return RTEMS directive status codes: | |
431 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
432 | * - RTEMS_SUCCESSFUL - ask started successfully | |
432 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
433 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
433 | * - RTEMS_INVALID_ID - invalid task id |
|
434 | * - RTEMS_INVALID_ID - invalid task id | |
434 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
435 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
435 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
436 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
436 | * |
|
437 | * | |
437 | */ |
|
438 | */ | |
438 | // starts all the tasks fot eh flight software |
|
439 | // starts all the tasks fot eh flight software | |
439 |
|
440 | |||
440 | rtems_status_code status; |
|
441 | rtems_status_code status; | |
441 |
|
442 | |||
442 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
443 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
443 | if (status!=RTEMS_SUCCESSFUL) { |
|
444 | if (status!=RTEMS_SUCCESSFUL) { | |
444 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
445 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
445 | } |
|
446 | } | |
446 |
|
447 | |||
447 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
448 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
448 | { |
|
449 | { | |
449 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
450 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
450 | if (status!=RTEMS_SUCCESSFUL) { |
|
451 | if (status!=RTEMS_SUCCESSFUL) { | |
451 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
452 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
452 | } |
|
453 | } | |
453 | } |
|
454 | } | |
454 |
|
455 | |||
455 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
456 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
456 | { |
|
457 | { | |
457 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); |
|
458 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); | |
458 | if (status!=RTEMS_SUCCESSFUL) { |
|
459 | if (status!=RTEMS_SUCCESSFUL) { | |
459 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") |
|
460 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") | |
460 | } |
|
461 | } | |
461 | } |
|
462 | } | |
462 |
|
463 | |||
463 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
464 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
464 | { |
|
465 | { | |
465 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
466 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
466 | if (status!=RTEMS_SUCCESSFUL) { |
|
467 | if (status!=RTEMS_SUCCESSFUL) { | |
467 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
468 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
468 | } |
|
469 | } | |
469 | } |
|
470 | } | |
470 |
|
471 | |||
471 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
472 | if (status == RTEMS_SUCCESSFUL) // STAT | |
472 | { |
|
473 | { | |
473 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
474 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
474 | if (status!=RTEMS_SUCCESSFUL) { |
|
475 | if (status!=RTEMS_SUCCESSFUL) { | |
475 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
476 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
476 | } |
|
477 | } | |
477 | } |
|
478 | } | |
478 |
|
479 | |||
479 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
480 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
480 | { |
|
481 | { | |
481 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); |
|
482 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); | |
482 | if (status!=RTEMS_SUCCESSFUL) { |
|
483 | if (status!=RTEMS_SUCCESSFUL) { | |
483 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
484 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
484 | } |
|
485 | } | |
485 | } |
|
486 | } | |
486 |
|
487 | |||
487 | if (status == RTEMS_SUCCESSFUL) // BPF0 |
|
488 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
488 | { |
|
489 | { | |
489 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); |
|
490 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); | |
490 | if (status!=RTEMS_SUCCESSFUL) { |
|
491 | if (status!=RTEMS_SUCCESSFUL) { | |
491 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") |
|
492 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") | |
492 | } |
|
493 | } | |
493 | } |
|
494 | } | |
494 |
|
495 | |||
495 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
496 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
496 | { |
|
497 | { | |
497 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
498 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
498 | if (status!=RTEMS_SUCCESSFUL) { |
|
499 | if (status!=RTEMS_SUCCESSFUL) { | |
499 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
500 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
500 | } |
|
501 | } | |
501 | } |
|
502 | } | |
502 |
|
503 | |||
503 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
504 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
504 | { |
|
505 | { | |
505 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
506 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
506 | if (status!=RTEMS_SUCCESSFUL) { |
|
507 | if (status!=RTEMS_SUCCESSFUL) { | |
507 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
508 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
508 | } |
|
509 | } | |
509 | } |
|
510 | } | |
510 |
|
511 | |||
511 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
512 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
512 | { |
|
513 | { | |
513 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
514 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
514 | if (status!=RTEMS_SUCCESSFUL) { |
|
515 | if (status!=RTEMS_SUCCESSFUL) { | |
515 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
516 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
516 | } |
|
517 | } | |
517 | } |
|
518 | } | |
518 |
|
519 | |||
519 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
520 | if (status == RTEMS_SUCCESSFUL) // MATR | |
520 | { |
|
521 | { | |
521 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); |
|
522 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); | |
522 | if (status!=RTEMS_SUCCESSFUL) { |
|
523 | if (status!=RTEMS_SUCCESSFUL) { | |
523 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") |
|
524 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") | |
524 | } |
|
525 | } | |
525 | } |
|
526 | } | |
526 |
|
527 | |||
527 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
528 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
528 | { |
|
529 | { | |
529 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
530 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
530 | if (status!=RTEMS_SUCCESSFUL) { |
|
531 | if (status!=RTEMS_SUCCESSFUL) { | |
531 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
532 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
532 | } |
|
533 | } | |
533 | } |
|
534 | } | |
534 |
|
535 | |||
535 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
536 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
536 | { |
|
537 | { | |
537 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
538 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
538 | if (status!=RTEMS_SUCCESSFUL) { |
|
539 | if (status!=RTEMS_SUCCESSFUL) { | |
539 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
540 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
540 | } |
|
541 | } | |
541 | } |
|
542 | } | |
542 |
|
543 | |||
543 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
544 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
544 | { |
|
545 | { | |
545 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
546 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
546 | if (status!=RTEMS_SUCCESSFUL) { |
|
547 | if (status!=RTEMS_SUCCESSFUL) { | |
547 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
548 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
548 | } |
|
549 | } | |
549 | } |
|
550 | } | |
550 | return status; |
|
551 | return status; | |
551 | } |
|
552 | } | |
552 |
|
553 | |||
553 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
554 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
554 | { |
|
555 | { | |
555 | rtems_status_code status_recv; |
|
556 | rtems_status_code status_recv; | |
556 | rtems_status_code status_send; |
|
557 | rtems_status_code status_send; | |
557 | rtems_status_code ret; |
|
558 | rtems_status_code ret; | |
558 | rtems_id queue_id; |
|
559 | rtems_id queue_id; | |
559 |
|
560 | |||
560 | // create the queue for handling valid TCs |
|
561 | // create the queue for handling valid TCs | |
561 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
562 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
562 | ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, |
|
563 | ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, | |
563 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
564 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
564 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
565 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
565 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
566 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
566 | } |
|
567 | } | |
567 |
|
568 | |||
568 | // create the queue for handling TM packet sending |
|
569 | // create the queue for handling TM packet sending | |
569 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
570 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
570 | ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE, |
|
571 | ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE, | |
571 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
572 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
572 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
573 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
573 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
574 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
574 | } |
|
575 | } | |
575 |
|
576 | |||
576 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
577 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
577 | { |
|
578 | { | |
578 | ret = status_recv; |
|
579 | ret = status_recv; | |
579 | } |
|
580 | } | |
580 | else |
|
581 | else | |
581 | { |
|
582 | { | |
582 | ret = status_send; |
|
583 | ret = status_send; | |
583 | } |
|
584 | } | |
584 |
|
585 | |||
585 | return ret; |
|
586 | return ret; | |
586 | } |
|
587 | } | |
587 |
|
588 | |||
588 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
589 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) | |
589 | { |
|
590 | { | |
590 | rtems_status_code status; |
|
591 | rtems_status_code status; | |
591 | rtems_name queue_name; |
|
592 | rtems_name queue_name; | |
592 |
|
593 | |||
593 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
594 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
594 |
|
595 | |||
595 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
596 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
596 |
|
597 | |||
597 | return status; |
|
598 | return status; | |
598 | } |
|
599 | } | |
599 |
|
600 | |||
600 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
601 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) | |
601 | { |
|
602 | { | |
602 | rtems_status_code status; |
|
603 | rtems_status_code status; | |
603 | rtems_name queue_name; |
|
604 | rtems_name queue_name; | |
604 |
|
605 | |||
605 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
606 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
606 |
|
607 | |||
607 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
608 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
608 |
|
609 | |||
609 | return status; |
|
610 | return status; | |
610 | } |
|
611 | } |
@@ -1,601 +1,601 | |||||
1 | /** Functions related to the SpaceWire interface. |
|
1 | /** Functions related to the SpaceWire interface. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle SpaceWire transmissions: |
|
6 | * A group of functions to handle SpaceWire transmissions: | |
7 | * - configuration of the SpaceWire link |
|
7 | * - configuration of the SpaceWire link | |
8 | * - SpaceWire related interruption requests processing |
|
8 | * - SpaceWire related interruption requests processing | |
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task | |
10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
10 | * - reception of TeleCommands by a dedicated RTEMS task | |
11 | * |
|
11 | * | |
12 | */ |
|
12 | */ | |
13 |
|
13 | |||
14 | #include "fsw_spacewire.h" |
|
14 | #include "fsw_spacewire.h" | |
15 |
|
15 | |||
16 | rtems_name semq_name; |
|
16 | rtems_name semq_name; | |
17 | rtems_id semq_id; |
|
17 | rtems_id semq_id; | |
18 |
|
18 | |||
19 | //*********** |
|
19 | //*********** | |
20 | // RTEMS TASK |
|
20 | // RTEMS TASK | |
21 | rtems_task spiq_task(rtems_task_argument unused) |
|
21 | rtems_task spiq_task(rtems_task_argument unused) | |
22 | { |
|
22 | { | |
23 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
23 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. | |
24 | * |
|
24 | * | |
25 | * @param unused is the starting argument of the RTEMS task |
|
25 | * @param unused is the starting argument of the RTEMS task | |
26 | * |
|
26 | * | |
27 | */ |
|
27 | */ | |
28 |
|
28 | |||
29 | rtems_event_set event_out; |
|
29 | rtems_event_set event_out; | |
30 | rtems_status_code status; |
|
30 | rtems_status_code status; | |
31 | int linkStatus; |
|
31 | int linkStatus; | |
32 |
|
32 | |||
33 | BOOT_PRINTF("in SPIQ *** \n") |
|
33 | BOOT_PRINTF("in SPIQ *** \n") | |
34 |
|
34 | |||
35 | while(true){ |
|
35 | while(true){ | |
36 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
36 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
37 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
37 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") | |
38 |
|
38 | |||
39 | // [0] SUSPEND RECV AND SEND TASKS |
|
39 | // [0] SUSPEND RECV AND SEND TASKS | |
40 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
40 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); | |
41 | if ( status != RTEMS_SUCCESSFUL ) { |
|
41 | if ( status != RTEMS_SUCCESSFUL ) { | |
42 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
42 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") | |
43 | } |
|
43 | } | |
44 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
44 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); | |
45 | if ( status != RTEMS_SUCCESSFUL ) { |
|
45 | if ( status != RTEMS_SUCCESSFUL ) { | |
46 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
46 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | // [1] CHECK THE LINK |
|
49 | // [1] CHECK THE LINK | |
50 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
50 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) | |
51 | if ( linkStatus != 5) { |
|
51 | if ( linkStatus != 5) { | |
52 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
52 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) | |
53 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
53 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
56 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT | |
57 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
57 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) | |
58 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
58 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link | |
59 | { |
|
59 | { | |
60 | spacewire_compute_stats_offsets(); |
|
60 | spacewire_compute_stats_offsets(); | |
61 | status = spacewire_reset_link( ); |
|
61 | status = spacewire_reset_link( ); | |
62 | } |
|
62 | } | |
63 | else // [2.b] in run state, start the link |
|
63 | else // [2.b] in run state, start the link | |
64 | { |
|
64 | { | |
65 | status = spacewire_stop_start_link( fdSPW ); // start the link |
|
65 | status = spacewire_stop_start_link( fdSPW ); // start the link | |
66 | if ( status != RTEMS_SUCCESSFUL) |
|
66 | if ( status != RTEMS_SUCCESSFUL) | |
67 | { |
|
67 | { | |
68 | PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status) |
|
68 | PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status) | |
69 | } |
|
69 | } | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
72 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS | |
73 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
73 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully | |
74 | { |
|
74 | { | |
75 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
75 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
76 | if ( status != RTEMS_SUCCESSFUL ) { |
|
76 | if ( status != RTEMS_SUCCESSFUL ) { | |
77 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
77 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") | |
78 | } |
|
78 | } | |
79 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
79 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
80 | if ( status != RTEMS_SUCCESSFUL ) { |
|
80 | if ( status != RTEMS_SUCCESSFUL ) { | |
81 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
81 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") | |
82 | } |
|
82 | } | |
83 | } |
|
83 | } | |
84 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
84 | else // [3.b] the link is not in run state, go in STANDBY mode | |
85 | { |
|
85 | { | |
86 | status = stop_current_mode(); |
|
86 | status = stop_current_mode(); | |
87 | if ( status != RTEMS_SUCCESSFUL ) { |
|
87 | if ( status != RTEMS_SUCCESSFUL ) { | |
88 | PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) |
|
88 | PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) | |
89 | } |
|
89 | } | |
90 |
status = enter_ |
|
90 | status = enter_mode( LFR_MODE_STANDBY ); | |
91 | if ( status != RTEMS_SUCCESSFUL ) { |
|
91 | if ( status != RTEMS_SUCCESSFUL ) { | |
92 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
92 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
93 | } |
|
93 | } | |
94 | // wake the WTDG task up to wait for the link recovery |
|
94 | // wake the WTDG task up to wait for the link recovery | |
95 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
95 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); | |
96 | status = rtems_task_suspend( RTEMS_SELF ); |
|
96 | status = rtems_task_suspend( RTEMS_SELF ); | |
97 | } |
|
97 | } | |
98 | } |
|
98 | } | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | rtems_task recv_task( rtems_task_argument unused ) |
|
101 | rtems_task recv_task( rtems_task_argument unused ) | |
102 | { |
|
102 | { | |
103 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
103 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
104 | * |
|
104 | * | |
105 | * @param unused is the starting argument of the RTEMS task |
|
105 | * @param unused is the starting argument of the RTEMS task | |
106 | * |
|
106 | * | |
107 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
107 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
108 | * 1. It reads the incoming data. |
|
108 | * 1. It reads the incoming data. | |
109 | * 2. Launches the acceptance procedure. |
|
109 | * 2. Launches the acceptance procedure. | |
110 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
110 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
111 | * |
|
111 | * | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | int len; |
|
114 | int len; | |
115 | ccsdsTelecommandPacket_t currentTC; |
|
115 | ccsdsTelecommandPacket_t currentTC; | |
116 | unsigned char computed_CRC[ 2 ]; |
|
116 | unsigned char computed_CRC[ 2 ]; | |
117 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
117 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
118 | unsigned char destinationID; |
|
118 | unsigned char destinationID; | |
119 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; |
|
119 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; | |
120 | unsigned int parserCode; |
|
120 | unsigned int parserCode; | |
121 | unsigned char time[6]; |
|
121 | unsigned char time[6]; | |
122 | rtems_status_code status; |
|
122 | rtems_status_code status; | |
123 | rtems_id queue_recv_id; |
|
123 | rtems_id queue_recv_id; | |
124 | rtems_id queue_send_id; |
|
124 | rtems_id queue_send_id; | |
125 |
|
125 | |||
126 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
126 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
127 |
|
127 | |||
128 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
128 | status = get_message_queue_id_recv( &queue_recv_id ); | |
129 | if (status != RTEMS_SUCCESSFUL) |
|
129 | if (status != RTEMS_SUCCESSFUL) | |
130 | { |
|
130 | { | |
131 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
131 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | status = get_message_queue_id_send( &queue_send_id ); |
|
134 | status = get_message_queue_id_send( &queue_send_id ); | |
135 | if (status != RTEMS_SUCCESSFUL) |
|
135 | if (status != RTEMS_SUCCESSFUL) | |
136 | { |
|
136 | { | |
137 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
137 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | BOOT_PRINTF("in RECV *** \n") |
|
140 | BOOT_PRINTF("in RECV *** \n") | |
141 |
|
141 | |||
142 | while(1) |
|
142 | while(1) | |
143 | { |
|
143 | { | |
144 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
144 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
145 | if (len == -1){ // error during the read call |
|
145 | if (len == -1){ // error during the read call | |
146 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
146 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
147 | } |
|
147 | } | |
148 | else { |
|
148 | else { | |
149 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
149 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
150 | PRINTF("in RECV *** packet lenght too short\n") |
|
150 | PRINTF("in RECV *** packet lenght too short\n") | |
151 | } |
|
151 | } | |
152 | else { |
|
152 | else { | |
153 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
153 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
154 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8); |
|
154 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8); | |
155 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt ); |
|
155 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt ); | |
156 | // CHECK THE TC |
|
156 | // CHECK THE TC | |
157 | parserCode = tc_parser( ¤tTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ; |
|
157 | parserCode = tc_parser( ¤tTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ; | |
158 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
158 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
159 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
159 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
160 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
160 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
161 | || (parserCode == WRONG_SRC_ID) ) |
|
161 | || (parserCode == WRONG_SRC_ID) ) | |
162 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
162 | { // send TM_LFR_TC_EXE_CORRUPTED | |
163 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
163 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
164 | && |
|
164 | && | |
165 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
165 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
166 | ) |
|
166 | ) | |
167 | { |
|
167 | { | |
168 | if ( parserCode == WRONG_SRC_ID ) |
|
168 | if ( parserCode == WRONG_SRC_ID ) | |
169 | { |
|
169 | { | |
170 | destinationID = SID_TC_GROUND; |
|
170 | destinationID = SID_TC_GROUND; | |
171 | } |
|
171 | } | |
172 | else |
|
172 | else | |
173 | { |
|
173 | { | |
174 | destinationID = currentTC.sourceID; |
|
174 | destinationID = currentTC.sourceID; | |
175 | } |
|
175 | } | |
176 | getTime( time ); |
|
176 | getTime( time ); | |
177 | close_action( ¤tTC, LFR_DEFAULT, queue_send_id, time); |
|
177 | close_action( ¤tTC, LFR_DEFAULT, queue_send_id, time); | |
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
179 | computed_CRC, currentTC_LEN_RCV, |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
180 | destinationID, time ); |
|
180 | destinationID, time ); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { // send valid TC to the action launcher |
|
184 | { // send valid TC to the action launcher | |
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
186 | currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
186 | currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | rtems_task send_task( rtems_task_argument argument) |
|
193 | rtems_task send_task( rtems_task_argument argument) | |
194 | { |
|
194 | { | |
195 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
195 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
196 | * |
|
196 | * | |
197 | * @param unused is the starting argument of the RTEMS task |
|
197 | * @param unused is the starting argument of the RTEMS task | |
198 | * |
|
198 | * | |
199 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
199 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
200 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
200 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
201 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
201 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
202 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
202 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
203 | * data it contains. |
|
203 | * data it contains. | |
204 | * |
|
204 | * | |
205 | */ |
|
205 | */ | |
206 |
|
206 | |||
207 | rtems_status_code status; // RTEMS status code |
|
207 | rtems_status_code status; // RTEMS status code | |
208 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer |
|
208 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer | |
209 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
209 | spw_ioctl_pkt_send *spw_ioctl_send; | |
210 | size_t size; // size of the incoming TC packet |
|
210 | size_t size; // size of the incoming TC packet | |
211 | u_int32_t count; |
|
211 | u_int32_t count; | |
212 | rtems_id queue_id; |
|
212 | rtems_id queue_id; | |
213 |
|
213 | |||
214 | status = get_message_queue_id_send( &queue_id ); |
|
214 | status = get_message_queue_id_send( &queue_id ); | |
215 | if (status != RTEMS_SUCCESSFUL) |
|
215 | if (status != RTEMS_SUCCESSFUL) | |
216 | { |
|
216 | { | |
217 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
217 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | BOOT_PRINTF("in SEND *** \n") |
|
220 | BOOT_PRINTF("in SEND *** \n") | |
221 |
|
221 | |||
222 | while(1) |
|
222 | while(1) | |
223 | { |
|
223 | { | |
224 | status = rtems_message_queue_receive( queue_id, incomingData, &size, |
|
224 | status = rtems_message_queue_receive( queue_id, incomingData, &size, | |
225 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
225 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
226 |
|
226 | |||
227 | if (status!=RTEMS_SUCCESSFUL) |
|
227 | if (status!=RTEMS_SUCCESSFUL) | |
228 | { |
|
228 | { | |
229 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
229 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
230 | } |
|
230 | } | |
231 | else |
|
231 | else | |
232 | { |
|
232 | { | |
233 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet |
|
233 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet | |
234 | { |
|
234 | { | |
235 | status = write( fdSPW, incomingData, size ); |
|
235 | status = write( fdSPW, incomingData, size ); | |
236 | if (status == -1){ |
|
236 | if (status == -1){ | |
237 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
237 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
238 | } |
|
238 | } | |
239 | } |
|
239 | } | |
240 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
240 | else // the incoming message is a spw_ioctl_pkt_send structure | |
241 | { |
|
241 | { | |
242 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
242 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
243 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
243 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
244 | if (status == -1){ |
|
244 | if (status == -1){ | |
245 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
245 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
246 | } |
|
246 | } | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
250 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
251 | if (status != RTEMS_SUCCESSFUL) |
|
251 | if (status != RTEMS_SUCCESSFUL) | |
252 | { |
|
252 | { | |
253 | PRINTF1("in SEND *** (3) ERR = %d\n", status) |
|
253 | PRINTF1("in SEND *** (3) ERR = %d\n", status) | |
254 | } |
|
254 | } | |
255 | else |
|
255 | else | |
256 | { |
|
256 | { | |
257 | if (count > maxCount) |
|
257 | if (count > maxCount) | |
258 | { |
|
258 | { | |
259 | maxCount = count; |
|
259 | maxCount = count; | |
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 | } |
|
262 | } | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
265 | rtems_task wtdg_task( rtems_task_argument argument ) | |
266 | { |
|
266 | { | |
267 | rtems_event_set event_out; |
|
267 | rtems_event_set event_out; | |
268 | rtems_status_code status; |
|
268 | rtems_status_code status; | |
269 | int linkStatus; |
|
269 | int linkStatus; | |
270 |
|
270 | |||
271 | BOOT_PRINTF("in WTDG ***\n") |
|
271 | BOOT_PRINTF("in WTDG ***\n") | |
272 |
|
272 | |||
273 | while(1) |
|
273 | while(1) | |
274 | { |
|
274 | { | |
275 | // wait for an RTEMS_EVENT |
|
275 | // wait for an RTEMS_EVENT | |
276 | rtems_event_receive( RTEMS_EVENT_0, |
|
276 | rtems_event_receive( RTEMS_EVENT_0, | |
277 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
277 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
278 | PRINTF("in WTDG *** wait for the link\n") |
|
278 | PRINTF("in WTDG *** wait for the link\n") | |
279 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
279 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
280 | while( linkStatus != 5) // wait for the link |
|
280 | while( linkStatus != 5) // wait for the link | |
281 | { |
|
281 | { | |
282 | rtems_task_wake_after( 10 ); |
|
282 | rtems_task_wake_after( 10 ); | |
283 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
283 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | status = spacewire_stop_start_link( fdSPW ); |
|
286 | status = spacewire_stop_start_link( fdSPW ); | |
287 |
|
287 | |||
288 | if (status != RTEMS_SUCCESSFUL) |
|
288 | if (status != RTEMS_SUCCESSFUL) | |
289 | { |
|
289 | { | |
290 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
290 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
291 | } |
|
291 | } | |
292 | else |
|
292 | else | |
293 | { |
|
293 | { | |
294 | PRINTF("in WTDG *** OK link started\n") |
|
294 | PRINTF("in WTDG *** OK link started\n") | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 | // restart the SPIQ task |
|
297 | // restart the SPIQ task | |
298 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
298 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
299 | if ( status != RTEMS_SUCCESSFUL ) { |
|
299 | if ( status != RTEMS_SUCCESSFUL ) { | |
300 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
300 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | // restart RECV and SEND |
|
303 | // restart RECV and SEND | |
304 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
304 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
305 | if ( status != RTEMS_SUCCESSFUL ) { |
|
305 | if ( status != RTEMS_SUCCESSFUL ) { | |
306 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
306 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
307 | } |
|
307 | } | |
308 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
308 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
309 | if ( status != RTEMS_SUCCESSFUL ) { |
|
309 | if ( status != RTEMS_SUCCESSFUL ) { | |
310 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
310 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
311 | } |
|
311 | } | |
312 | } |
|
312 | } | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | //**************** |
|
315 | //**************** | |
316 | // OTHER FUNCTIONS |
|
316 | // OTHER FUNCTIONS | |
317 | int spacewire_open_link( void ) |
|
317 | int spacewire_open_link( void ) | |
318 | { |
|
318 | { | |
319 | /** This function opens the SpaceWire link. |
|
319 | /** This function opens the SpaceWire link. | |
320 | * |
|
320 | * | |
321 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
321 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
322 | * |
|
322 | * | |
323 | */ |
|
323 | */ | |
324 | rtems_status_code status; |
|
324 | rtems_status_code status; | |
325 |
|
325 | |||
326 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
326 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
327 | if ( fdSPW < 0 ) { |
|
327 | if ( fdSPW < 0 ) { | |
328 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
328 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
329 | } |
|
329 | } | |
330 | else |
|
330 | else | |
331 | { |
|
331 | { | |
332 | status = RTEMS_SUCCESSFUL; |
|
332 | status = RTEMS_SUCCESSFUL; | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 | return status; |
|
335 | return status; | |
336 | } |
|
336 | } | |
337 |
|
337 | |||
338 | int spacewire_start_link( int fd ) |
|
338 | int spacewire_start_link( int fd ) | |
339 | { |
|
339 | { | |
340 | rtems_status_code status; |
|
340 | rtems_status_code status; | |
341 |
|
341 | |||
342 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
342 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
343 | // -1 default hardcoded driver timeout |
|
343 | // -1 default hardcoded driver timeout | |
344 |
|
344 | |||
345 | return status; |
|
345 | return status; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | int spacewire_stop_start_link( int fd ) |
|
348 | int spacewire_stop_start_link( int fd ) | |
349 | { |
|
349 | { | |
350 | rtems_status_code status; |
|
350 | rtems_status_code status; | |
351 |
|
351 | |||
352 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
352 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
353 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
353 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
354 | // -1 default hardcoded driver timeout |
|
354 | // -1 default hardcoded driver timeout | |
355 |
|
355 | |||
356 | return status; |
|
356 | return status; | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | int spacewire_configure_link( int fd ) |
|
359 | int spacewire_configure_link( int fd ) | |
360 | { |
|
360 | { | |
361 | /** This function configures the SpaceWire link. |
|
361 | /** This function configures the SpaceWire link. | |
362 | * |
|
362 | * | |
363 | * @return GR-RTEMS-DRIVER directive status codes: |
|
363 | * @return GR-RTEMS-DRIVER directive status codes: | |
364 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
364 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
365 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
365 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
366 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
366 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
367 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
367 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
368 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
368 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
369 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
369 | * - 5 EIO - Error when writing to grswp hardware registers. | |
370 | * - 2 ENOENT - No such file or directory |
|
370 | * - 2 ENOENT - No such file or directory | |
371 | */ |
|
371 | */ | |
372 |
|
372 | |||
373 | rtems_status_code status; |
|
373 | rtems_status_code status; | |
374 |
|
374 | |||
375 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
375 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
376 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
376 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
377 |
|
377 | |||
378 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
378 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
379 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
379 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
380 | // |
|
380 | // | |
381 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
381 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
382 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
382 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
383 | // |
|
383 | // | |
384 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
384 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
385 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
385 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
386 | // |
|
386 | // | |
387 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
387 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
388 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
388 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
389 | // |
|
389 | // | |
390 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks |
|
390 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks | |
391 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
391 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
392 | // |
|
392 | // | |
393 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
393 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
394 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
394 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
395 | // |
|
395 | // | |
396 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
396 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
397 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
397 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
398 |
|
398 | |||
399 | return status; |
|
399 | return status; | |
400 | } |
|
400 | } | |
401 |
|
401 | |||
402 | int spacewire_reset_link( void ) |
|
402 | int spacewire_reset_link( void ) | |
403 | { |
|
403 | { | |
404 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
404 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
405 | * |
|
405 | * | |
406 | * @return RTEMS directive status code: |
|
406 | * @return RTEMS directive status code: | |
407 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
407 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
408 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
408 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
409 | * |
|
409 | * | |
410 | */ |
|
410 | */ | |
411 |
|
411 | |||
412 | rtems_status_code status_spw; |
|
412 | rtems_status_code status_spw; | |
413 | int i; |
|
413 | int i; | |
414 |
|
414 | |||
415 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
415 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
416 | { |
|
416 | { | |
417 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
417 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
418 |
|
418 | |||
419 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
419 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
420 |
|
420 | |||
421 | status_spw = spacewire_stop_start_link( fdSPW ); |
|
421 | status_spw = spacewire_stop_start_link( fdSPW ); | |
422 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
422 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
423 | { |
|
423 | { | |
424 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
424 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
425 | } |
|
425 | } | |
426 |
|
426 | |||
427 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
427 | if ( status_spw == RTEMS_SUCCESSFUL) | |
428 | { |
|
428 | { | |
429 | break; |
|
429 | break; | |
430 | } |
|
430 | } | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 | return status_spw; |
|
433 | return status_spw; | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
436 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
437 | { |
|
437 | { | |
438 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
438 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
439 | * |
|
439 | * | |
440 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
440 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
441 | * @param regAddr is the address of the GRSPW control register. |
|
441 | * @param regAddr is the address of the GRSPW control register. | |
442 | * |
|
442 | * | |
443 | * NP is the bit 20 of the GRSPW control register. |
|
443 | * NP is the bit 20 of the GRSPW control register. | |
444 | * |
|
444 | * | |
445 | */ |
|
445 | */ | |
446 |
|
446 | |||
447 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
447 | unsigned int *spwptr = (unsigned int*) regAddr; | |
448 |
|
448 | |||
449 | if (val == 1) { |
|
449 | if (val == 1) { | |
450 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
450 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
451 | } |
|
451 | } | |
452 | if (val== 0) { |
|
452 | if (val== 0) { | |
453 | *spwptr = *spwptr & 0xffdfffff; |
|
453 | *spwptr = *spwptr & 0xffdfffff; | |
454 | } |
|
454 | } | |
455 | } |
|
455 | } | |
456 |
|
456 | |||
457 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
457 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
458 | { |
|
458 | { | |
459 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
459 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
460 | * |
|
460 | * | |
461 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
461 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
462 | * @param regAddr is the address of the GRSPW control register. |
|
462 | * @param regAddr is the address of the GRSPW control register. | |
463 | * |
|
463 | * | |
464 | * RE is the bit 16 of the GRSPW control register. |
|
464 | * RE is the bit 16 of the GRSPW control register. | |
465 | * |
|
465 | * | |
466 | */ |
|
466 | */ | |
467 |
|
467 | |||
468 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
468 | unsigned int *spwptr = (unsigned int*) regAddr; | |
469 |
|
469 | |||
470 | if (val == 1) |
|
470 | if (val == 1) | |
471 | { |
|
471 | { | |
472 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
472 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
473 | } |
|
473 | } | |
474 | if (val== 0) |
|
474 | if (val== 0) | |
475 | { |
|
475 | { | |
476 | *spwptr = *spwptr & 0xfffdffff; |
|
476 | *spwptr = *spwptr & 0xfffdffff; | |
477 | } |
|
477 | } | |
478 | } |
|
478 | } | |
479 |
|
479 | |||
480 | void spacewire_compute_stats_offsets( void ) |
|
480 | void spacewire_compute_stats_offsets( void ) | |
481 | { |
|
481 | { | |
482 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
482 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
483 | * |
|
483 | * | |
484 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
484 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
485 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
485 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
486 | * during the open systel call). |
|
486 | * during the open systel call). | |
487 | * |
|
487 | * | |
488 | */ |
|
488 | */ | |
489 |
|
489 | |||
490 | spw_stats spacewire_stats_grspw; |
|
490 | spw_stats spacewire_stats_grspw; | |
491 | rtems_status_code status; |
|
491 | rtems_status_code status; | |
492 |
|
492 | |||
493 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
493 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
494 |
|
494 | |||
495 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
495 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
496 | + spacewire_stats.packets_received; |
|
496 | + spacewire_stats.packets_received; | |
497 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
497 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
498 | + spacewire_stats.packets_sent; |
|
498 | + spacewire_stats.packets_sent; | |
499 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
499 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
500 | + spacewire_stats.parity_err; |
|
500 | + spacewire_stats.parity_err; | |
501 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
501 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
502 | + spacewire_stats.disconnect_err; |
|
502 | + spacewire_stats.disconnect_err; | |
503 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
503 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
504 | + spacewire_stats.escape_err; |
|
504 | + spacewire_stats.escape_err; | |
505 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
505 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
506 | + spacewire_stats.credit_err; |
|
506 | + spacewire_stats.credit_err; | |
507 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
507 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
508 | + spacewire_stats.write_sync_err; |
|
508 | + spacewire_stats.write_sync_err; | |
509 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
509 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
510 | + spacewire_stats.rx_rmap_header_crc_err; |
|
510 | + spacewire_stats.rx_rmap_header_crc_err; | |
511 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
511 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
512 | + spacewire_stats.rx_rmap_data_crc_err; |
|
512 | + spacewire_stats.rx_rmap_data_crc_err; | |
513 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
513 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
514 | + spacewire_stats.early_ep; |
|
514 | + spacewire_stats.early_ep; | |
515 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
515 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
516 | + spacewire_stats.invalid_address; |
|
516 | + spacewire_stats.invalid_address; | |
517 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
517 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
518 | + spacewire_stats.rx_eep_err; |
|
518 | + spacewire_stats.rx_eep_err; | |
519 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
519 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
520 | + spacewire_stats.rx_truncated; |
|
520 | + spacewire_stats.rx_truncated; | |
521 | } |
|
521 | } | |
522 |
|
522 | |||
523 | void spacewire_update_statistics( void ) |
|
523 | void spacewire_update_statistics( void ) | |
524 | { |
|
524 | { | |
525 | rtems_status_code status; |
|
525 | rtems_status_code status; | |
526 | spw_stats spacewire_stats_grspw; |
|
526 | spw_stats spacewire_stats_grspw; | |
527 |
|
527 | |||
528 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
528 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
529 |
|
529 | |||
530 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
530 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
531 | + spacewire_stats_grspw.packets_received; |
|
531 | + spacewire_stats_grspw.packets_received; | |
532 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
532 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
533 | + spacewire_stats_grspw.packets_sent; |
|
533 | + spacewire_stats_grspw.packets_sent; | |
534 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
534 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
535 | + spacewire_stats_grspw.parity_err; |
|
535 | + spacewire_stats_grspw.parity_err; | |
536 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
536 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
537 | + spacewire_stats_grspw.disconnect_err; |
|
537 | + spacewire_stats_grspw.disconnect_err; | |
538 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
538 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
539 | + spacewire_stats_grspw.escape_err; |
|
539 | + spacewire_stats_grspw.escape_err; | |
540 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
540 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
541 | + spacewire_stats_grspw.credit_err; |
|
541 | + spacewire_stats_grspw.credit_err; | |
542 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
542 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
543 | + spacewire_stats_grspw.write_sync_err; |
|
543 | + spacewire_stats_grspw.write_sync_err; | |
544 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
544 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
545 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
545 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
546 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
546 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
547 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
547 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
548 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
548 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
549 | + spacewire_stats_grspw.early_ep; |
|
549 | + spacewire_stats_grspw.early_ep; | |
550 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
550 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
551 | + spacewire_stats_grspw.invalid_address; |
|
551 | + spacewire_stats_grspw.invalid_address; | |
552 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
552 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
553 | + spacewire_stats_grspw.rx_eep_err; |
|
553 | + spacewire_stats_grspw.rx_eep_err; | |
554 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
554 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
555 | + spacewire_stats_grspw.rx_truncated; |
|
555 | + spacewire_stats_grspw.rx_truncated; | |
556 | //spacewire_stats.tx_link_err; |
|
556 | //spacewire_stats.tx_link_err; | |
557 |
|
557 | |||
558 | //**************************** |
|
558 | //**************************** | |
559 | // DPU_SPACEWIRE_IF_STATISTICS |
|
559 | // DPU_SPACEWIRE_IF_STATISTICS | |
560 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
560 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
561 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
561 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
562 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
562 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
563 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
563 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
564 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
564 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
565 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
565 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
566 |
|
566 | |||
567 | //****************************************** |
|
567 | //****************************************** | |
568 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
568 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
569 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
569 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
570 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
570 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
571 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
571 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
572 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
572 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
573 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
573 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
574 |
|
574 | |||
575 | //********************************************* |
|
575 | //********************************************* | |
576 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
576 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
577 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
577 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
578 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
578 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
579 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
579 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
580 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
580 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
581 | } |
|
581 | } | |
582 |
|
582 | |||
583 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
583 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
584 | { |
|
584 | { | |
585 | //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) { |
|
585 | //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) { | |
586 | // printf("In timecode_irq_handler *** Error sending event to DUMB\n"); |
|
586 | // printf("In timecode_irq_handler *** Error sending event to DUMB\n"); | |
587 | //} |
|
587 | //} | |
588 | } |
|
588 | } | |
589 |
|
589 | |||
590 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
590 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) | |
591 | { |
|
591 | { | |
592 | int linkStatus; |
|
592 | int linkStatus; | |
593 | rtems_status_code status; |
|
593 | rtems_status_code status; | |
594 |
|
594 | |||
595 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
595 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
596 |
|
596 | |||
597 | if ( linkStatus == 5) { |
|
597 | if ( linkStatus == 5) { | |
598 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
598 | PRINTF("in spacewire_reset_link *** link is running\n") | |
599 | status = RTEMS_SUCCESSFUL; |
|
599 | status = RTEMS_SUCCESSFUL; | |
600 | } |
|
600 | } | |
601 | } |
|
601 | } |
@@ -1,837 +1,748 | |||||
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 | //*********** |
|
15 | //*********** | |
16 | // RTEMS TASK |
|
16 | // RTEMS TASK | |
17 |
|
17 | |||
18 | rtems_task actn_task( rtems_task_argument unused ) |
|
18 | rtems_task actn_task( rtems_task_argument unused ) | |
19 | { |
|
19 | { | |
20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
21 | * |
|
21 | * | |
22 | * @param unused is the starting argument of the RTEMS task |
|
22 | * @param unused is the starting argument of the RTEMS task | |
23 | * |
|
23 | * | |
24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
25 | * on the incoming TeleCommand. |
|
25 | * on the incoming TeleCommand. | |
26 | * |
|
26 | * | |
27 | */ |
|
27 | */ | |
28 |
|
28 | |||
29 | int result; |
|
29 | int result; | |
30 | rtems_status_code status; // RTEMS status code |
|
30 | rtems_status_code status; // RTEMS status code | |
31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | |
32 | size_t size; // size of the incoming TC packet |
|
32 | size_t size; // size of the incoming TC packet | |
33 | unsigned char subtype; // subtype of the current TC packet |
|
33 | unsigned char subtype; // subtype of the current TC packet | |
34 | unsigned char time[6]; |
|
34 | unsigned char time[6]; | |
35 | rtems_id queue_rcv_id; |
|
35 | rtems_id queue_rcv_id; | |
36 | rtems_id queue_snd_id; |
|
36 | rtems_id queue_snd_id; | |
37 |
|
37 | |||
38 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
38 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
39 | if (status != RTEMS_SUCCESSFUL) |
|
39 | if (status != RTEMS_SUCCESSFUL) | |
40 | { |
|
40 | { | |
41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | status = get_message_queue_id_send( &queue_snd_id ); |
|
44 | status = get_message_queue_id_send( &queue_snd_id ); | |
45 | if (status != RTEMS_SUCCESSFUL) |
|
45 | if (status != RTEMS_SUCCESSFUL) | |
46 | { |
|
46 | { | |
47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | result = LFR_SUCCESSFUL; |
|
50 | result = LFR_SUCCESSFUL; | |
51 | subtype = 0; // subtype of the current TC packet |
|
51 | subtype = 0; // subtype of the current TC packet | |
52 |
|
52 | |||
53 | BOOT_PRINTF("in ACTN *** \n") |
|
53 | BOOT_PRINTF("in ACTN *** \n") | |
54 |
|
54 | |||
55 | while(1) |
|
55 | while(1) | |
56 | { |
|
56 | { | |
57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
59 | getTime( time ); // set time to the current time |
|
59 | getTime( time ); // set time to the current time | |
60 | if (status!=RTEMS_SUCCESSFUL) |
|
60 | if (status!=RTEMS_SUCCESSFUL) | |
61 | { |
|
61 | { | |
62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
63 | } |
|
63 | } | |
64 | else |
|
64 | else | |
65 | { |
|
65 | { | |
66 | subtype = TC.serviceSubType; |
|
66 | subtype = TC.serviceSubType; | |
67 | switch(subtype) |
|
67 | switch(subtype) | |
68 | { |
|
68 | { | |
69 | case TC_SUBTYPE_RESET: |
|
69 | case TC_SUBTYPE_RESET: | |
70 | result = action_reset( &TC, queue_snd_id, time ); |
|
70 | result = action_reset( &TC, queue_snd_id, time ); | |
71 | close_action( &TC, result, queue_snd_id, time ); |
|
71 | close_action( &TC, result, queue_snd_id, time ); | |
72 | break; |
|
72 | break; | |
73 | // |
|
73 | // | |
74 | case TC_SUBTYPE_LOAD_COMM: |
|
74 | case TC_SUBTYPE_LOAD_COMM: | |
75 | result = action_load_common_par( &TC ); |
|
75 | result = action_load_common_par( &TC ); | |
76 | close_action( &TC, result, queue_snd_id, time ); |
|
76 | close_action( &TC, result, queue_snd_id, time ); | |
77 | break; |
|
77 | break; | |
78 | // |
|
78 | // | |
79 | case TC_SUBTYPE_LOAD_NORM: |
|
79 | case TC_SUBTYPE_LOAD_NORM: | |
80 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
80 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
81 | close_action( &TC, result, queue_snd_id, time ); |
|
81 | close_action( &TC, result, queue_snd_id, time ); | |
82 | break; |
|
82 | break; | |
83 | // |
|
83 | // | |
84 | case TC_SUBTYPE_LOAD_BURST: |
|
84 | case TC_SUBTYPE_LOAD_BURST: | |
85 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
85 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
86 | close_action( &TC, result, queue_snd_id, time ); |
|
86 | close_action( &TC, result, queue_snd_id, time ); | |
87 | break; |
|
87 | break; | |
88 | // |
|
88 | // | |
89 | case TC_SUBTYPE_LOAD_SBM1: |
|
89 | case TC_SUBTYPE_LOAD_SBM1: | |
90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
91 | close_action( &TC, result, queue_snd_id, time ); |
|
91 | close_action( &TC, result, queue_snd_id, time ); | |
92 | break; |
|
92 | break; | |
93 | // |
|
93 | // | |
94 | case TC_SUBTYPE_LOAD_SBM2: |
|
94 | case TC_SUBTYPE_LOAD_SBM2: | |
95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
96 | close_action( &TC, result, queue_snd_id, time ); |
|
96 | close_action( &TC, result, queue_snd_id, time ); | |
97 | break; |
|
97 | break; | |
98 | // |
|
98 | // | |
99 | case TC_SUBTYPE_DUMP: |
|
99 | case TC_SUBTYPE_DUMP: | |
100 | result = action_dump_par( queue_snd_id ); |
|
100 | result = action_dump_par( queue_snd_id ); | |
101 | close_action( &TC, result, queue_snd_id, time ); |
|
101 | close_action( &TC, result, queue_snd_id, time ); | |
102 | break; |
|
102 | break; | |
103 | // |
|
103 | // | |
104 | case TC_SUBTYPE_ENTER: |
|
104 | case TC_SUBTYPE_ENTER: | |
105 | result = action_enter_mode( &TC, queue_snd_id, time ); |
|
105 | result = action_enter_mode( &TC, queue_snd_id, time ); | |
106 | close_action( &TC, result, queue_snd_id, time ); |
|
106 | close_action( &TC, result, queue_snd_id, time ); | |
107 | break; |
|
107 | break; | |
108 | // |
|
108 | // | |
109 | case TC_SUBTYPE_UPDT_INFO: |
|
109 | case TC_SUBTYPE_UPDT_INFO: | |
110 | result = action_update_info( &TC, queue_snd_id ); |
|
110 | result = action_update_info( &TC, queue_snd_id ); | |
111 | close_action( &TC, result, queue_snd_id, time ); |
|
111 | close_action( &TC, result, queue_snd_id, time ); | |
112 | break; |
|
112 | break; | |
113 | // |
|
113 | // | |
114 | case TC_SUBTYPE_EN_CAL: |
|
114 | case TC_SUBTYPE_EN_CAL: | |
115 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
115 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id, time ); |
|
116 | close_action( &TC, result, queue_snd_id, time ); | |
117 | break; |
|
117 | break; | |
118 | // |
|
118 | // | |
119 | case TC_SUBTYPE_DIS_CAL: |
|
119 | case TC_SUBTYPE_DIS_CAL: | |
120 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
120 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
121 | close_action( &TC, result, queue_snd_id, time ); |
|
121 | close_action( &TC, result, queue_snd_id, time ); | |
122 | break; |
|
122 | break; | |
123 | // |
|
123 | // | |
124 | case TC_SUBTYPE_UPDT_TIME: |
|
124 | case TC_SUBTYPE_UPDT_TIME: | |
125 | result = action_update_time( &TC ); |
|
125 | result = action_update_time( &TC ); | |
126 | close_action( &TC, result, queue_snd_id, time ); |
|
126 | close_action( &TC, result, queue_snd_id, time ); | |
127 | break; |
|
127 | break; | |
128 | // |
|
128 | // | |
129 | default: |
|
129 | default: | |
130 | break; |
|
130 | break; | |
131 | } |
|
131 | } | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | //*********** |
|
136 | //*********** | |
137 | // TC ACTIONS |
|
137 | // TC ACTIONS | |
138 |
|
138 | |||
139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
140 | { |
|
140 | { | |
141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
142 | * |
|
142 | * | |
143 | * @param TC points to the TeleCommand packet that is being processed |
|
143 | * @param TC points to the TeleCommand packet that is being processed | |
144 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
144 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
145 | * |
|
145 | * | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
149 | return LFR_DEFAULT; |
|
149 | return LFR_DEFAULT; | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
153 | { |
|
153 | { | |
154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
155 | * |
|
155 | * | |
156 | * @param TC points to the TeleCommand packet that is being processed |
|
156 | * @param TC points to the TeleCommand packet that is being processed | |
157 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
157 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
158 | * |
|
158 | * | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | rtems_status_code status; |
|
161 | rtems_status_code status; | |
162 | unsigned char requestedMode; |
|
162 | unsigned char requestedMode; | |
163 |
|
163 | |||
164 | requestedMode = TC->dataAndCRC[1]; |
|
164 | requestedMode = TC->dataAndCRC[1]; | |
165 |
|
165 | |||
166 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
166 | if ( (requestedMode != LFR_MODE_STANDBY) | |
167 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
167 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
168 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
168 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
169 | { |
|
169 | { | |
170 | status = RTEMS_UNSATISFIED; |
|
170 | status = RTEMS_UNSATISFIED; | |
171 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time ); |
|
171 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time ); | |
172 | } |
|
172 | } | |
173 | else |
|
173 | else | |
174 | { |
|
174 | { | |
175 | printf("in action_enter_mode *** enter mode %d\n", requestedMode); |
|
175 | printf("in action_enter_mode *** enter mode %d\n", requestedMode); | |
176 |
|
176 | |||
177 | #ifdef PRINT_TASK_STATISTICS |
|
177 | #ifdef PRINT_TASK_STATISTICS | |
178 | if (requestedMode != LFR_MODE_STANDBY) |
|
178 | if (requestedMode != LFR_MODE_STANDBY) | |
179 | { |
|
179 | { | |
180 | rtems_cpu_usage_reset(); |
|
180 | rtems_cpu_usage_reset(); | |
181 | maxCount = 0; |
|
181 | maxCount = 0; | |
182 | } |
|
182 | } | |
183 | #endif |
|
183 | #endif | |
184 |
|
184 | |||
185 | status = transition_validation(requestedMode); |
|
185 | status = transition_validation(requestedMode); | |
186 |
|
186 | |||
187 | if ( status == LFR_SUCCESSFUL ) { |
|
187 | if ( status == LFR_SUCCESSFUL ) { | |
188 | if ( lfrCurrentMode != LFR_MODE_STANDBY) |
|
188 | if ( lfrCurrentMode != LFR_MODE_STANDBY) | |
189 | { |
|
189 | { | |
190 | status = stop_current_mode(); |
|
190 | status = stop_current_mode(); | |
191 | } |
|
191 | } | |
192 | if (status != RTEMS_SUCCESSFUL) |
|
192 | if (status != RTEMS_SUCCESSFUL) | |
193 | { |
|
193 | { | |
194 | PRINTF("ERR *** in action_enter *** stop_current_mode\n") |
|
194 | PRINTF("ERR *** in action_enter *** stop_current_mode\n") | |
195 | } |
|
195 | } | |
196 | status = enter_mode( requestedMode ); |
|
196 | status = enter_mode( requestedMode ); | |
197 | } |
|
197 | } | |
198 | else |
|
198 | else | |
199 | { |
|
199 | { | |
200 | PRINTF("ERR *** in action_enter *** transition rejected\n") |
|
200 | PRINTF("ERR *** in action_enter *** transition rejected\n") | |
201 | send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
201 | send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
202 | } |
|
202 | } | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | return status; |
|
205 | return status; | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
208 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
209 | { |
|
209 | { | |
210 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
210 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
211 | * |
|
211 | * | |
212 | * @param TC points to the TeleCommand packet that is being processed |
|
212 | * @param TC points to the TeleCommand packet that is being processed | |
213 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
213 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
214 | * |
|
214 | * | |
215 | * @return LFR directive status code: |
|
215 | * @return LFR directive status code: | |
216 | * - LFR_DEFAULT |
|
216 | * - LFR_DEFAULT | |
217 | * - LFR_SUCCESSFUL |
|
217 | * - LFR_SUCCESSFUL | |
218 | * |
|
218 | * | |
219 | */ |
|
219 | */ | |
220 |
|
220 | |||
221 | unsigned int val; |
|
221 | unsigned int val; | |
222 | int result; |
|
222 | int result; | |
223 |
|
223 | |||
224 | result = LFR_SUCCESSFUL; |
|
224 | result = LFR_SUCCESSFUL; | |
225 |
|
225 | |||
226 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
226 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
227 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
227 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
228 | val++; |
|
228 | val++; | |
229 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
229 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
230 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
230 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
231 |
|
231 | |||
232 | return result; |
|
232 | return result; | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
235 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
236 | { |
|
236 | { | |
237 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
237 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
238 | * |
|
238 | * | |
239 | * @param TC points to the TeleCommand packet that is being processed |
|
239 | * @param TC points to the TeleCommand packet that is being processed | |
240 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
240 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
241 | * |
|
241 | * | |
242 | */ |
|
242 | */ | |
243 |
|
243 | |||
244 | int result; |
|
244 | int result; | |
245 | unsigned char lfrMode; |
|
245 | unsigned char lfrMode; | |
246 |
|
246 | |||
247 | result = LFR_DEFAULT; |
|
247 | result = LFR_DEFAULT; | |
248 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
248 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
249 |
|
249 | |||
250 | if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) { |
|
250 | if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) { | |
251 | send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
251 | send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
252 | result = LFR_DEFAULT; |
|
252 | result = LFR_DEFAULT; | |
253 | } |
|
253 | } | |
254 | else { |
|
254 | else { | |
255 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
255 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
256 | result = LFR_DEFAULT; |
|
256 | result = LFR_DEFAULT; | |
257 | } |
|
257 | } | |
258 | return result; |
|
258 | return result; | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
261 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
262 | { |
|
262 | { | |
263 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
263 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
264 | * |
|
264 | * | |
265 | * @param TC points to the TeleCommand packet that is being processed |
|
265 | * @param TC points to the TeleCommand packet that is being processed | |
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
267 | * |
|
267 | * | |
268 | */ |
|
268 | */ | |
269 |
|
269 | |||
270 | int result; |
|
270 | int result; | |
271 | unsigned char lfrMode; |
|
271 | unsigned char lfrMode; | |
272 |
|
272 | |||
273 | result = LFR_DEFAULT; |
|
273 | result = LFR_DEFAULT; | |
274 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
274 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
275 |
|
275 | |||
276 | if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) { |
|
276 | if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) { | |
277 | send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
277 | send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
278 | result = LFR_DEFAULT; |
|
278 | result = LFR_DEFAULT; | |
279 | } |
|
279 | } | |
280 | else { |
|
280 | else { | |
281 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
281 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
282 | result = LFR_DEFAULT; |
|
282 | result = LFR_DEFAULT; | |
283 | } |
|
283 | } | |
284 | return result; |
|
284 | return result; | |
285 | } |
|
285 | } | |
286 |
|
286 | |||
287 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
287 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
288 | { |
|
288 | { | |
289 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
289 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
290 | * |
|
290 | * | |
291 | * @param TC points to the TeleCommand packet that is being processed |
|
291 | * @param TC points to the TeleCommand packet that is being processed | |
292 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
292 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
293 | * |
|
293 | * | |
294 | * @return LFR_SUCCESSFUL |
|
294 | * @return LFR_SUCCESSFUL | |
295 | * |
|
295 | * | |
296 | */ |
|
296 | */ | |
297 |
|
297 | |||
298 | unsigned int val; |
|
298 | unsigned int val; | |
299 |
|
299 | |||
300 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
300 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
301 | + (TC->dataAndCRC[1] << 16) |
|
301 | + (TC->dataAndCRC[1] << 16) | |
302 | + (TC->dataAndCRC[2] << 8) |
|
302 | + (TC->dataAndCRC[2] << 8) | |
303 | + TC->dataAndCRC[3]; |
|
303 | + TC->dataAndCRC[3]; | |
304 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
304 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
305 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
305 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
306 | val++; |
|
306 | val++; | |
307 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
307 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
308 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
308 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
309 | time_management_regs->ctrl = time_management_regs->ctrl | 1; |
|
309 | time_management_regs->ctrl = time_management_regs->ctrl | 1; | |
310 |
|
310 | |||
311 | return LFR_SUCCESSFUL; |
|
311 | return LFR_SUCCESSFUL; | |
312 | } |
|
312 | } | |
313 |
|
313 | |||
314 | //******************* |
|
314 | //******************* | |
315 | // ENTERING THE MODES |
|
315 | // ENTERING THE MODES | |
316 |
|
316 | |||
317 | int transition_validation(unsigned char requestedMode) |
|
317 | int transition_validation(unsigned char requestedMode) | |
318 | { |
|
318 | { | |
319 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
319 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
320 | * |
|
320 | * | |
321 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
321 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
322 | * |
|
322 | * | |
323 | * @return LFR directive status codes: |
|
323 | * @return LFR directive status codes: | |
324 | * - LFR_SUCCESSFUL - the transition is authorized |
|
324 | * - LFR_SUCCESSFUL - the transition is authorized | |
325 | * - LFR_DEFAULT - the transition is not authorized |
|
325 | * - LFR_DEFAULT - the transition is not authorized | |
326 | * |
|
326 | * | |
327 | */ |
|
327 | */ | |
328 |
|
328 | |||
329 | int status; |
|
329 | int status; | |
330 |
|
330 | |||
331 | switch (requestedMode) |
|
331 | switch (requestedMode) | |
332 | { |
|
332 | { | |
333 | case LFR_MODE_STANDBY: |
|
333 | case LFR_MODE_STANDBY: | |
334 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
334 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
335 | status = LFR_DEFAULT; |
|
335 | status = LFR_DEFAULT; | |
336 | } |
|
336 | } | |
337 | else |
|
337 | else | |
338 | { |
|
338 | { | |
339 | status = LFR_SUCCESSFUL; |
|
339 | status = LFR_SUCCESSFUL; | |
340 | } |
|
340 | } | |
341 | break; |
|
341 | break; | |
342 | case LFR_MODE_NORMAL: |
|
342 | case LFR_MODE_NORMAL: | |
343 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
343 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
344 | status = LFR_DEFAULT; |
|
344 | status = LFR_DEFAULT; | |
345 | } |
|
345 | } | |
346 | else { |
|
346 | else { | |
347 | status = LFR_SUCCESSFUL; |
|
347 | status = LFR_SUCCESSFUL; | |
348 | } |
|
348 | } | |
349 | break; |
|
349 | break; | |
350 | case LFR_MODE_BURST: |
|
350 | case LFR_MODE_BURST: | |
351 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
351 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
352 | status = LFR_DEFAULT; |
|
352 | status = LFR_DEFAULT; | |
353 | } |
|
353 | } | |
354 | else { |
|
354 | else { | |
355 | status = LFR_SUCCESSFUL; |
|
355 | status = LFR_SUCCESSFUL; | |
356 | } |
|
356 | } | |
357 | break; |
|
357 | break; | |
358 | case LFR_MODE_SBM1: |
|
358 | case LFR_MODE_SBM1: | |
359 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
359 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
360 | status = LFR_DEFAULT; |
|
360 | status = LFR_DEFAULT; | |
361 | } |
|
361 | } | |
362 | else { |
|
362 | else { | |
363 | status = LFR_SUCCESSFUL; |
|
363 | status = LFR_SUCCESSFUL; | |
364 | } |
|
364 | } | |
365 | break; |
|
365 | break; | |
366 | case LFR_MODE_SBM2: |
|
366 | case LFR_MODE_SBM2: | |
367 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
367 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
368 | status = LFR_DEFAULT; |
|
368 | status = LFR_DEFAULT; | |
369 | } |
|
369 | } | |
370 | else { |
|
370 | else { | |
371 | status = LFR_SUCCESSFUL; |
|
371 | status = LFR_SUCCESSFUL; | |
372 | } |
|
372 | } | |
373 | break; |
|
373 | break; | |
374 | default: |
|
374 | default: | |
375 | status = LFR_DEFAULT; |
|
375 | status = LFR_DEFAULT; | |
376 | break; |
|
376 | break; | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | return status; |
|
379 | return status; | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 | int stop_current_mode() |
|
382 | int stop_current_mode(void) | |
383 | { |
|
383 | { | |
384 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
384 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
385 | * |
|
385 | * | |
386 | * @return RTEMS directive status codes: |
|
386 | * @return RTEMS directive status codes: | |
387 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
387 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
388 | * - RTEMS_INVALID_ID - task id invalid |
|
388 | * - RTEMS_INVALID_ID - task id invalid | |
389 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
389 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
390 | * |
|
390 | * | |
391 | */ |
|
391 | */ | |
392 |
|
392 | |||
393 | rtems_status_code status; |
|
393 | rtems_status_code status; | |
394 |
|
394 | |||
395 | status = RTEMS_SUCCESSFUL; |
|
395 | status = RTEMS_SUCCESSFUL; | |
396 |
|
396 | |||
397 | // mask interruptions |
|
397 | // mask interruptions | |
398 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
398 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
399 | //LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
399 | //LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
400 | LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrix interrupt simulator |
|
400 | LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrix interrupt simulator | |
401 | // reset registers |
|
401 | // reset registers | |
402 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
402 | reset_wfp_burst_enable(); // reset burst and enable bits | |
403 | reset_wfp_status(); // reset all the status bits |
|
403 | reset_wfp_status(); // reset all the status bits | |
404 | // clear interruptions |
|
404 | // clear interruptions | |
405 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
405 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
406 | //LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
406 | //LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
407 | LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrix interrupt simulator |
|
407 | LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrix interrupt simulator | |
408 | //********************** |
|
408 | //********************** | |
409 | // suspend several tasks |
|
409 | // suspend several tasks | |
410 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
410 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
411 | status = suspend_science_tasks(); |
|
411 | status = suspend_science_tasks(); | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | if (status != RTEMS_SUCCESSFUL) |
|
414 | if (status != RTEMS_SUCCESSFUL) | |
415 | { |
|
415 | { | |
416 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
416 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
417 | } |
|
417 | } | |
418 |
|
418 | |||
419 | return status; |
|
419 | return status; | |
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 | int enter_mode(unsigned char mode ) |
|
422 | int enter_mode(unsigned char mode ) | |
423 | { |
|
423 | { | |
424 | /** This function is launched after a mode transition validation. |
|
424 | /** This function is launched after a mode transition validation. | |
425 | * |
|
425 | * | |
426 | * @param mode is the mode in which LFR will be put. |
|
426 | * @param mode is the mode in which LFR will be put. | |
427 | * |
|
427 | * | |
428 | * @return RTEMS directive status codes: |
|
428 | * @return RTEMS directive status codes: | |
429 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
429 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully | |
430 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
430 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully | |
431 | * |
|
431 | * | |
432 | */ |
|
432 | */ | |
433 |
|
433 | |||
434 | rtems_status_code status; |
|
434 | rtems_status_code status; | |
435 |
|
435 | |||
436 | status = RTEMS_UNSATISFIED; |
|
436 | status = RTEMS_UNSATISFIED; | |
437 |
|
437 | |||
438 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); |
|
438 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); | |
439 | updateLFRCurrentMode(); |
|
439 | updateLFRCurrentMode(); | |
440 |
|
440 | |||
441 | switch(mode){ |
|
441 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) | |
442 | case LFR_MODE_STANDBY: |
|
442 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) | |
443 | status = enter_standby_mode( ); |
|
443 | { | |
444 | break; |
|
444 | status = restart_science_tasks(); | |
445 | case LFR_MODE_NORMAL: |
|
445 | launch_waveform_picker( mode ); | |
446 | status = enter_normal_mode( ); |
|
446 | // launch_spectral_matrix( mode ); | |
447 | break; |
|
447 | } | |
448 | case LFR_MODE_BURST: |
|
448 | else if ( mode == LFR_MODE_STANDBY ) | |
449 | status = enter_burst_mode( ); |
|
449 | { | |
450 | break; |
|
450 | status = stop_current_mode(); | |
451 | case LFR_MODE_SBM1: |
|
451 | } | |
452 | status = enter_sbm1_mode( ); |
|
452 | else | |
453 | break; |
|
453 | { | |
454 | case LFR_MODE_SBM2: |
|
|||
455 | status = enter_sbm2_mode( ); |
|
|||
456 | break; |
|
|||
457 | default: |
|
|||
458 | status = RTEMS_UNSATISFIED; |
|
454 | status = RTEMS_UNSATISFIED; | |
459 | } |
|
455 | } | |
460 |
|
456 | |||
|
457 | if (mode == LFR_MODE_STANDBY) | |||
|
458 | { | |||
|
459 | PRINTF1("maxCount = %d\n", maxCount) | |||
|
460 | #ifdef PRINT_TASK_STATISTICS | |||
|
461 | rtems_cpu_usage_report(); | |||
|
462 | #endif | |||
|
463 | ||||
|
464 | #ifdef PRINT_STACK_REPORT | |||
|
465 | rtems_stack_checker_report_usage(); | |||
|
466 | #endif | |||
|
467 | } | |||
|
468 | ||||
461 | if (status != RTEMS_SUCCESSFUL) |
|
469 | if (status != RTEMS_SUCCESSFUL) | |
462 | { |
|
470 | { | |
463 | PRINTF("in enter_mode *** ERR\n") |
|
471 | PRINTF1("in enter_mode *** ERR = %d\n", status) | |
464 | status = RTEMS_UNSATISFIED; |
|
472 | status = RTEMS_UNSATISFIED; | |
465 | } |
|
473 | } | |
466 |
|
474 | |||
467 | return status; |
|
475 | return status; | |
468 | } |
|
476 | } | |
469 |
|
477 | |||
470 | int enter_standby_mode() |
|
|||
471 | { |
|
|||
472 | /** This function is used to enter the STANDBY mode. |
|
|||
473 | * |
|
|||
474 | * @return RTEMS directive status codes: |
|
|||
475 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
|||
476 | * |
|
|||
477 | */ |
|
|||
478 |
|
||||
479 | PRINTF1("maxCount = %d\n", maxCount) |
|
|||
480 |
|
||||
481 | #ifdef PRINT_TASK_STATISTICS |
|
|||
482 | rtems_cpu_usage_report(); |
|
|||
483 | #endif |
|
|||
484 |
|
||||
485 | #ifdef PRINT_STACK_REPORT |
|
|||
486 | rtems_stack_checker_report_usage(); |
|
|||
487 | #endif |
|
|||
488 |
|
||||
489 | return LFR_SUCCESSFUL; |
|
|||
490 | } |
|
|||
491 |
|
||||
492 | int enter_normal_mode() |
|
|||
493 | { |
|
|||
494 | rtems_status_code status; |
|
|||
495 |
|
||||
496 | status = restart_science_tasks(); |
|
|||
497 |
|
||||
498 | launch_waveform_picker( LFR_MODE_NORMAL ); |
|
|||
499 | // launch_spectral_matrix( LFR_MODE_NORMAL ); |
|
|||
500 |
|
||||
501 | return status; |
|
|||
502 | } |
|
|||
503 |
|
||||
504 | int enter_burst_mode() |
|
|||
505 | { |
|
|||
506 | /** This function is used to enter the STANDBY mode. |
|
|||
507 | * |
|
|||
508 | * @return RTEMS directive status codes: |
|
|||
509 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
|||
510 | * - RTEMS_INVALID_ID - task id invalid |
|
|||
511 | * - RTEMS_INCORRECT_STATE - task never started |
|
|||
512 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
|||
513 | * |
|
|||
514 | */ |
|
|||
515 |
|
||||
516 | rtems_status_code status; |
|
|||
517 |
|
||||
518 | status = restart_science_tasks(); |
|
|||
519 |
|
||||
520 | launch_waveform_picker( LFR_MODE_BURST ); |
|
|||
521 |
|
||||
522 | return status; |
|
|||
523 | } |
|
|||
524 |
|
||||
525 | int enter_sbm1_mode() |
|
|||
526 | { |
|
|||
527 | /** This function is used to enter the SBM1 mode. |
|
|||
528 | * |
|
|||
529 | * @return RTEMS directive status codes: |
|
|||
530 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
|||
531 | * - RTEMS_INVALID_ID - task id invalid |
|
|||
532 | * - RTEMS_INCORRECT_STATE - task never started |
|
|||
533 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
|||
534 | * |
|
|||
535 | */ |
|
|||
536 |
|
||||
537 | rtems_status_code status; |
|
|||
538 |
|
||||
539 | status = restart_science_tasks(); |
|
|||
540 |
|
||||
541 | launch_waveform_picker( LFR_MODE_SBM1 ); |
|
|||
542 |
|
||||
543 | return status; |
|
|||
544 | } |
|
|||
545 |
|
||||
546 | int enter_sbm2_mode() |
|
|||
547 | { |
|
|||
548 | /** This function is used to enter the SBM2 mode. |
|
|||
549 | * |
|
|||
550 | * @return RTEMS directive status codes: |
|
|||
551 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
|||
552 | * - RTEMS_INVALID_ID - task id invalid |
|
|||
553 | * - RTEMS_INCORRECT_STATE - task never started |
|
|||
554 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
|||
555 | * |
|
|||
556 | */ |
|
|||
557 |
|
||||
558 | rtems_status_code status; |
|
|||
559 |
|
||||
560 | status = restart_science_tasks(); |
|
|||
561 |
|
||||
562 | launch_waveform_picker( LFR_MODE_SBM2 ); |
|
|||
563 |
|
||||
564 | return status; |
|
|||
565 | } |
|
|||
566 |
|
||||
567 | int restart_science_tasks() |
|
478 | int restart_science_tasks() | |
568 | { |
|
479 | { | |
569 | /** This function is used to restart all science tasks. |
|
480 | /** This function is used to restart all science tasks. | |
570 | * |
|
481 | * | |
571 | * @return RTEMS directive status codes: |
|
482 | * @return RTEMS directive status codes: | |
572 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
483 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
573 | * - RTEMS_INVALID_ID - task id invalid |
|
484 | * - RTEMS_INVALID_ID - task id invalid | |
574 | * - RTEMS_INCORRECT_STATE - task never started |
|
485 | * - RTEMS_INCORRECT_STATE - task never started | |
575 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
486 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
576 | * |
|
487 | * | |
577 | * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1 |
|
488 | * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1 | |
578 | * |
|
489 | * | |
579 | */ |
|
490 | */ | |
580 |
|
491 | |||
581 | rtems_status_code status[6]; |
|
492 | rtems_status_code status[6]; | |
582 | rtems_status_code ret; |
|
493 | rtems_status_code ret; | |
583 |
|
494 | |||
584 | ret = RTEMS_SUCCESSFUL; |
|
495 | ret = RTEMS_SUCCESSFUL; | |
585 |
|
496 | |||
586 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); |
|
497 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); | |
587 | if (status[0] != RTEMS_SUCCESSFUL) |
|
498 | if (status[0] != RTEMS_SUCCESSFUL) | |
588 | { |
|
499 | { | |
589 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) |
|
500 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) | |
590 | } |
|
501 | } | |
591 |
|
502 | |||
592 | status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 ); |
|
503 | status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 ); | |
593 | if (status[1] != RTEMS_SUCCESSFUL) |
|
504 | if (status[1] != RTEMS_SUCCESSFUL) | |
594 | { |
|
505 | { | |
595 | PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1]) |
|
506 | PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1]) | |
596 | } |
|
507 | } | |
597 |
|
508 | |||
598 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
509 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
599 | if (status[2] != RTEMS_SUCCESSFUL) |
|
510 | if (status[2] != RTEMS_SUCCESSFUL) | |
600 | { |
|
511 | { | |
601 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) |
|
512 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) | |
602 | } |
|
513 | } | |
603 |
|
514 | |||
604 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
515 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
605 | if (status[3] != RTEMS_SUCCESSFUL) |
|
516 | if (status[3] != RTEMS_SUCCESSFUL) | |
606 | { |
|
517 | { | |
607 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) |
|
518 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) | |
608 | } |
|
519 | } | |
609 |
|
520 | |||
610 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
521 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
611 | if (status[4] != RTEMS_SUCCESSFUL) |
|
522 | if (status[4] != RTEMS_SUCCESSFUL) | |
612 | { |
|
523 | { | |
613 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) |
|
524 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) | |
614 | } |
|
525 | } | |
615 |
|
526 | |||
616 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
527 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
617 | if (status[5] != RTEMS_SUCCESSFUL) |
|
528 | if (status[5] != RTEMS_SUCCESSFUL) | |
618 | { |
|
529 | { | |
619 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) |
|
530 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) | |
620 | } |
|
531 | } | |
621 |
|
532 | |||
622 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || |
|
533 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || | |
623 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
534 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
624 | { |
|
535 | { | |
625 | ret = RTEMS_UNSATISFIED; |
|
536 | ret = RTEMS_UNSATISFIED; | |
626 | } |
|
537 | } | |
627 |
|
538 | |||
628 | return ret; |
|
539 | return ret; | |
629 | } |
|
540 | } | |
630 |
|
541 | |||
631 | int suspend_science_tasks() |
|
542 | int suspend_science_tasks() | |
632 | { |
|
543 | { | |
633 | /** This function suspends the science tasks. |
|
544 | /** This function suspends the science tasks. | |
634 | * |
|
545 | * | |
635 | * @return RTEMS directive status codes: |
|
546 | * @return RTEMS directive status codes: | |
636 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
547 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
637 | * - RTEMS_INVALID_ID - task id invalid |
|
548 | * - RTEMS_INVALID_ID - task id invalid | |
638 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
549 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
639 | * |
|
550 | * | |
640 | */ |
|
551 | */ | |
641 |
|
552 | |||
642 | rtems_status_code status; |
|
553 | rtems_status_code status; | |
643 |
|
554 | |||
644 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); |
|
555 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); | |
645 | if (status != RTEMS_SUCCESSFUL) |
|
556 | if (status != RTEMS_SUCCESSFUL) | |
646 | { |
|
557 | { | |
647 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
558 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
648 | } |
|
559 | } | |
649 |
|
560 | |||
650 | if (status == RTEMS_SUCCESSFUL) // suspend BPF0 |
|
561 | if (status == RTEMS_SUCCESSFUL) // suspend BPF0 | |
651 | { |
|
562 | { | |
652 | status = rtems_task_suspend( Task_id[TASKID_BPF0] ); |
|
563 | status = rtems_task_suspend( Task_id[TASKID_BPF0] ); | |
653 | if (status != RTEMS_SUCCESSFUL) |
|
564 | if (status != RTEMS_SUCCESSFUL) | |
654 | { |
|
565 | { | |
655 | PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status) |
|
566 | PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status) | |
656 | } |
|
567 | } | |
657 | } |
|
568 | } | |
658 |
|
569 | |||
659 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
570 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
660 | { |
|
571 | { | |
661 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
572 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
662 | if (status != RTEMS_SUCCESSFUL) |
|
573 | if (status != RTEMS_SUCCESSFUL) | |
663 | { |
|
574 | { | |
664 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
575 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
665 | } |
|
576 | } | |
666 | } |
|
577 | } | |
667 |
|
578 | |||
668 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
579 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
669 | { |
|
580 | { | |
670 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
581 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
671 | if (status != RTEMS_SUCCESSFUL) |
|
582 | if (status != RTEMS_SUCCESSFUL) | |
672 | { |
|
583 | { | |
673 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
584 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
674 | } |
|
585 | } | |
675 | } |
|
586 | } | |
676 |
|
587 | |||
677 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
588 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
678 | { |
|
589 | { | |
679 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
590 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
680 | if (status != RTEMS_SUCCESSFUL) |
|
591 | if (status != RTEMS_SUCCESSFUL) | |
681 | { |
|
592 | { | |
682 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
593 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
683 | } |
|
594 | } | |
684 | } |
|
595 | } | |
685 |
|
596 | |||
686 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
597 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
687 | { |
|
598 | { | |
688 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
599 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
689 | if (status != RTEMS_SUCCESSFUL) |
|
600 | if (status != RTEMS_SUCCESSFUL) | |
690 | { |
|
601 | { | |
691 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
602 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
692 | } |
|
603 | } | |
693 | } |
|
604 | } | |
694 |
|
605 | |||
695 | return status; |
|
606 | return status; | |
696 | } |
|
607 | } | |
697 |
|
608 | |||
698 | void launch_waveform_picker( unsigned char mode ) |
|
609 | void launch_waveform_picker( unsigned char mode ) | |
699 | { |
|
610 | { | |
700 | int startDate; |
|
611 | int startDate; | |
701 |
|
612 | |||
702 | reset_current_ring_nodes(); |
|
613 | reset_current_ring_nodes(); | |
703 | reset_waveform_picker_regs(); |
|
614 | reset_waveform_picker_regs(); | |
704 | set_wfp_burst_enable_register( mode ); |
|
615 | set_wfp_burst_enable_register( mode ); | |
705 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
616 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
706 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
617 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
707 | startDate = time_management_regs->coarse_time + 2; |
|
618 | startDate = time_management_regs->coarse_time + 2; | |
708 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] |
|
619 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] | |
709 | waveform_picker_regs->start_date = startDate; |
|
620 | waveform_picker_regs->start_date = startDate; | |
710 | } |
|
621 | } | |
711 |
|
622 | |||
712 | void launch_spectral_matrix( unsigned char mode ) |
|
623 | void launch_spectral_matrix( unsigned char mode ) | |
713 | { |
|
624 | { | |
714 | reset_current_sm_ring_nodes(); |
|
625 | reset_current_sm_ring_nodes(); | |
715 | reset_spectral_matrix_regs(); |
|
626 | reset_spectral_matrix_regs(); | |
716 | // Spectral Matrices simulator |
|
627 | // Spectral Matrices simulator | |
717 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
628 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
718 | set_local_nb_interrupt_f0_MAX(); |
|
629 | set_local_nb_interrupt_f0_MAX(); | |
719 | LEON_Clear_interrupt( IRQ_SM ); |
|
630 | LEON_Clear_interrupt( IRQ_SM ); | |
720 | LEON_Unmask_interrupt( IRQ_SM ); |
|
631 | LEON_Unmask_interrupt( IRQ_SM ); | |
721 | } |
|
632 | } | |
722 |
|
633 | |||
723 | //**************** |
|
634 | //**************** | |
724 | // CLOSING ACTIONS |
|
635 | // CLOSING ACTIONS | |
725 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time) |
|
636 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time) | |
726 | { |
|
637 | { | |
727 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
638 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
728 | * |
|
639 | * | |
729 | * @param TC points to the TC being processed |
|
640 | * @param TC points to the TC being processed | |
730 | * @param time is the time used to date the TC execution |
|
641 | * @param time is the time used to date the TC execution | |
731 | * |
|
642 | * | |
732 | */ |
|
643 | */ | |
733 |
|
644 | |||
734 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
645 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
735 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
646 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
736 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
647 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
737 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
648 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
738 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
649 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
739 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
650 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
740 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
651 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
741 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
652 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
742 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
653 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
743 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
654 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
744 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
655 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
745 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
656 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
746 | } |
|
657 | } | |
747 |
|
658 | |||
748 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time) |
|
659 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time) | |
749 | { |
|
660 | { | |
750 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
661 | /** This function is used to update the HK packets statistics after a TC rejection. | |
751 | * |
|
662 | * | |
752 | * @param TC points to the TC being processed |
|
663 | * @param TC points to the TC being processed | |
753 | * @param time is the time used to date the TC rejection |
|
664 | * @param time is the time used to date the TC rejection | |
754 | * |
|
665 | * | |
755 | */ |
|
666 | */ | |
756 |
|
667 | |||
757 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
668 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
758 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
669 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
759 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
670 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
760 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
671 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
761 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
672 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
762 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
673 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
763 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
674 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
764 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
675 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
765 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
676 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
766 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
677 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
767 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
678 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
768 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
679 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
769 | } |
|
680 | } | |
770 |
|
681 | |||
771 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time) |
|
682 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time) | |
772 | { |
|
683 | { | |
773 | /** This function is the last step of the TC execution workflow. |
|
684 | /** This function is the last step of the TC execution workflow. | |
774 | * |
|
685 | * | |
775 | * @param TC points to the TC being processed |
|
686 | * @param TC points to the TC being processed | |
776 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
687 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
777 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
688 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
778 | * @param time is the time used to date the TC execution |
|
689 | * @param time is the time used to date the TC execution | |
779 | * |
|
690 | * | |
780 | */ |
|
691 | */ | |
781 |
|
692 | |||
782 | unsigned int val = 0; |
|
693 | unsigned int val = 0; | |
783 |
|
694 | |||
784 | if (result == LFR_SUCCESSFUL) |
|
695 | if (result == LFR_SUCCESSFUL) | |
785 | { |
|
696 | { | |
786 | if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
697 | if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
787 | && |
|
698 | && | |
788 | !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
699 | !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
789 | ) |
|
700 | ) | |
790 | { |
|
701 | { | |
791 | send_tm_lfr_tc_exe_success( TC, queue_id, time ); |
|
702 | send_tm_lfr_tc_exe_success( TC, queue_id, time ); | |
792 | } |
|
703 | } | |
793 | update_last_TC_exe( TC, time ); |
|
704 | update_last_TC_exe( TC, time ); | |
794 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
705 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
795 | val++; |
|
706 | val++; | |
796 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
707 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
797 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
708 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
798 | } |
|
709 | } | |
799 | else |
|
710 | else | |
800 | { |
|
711 | { | |
801 | update_last_TC_rej( TC, time ); |
|
712 | update_last_TC_rej( TC, time ); | |
802 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
713 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
803 | val++; |
|
714 | val++; | |
804 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
715 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
805 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
716 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
806 | } |
|
717 | } | |
807 | } |
|
718 | } | |
808 |
|
719 | |||
809 | //*************************** |
|
720 | //*************************** | |
810 | // Interrupt Service Routines |
|
721 | // Interrupt Service Routines | |
811 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
722 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
812 | { |
|
723 | { | |
813 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
724 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
814 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
725 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
815 | } |
|
726 | } | |
816 | } |
|
727 | } | |
817 |
|
728 | |||
818 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
729 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
819 | { |
|
730 | { | |
820 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
731 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
821 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
732 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
822 | } |
|
733 | } | |
823 | } |
|
734 | } | |
824 |
|
735 | |||
825 | //**************** |
|
736 | //**************** | |
826 | // OTHER FUNCTIONS |
|
737 | // OTHER FUNCTIONS | |
827 | void updateLFRCurrentMode() |
|
738 | void updateLFRCurrentMode() | |
828 | { |
|
739 | { | |
829 | /** This function updates the value of the global variable lfrCurrentMode. |
|
740 | /** This function updates the value of the global variable lfrCurrentMode. | |
830 | * |
|
741 | * | |
831 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
742 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
832 | * |
|
743 | * | |
833 | */ |
|
744 | */ | |
834 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
745 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
835 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
746 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
836 | } |
|
747 | } | |
837 |
|
748 |
@@ -1,482 +1,483 | |||||
1 | /** Functions to load and dump parameters in the LFR registers. |
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
9 | * TC_LFR_LOAD_BURST_PAR\n |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
12 | * |
|
12 | * | |
13 | */ |
|
13 | */ | |
14 |
|
14 | |||
15 | #include "tc_load_dump_parameters.h" |
|
15 | #include "tc_load_dump_parameters.h" | |
16 |
|
16 | |||
17 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
17 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
18 | { |
|
18 | { | |
19 | /** This function updates the LFR registers with the incoming common parameters. |
|
19 | /** This function updates the LFR registers with the incoming common parameters. | |
20 | * |
|
20 | * | |
21 | * @param TC points to the TeleCommand packet that is being processed |
|
21 | * @param TC points to the TeleCommand packet that is being processed | |
22 | * |
|
22 | * | |
23 | * |
|
23 | * | |
24 | */ |
|
24 | */ | |
25 |
|
25 | |||
26 | parameter_dump_packet.unused0 = TC->dataAndCRC[0]; |
|
26 | parameter_dump_packet.unused0 = TC->dataAndCRC[0]; | |
27 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1]; |
|
27 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1]; | |
28 | set_wfp_data_shaping( ); |
|
28 | set_wfp_data_shaping( ); | |
29 | return LFR_SUCCESSFUL; |
|
29 | return LFR_SUCCESSFUL; | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
32 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
33 | { |
|
33 | { | |
34 | /** This function updates the LFR registers with the incoming normal parameters. |
|
34 | /** This function updates the LFR registers with the incoming normal parameters. | |
35 | * |
|
35 | * | |
36 | * @param TC points to the TeleCommand packet that is being processed |
|
36 | * @param TC points to the TeleCommand packet that is being processed | |
37 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
37 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
38 | * |
|
38 | * | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | int result; |
|
41 | int result; | |
42 | int flag; |
|
42 | int flag; | |
43 | rtems_status_code status; |
|
43 | rtems_status_code status; | |
44 |
|
44 | |||
45 | flag = LFR_SUCCESSFUL; |
|
45 | flag = LFR_SUCCESSFUL; | |
46 |
|
46 | |||
47 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
47 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || | |
48 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
48 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { | |
49 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
49 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
50 | flag = LFR_DEFAULT; |
|
50 | flag = LFR_DEFAULT; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | //*************** |
|
53 | //*************** | |
54 | // sy_lfr_n_swf_l |
|
54 | // sy_lfr_n_swf_l | |
55 | if (flag == LFR_SUCCESSFUL) |
|
55 | if (flag == LFR_SUCCESSFUL) | |
56 | { |
|
56 | { | |
57 | result = set_sy_lfr_n_swf_l( TC, queue_id, time ); |
|
57 | result = set_sy_lfr_n_swf_l( TC, queue_id, time ); | |
58 | if (result != LFR_SUCCESSFUL) |
|
58 | if (result != LFR_SUCCESSFUL) | |
59 | { |
|
59 | { | |
60 | flag = LFR_DEFAULT; |
|
60 | flag = LFR_DEFAULT; | |
61 | } |
|
61 | } | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | //*************** |
|
64 | //*************** | |
65 | // sy_lfr_n_swf_p |
|
65 | // sy_lfr_n_swf_p | |
66 | if (flag == LFR_SUCCESSFUL) |
|
66 | if (flag == LFR_SUCCESSFUL) | |
67 | { |
|
67 | { | |
68 | result = set_sy_lfr_n_swf_p( TC, queue_id, time ); |
|
68 | result = set_sy_lfr_n_swf_p( TC, queue_id, time ); | |
69 | if (result != LFR_SUCCESSFUL) |
|
69 | if (result != LFR_SUCCESSFUL) | |
70 | { |
|
70 | { | |
71 | flag = LFR_DEFAULT; |
|
71 | flag = LFR_DEFAULT; | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | //*************** |
|
75 | //*************** | |
76 | // SY_LFR_N_ASM_P |
|
76 | // sy_lfr_n_asm_p | |
77 | if (flag == LFR_SUCCESSFUL) |
|
77 | if (flag == LFR_SUCCESSFUL) | |
78 | { |
|
78 | { | |
79 | result = set_sy_lfr_n_asm_p( TC, queue_id ); |
|
79 | result = set_sy_lfr_n_asm_p( TC, queue_id ); | |
80 | if (result != LFR_SUCCESSFUL) |
|
80 | if (result != LFR_SUCCESSFUL) | |
81 | { |
|
81 | { | |
82 | flag = LFR_DEFAULT; |
|
82 | flag = LFR_DEFAULT; | |
83 | } |
|
83 | } | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | //*************** |
|
86 | //*************** | |
87 | // SY_LFR_N_BP_P0 |
|
87 | // sy_lfr_n_bp_p0 | |
88 | if (flag == LFR_SUCCESSFUL) |
|
88 | if (flag == LFR_SUCCESSFUL) | |
89 | { |
|
89 | { | |
90 | result = set_sy_lfr_n_bp_p0( TC, queue_id ); |
|
90 | result = set_sy_lfr_n_bp_p0( TC, queue_id ); | |
91 | if (result != LFR_SUCCESSFUL) |
|
91 | if (result != LFR_SUCCESSFUL) | |
92 | { |
|
92 | { | |
93 | flag = LFR_DEFAULT; |
|
93 | flag = LFR_DEFAULT; | |
94 | } |
|
94 | } | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | //*************** |
|
97 | //*************** | |
98 | // sy_lfr_n_bp_p1 |
|
98 | // sy_lfr_n_bp_p1 | |
99 | if (flag == LFR_SUCCESSFUL) |
|
99 | if (flag == LFR_SUCCESSFUL) | |
100 | { |
|
100 | { | |
101 | result = set_sy_lfr_n_bp_p1( TC, queue_id ); |
|
101 | result = set_sy_lfr_n_bp_p1( TC, queue_id ); | |
102 | if (result != LFR_SUCCESSFUL) |
|
102 | if (result != LFR_SUCCESSFUL) | |
103 | { |
|
103 | { | |
104 | flag = LFR_DEFAULT; |
|
104 | flag = LFR_DEFAULT; | |
105 | } |
|
105 | } | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | //********************* |
|
108 | //********************* | |
109 | // sy_lfr_n_cwf_long_f3 |
|
109 | // sy_lfr_n_cwf_long_f3 | |
110 | if (flag == LFR_SUCCESSFUL) |
|
110 | if (flag == LFR_SUCCESSFUL) | |
111 | { |
|
111 | { | |
112 | result = set_sy_lfr_n_cwf_long_f3( TC, queue_id ); |
|
112 | result = set_sy_lfr_n_cwf_long_f3( TC, queue_id ); | |
113 | if (result != LFR_SUCCESSFUL) |
|
113 | if (result != LFR_SUCCESSFUL) | |
114 | { |
|
114 | { | |
115 | flag = LFR_DEFAULT; |
|
115 | flag = LFR_DEFAULT; | |
116 | } |
|
116 | } | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | return flag; |
|
119 | return flag; | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
122 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
123 | { |
|
123 | { | |
124 | /** This function updates the LFR registers with the incoming burst parameters. |
|
124 | /** This function updates the LFR registers with the incoming burst parameters. | |
125 | * |
|
125 | * | |
126 | * @param TC points to the TeleCommand packet that is being processed |
|
126 | * @param TC points to the TeleCommand packet that is being processed | |
127 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
127 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
128 | * |
|
128 | * | |
129 | */ |
|
129 | */ | |
130 |
|
130 | |||
131 | int result; |
|
131 | int result; | |
132 | unsigned char lfrMode; |
|
132 | unsigned char lfrMode; | |
133 | rtems_status_code status; |
|
133 | rtems_status_code status; | |
134 |
|
134 | |||
135 | result = LFR_DEFAULT; |
|
135 | result = LFR_DEFAULT; | |
136 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
136 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
137 |
|
137 | |||
138 | if ( lfrMode == LFR_MODE_BURST ) { |
|
138 | if ( lfrMode == LFR_MODE_BURST ) { | |
139 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
139 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
140 | result = LFR_DEFAULT; |
|
140 | result = LFR_DEFAULT; | |
141 | } |
|
141 | } | |
142 | else { |
|
142 | else { | |
143 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0]; |
|
143 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0]; | |
144 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1]; |
|
144 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1]; | |
145 |
|
145 | |||
146 | result = LFR_SUCCESSFUL; |
|
146 | result = LFR_SUCCESSFUL; | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | return result; |
|
149 | return result; | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
152 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
153 | { |
|
153 | { | |
154 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
154 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
155 | * |
|
155 | * | |
156 | * @param TC points to the TeleCommand packet that is being processed |
|
156 | * @param TC points to the TeleCommand packet that is being processed | |
157 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
157 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
158 | * |
|
158 | * | |
159 | */ |
|
159 | */ | |
160 | int result; |
|
160 | int result; | |
161 | unsigned char lfrMode; |
|
161 | unsigned char lfrMode; | |
162 | rtems_status_code status; |
|
162 | rtems_status_code status; | |
163 |
|
163 | |||
164 | result = LFR_DEFAULT; |
|
164 | result = LFR_DEFAULT; | |
165 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
165 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
166 |
|
166 | |||
167 | if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) { |
|
167 | if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) { | |
168 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
168 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
169 | result = LFR_DEFAULT; |
|
169 | result = LFR_DEFAULT; | |
170 | } |
|
170 | } | |
171 | else { |
|
171 | else { | |
172 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0]; |
|
172 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0]; | |
173 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1]; |
|
173 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1]; | |
174 |
|
174 | |||
175 | result = LFR_SUCCESSFUL; |
|
175 | result = LFR_SUCCESSFUL; | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | return result; |
|
178 | return result; | |
179 | } |
|
179 | } | |
180 |
|
180 | |||
181 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
181 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
182 | { |
|
182 | { | |
183 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
183 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
184 | * |
|
184 | * | |
185 | * @param TC points to the TeleCommand packet that is being processed |
|
185 | * @param TC points to the TeleCommand packet that is being processed | |
186 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
186 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
187 | * |
|
187 | * | |
188 | */ |
|
188 | */ | |
189 |
|
189 | |||
190 | int result; |
|
190 | int result; | |
191 | unsigned char lfrMode; |
|
191 | unsigned char lfrMode; | |
192 | rtems_status_code status; |
|
192 | rtems_status_code status; | |
193 |
|
193 | |||
194 | result = LFR_DEFAULT; |
|
194 | result = LFR_DEFAULT; | |
195 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
195 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
196 |
|
196 | |||
197 | if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) { |
|
197 | if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) { | |
198 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); |
|
198 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time ); | |
199 | result = LFR_DEFAULT; |
|
199 | result = LFR_DEFAULT; | |
200 | } |
|
200 | } | |
201 | else { |
|
201 | else { | |
202 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0]; |
|
202 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0]; | |
203 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1]; |
|
203 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1]; | |
204 |
|
204 | |||
205 | result = LFR_SUCCESSFUL; |
|
205 | result = LFR_SUCCESSFUL; | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | return result; |
|
208 | return result; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | int action_dump_par( rtems_id queue_id ) |
|
211 | int action_dump_par( rtems_id queue_id ) | |
212 | { |
|
212 | { | |
213 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
213 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
214 | * |
|
214 | * | |
215 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
215 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
216 | * |
|
216 | * | |
217 | * @return RTEMS directive status codes: |
|
217 | * @return RTEMS directive status codes: | |
218 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
218 | * - RTEMS_SUCCESSFUL - message sent successfully | |
219 | * - RTEMS_INVALID_ID - invalid queue id |
|
219 | * - RTEMS_INVALID_ID - invalid queue id | |
220 | * - RTEMS_INVALID_SIZE - invalid message size |
|
220 | * - RTEMS_INVALID_SIZE - invalid message size | |
221 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
221 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
222 | * - RTEMS_UNSATISFIED - out of message buffers |
|
222 | * - RTEMS_UNSATISFIED - out of message buffers | |
223 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
223 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
224 | * |
|
224 | * | |
225 | */ |
|
225 | */ | |
226 |
|
226 | |||
227 | int status; |
|
227 | int status; | |
228 |
|
228 | |||
229 | // UPDATE TIME |
|
229 | // UPDATE TIME | |
230 | increment_seq_counter( parameter_dump_packet.packetSequenceControl ); |
|
230 | increment_seq_counter( parameter_dump_packet.packetSequenceControl ); | |
231 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
231 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
232 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
232 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
233 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
233 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
234 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
234 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
235 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
235 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
236 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
236 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
237 | // SEND DATA |
|
237 | // SEND DATA | |
238 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
238 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
239 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
239 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
240 | if (status != RTEMS_SUCCESSFUL) { |
|
240 | if (status != RTEMS_SUCCESSFUL) { | |
241 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
241 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | return status; |
|
244 | return status; | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | //*********************** |
|
247 | //*********************** | |
248 | // NORMAL MODE PARAMETERS |
|
248 | // NORMAL MODE PARAMETERS | |
249 |
|
249 | |||
250 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) |
|
250 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) | |
251 | { |
|
251 | { | |
252 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
252 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
253 | * |
|
253 | * | |
254 | * @param TC points to the TeleCommand packet that is being processed |
|
254 | * @param TC points to the TeleCommand packet that is being processed | |
255 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
255 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
256 | * |
|
256 | * | |
257 | */ |
|
257 | */ | |
258 |
|
258 | |||
259 | unsigned int tmp; |
|
259 | unsigned int tmp; | |
260 | int result; |
|
260 | int result; | |
261 | unsigned char msb; |
|
261 | unsigned char msb; | |
262 | unsigned char lsb; |
|
262 | unsigned char lsb; | |
263 | rtems_status_code status; |
|
263 | rtems_status_code status; | |
264 |
|
264 | |||
265 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ]; |
|
265 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ]; | |
266 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ]; |
|
266 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ]; | |
267 |
|
267 | |||
268 | tmp = ( unsigned int ) floor( |
|
268 | tmp = ( unsigned int ) floor( | |
269 | ( ( msb*256 ) + lsb ) / 16 |
|
269 | ( ( msb*256 ) + lsb ) / 16 | |
270 | ) * 16; |
|
270 | ) * 16; | |
271 |
|
271 | |||
272 | if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16 |
|
272 | if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16 | |
273 | { // 2048 is the maximum limit due to the size of the buffers |
|
273 | { // 2048 is the maximum limit due to the size of the buffers | |
274 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb, time ); |
|
274 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb, time ); | |
275 | result = WRONG_APP_DATA; |
|
275 | result = WRONG_APP_DATA; | |
276 | } |
|
276 | } | |
277 | else if (tmp != 2048) |
|
277 | else if (tmp != 2048) | |
278 | { |
|
278 | { | |
279 | status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
279 | status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
280 | result = FUNCT_NOT_IMPL; |
|
280 | result = FUNCT_NOT_IMPL; | |
281 | } |
|
281 | } | |
282 | else |
|
282 | else | |
283 | { |
|
283 | { | |
284 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8); |
|
284 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8); | |
285 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp ); |
|
285 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp ); | |
286 | result = LFR_SUCCESSFUL; |
|
286 | result = LFR_SUCCESSFUL; | |
287 | } |
|
287 | } | |
288 |
|
288 | |||
289 | return result; |
|
289 | return result; | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time) |
|
292 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time) | |
293 | { |
|
293 | { | |
294 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
294 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
295 | * |
|
295 | * | |
296 | * @param TC points to the TeleCommand packet that is being processed |
|
296 | * @param TC points to the TeleCommand packet that is being processed | |
297 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
297 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
298 | * |
|
298 | * | |
299 | */ |
|
299 | */ | |
300 |
|
300 | |||
301 | unsigned int tmp; |
|
301 | unsigned int tmp; | |
302 | int result; |
|
302 | int result; | |
303 | unsigned char msb; |
|
303 | unsigned char msb; | |
304 | unsigned char lsb; |
|
304 | unsigned char lsb; | |
305 | rtems_status_code status; |
|
305 | rtems_status_code status; | |
306 |
|
306 | |||
307 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ]; |
|
307 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ]; | |
308 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ]; |
|
308 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ]; | |
309 |
|
309 | |||
310 | tmp = msb * 256 + lsb; |
|
310 | tmp = msb * 256 + lsb; | |
311 |
|
311 | |||
312 | if ( tmp < 16 ) |
|
312 | if ( tmp < 16 ) | |
313 | { |
|
313 | { | |
314 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb, time ); |
|
314 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb, time ); | |
315 | result = WRONG_APP_DATA; |
|
315 | result = WRONG_APP_DATA; | |
316 | } |
|
316 | } | |
317 | else |
|
317 | else | |
318 | { |
|
318 | { | |
319 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8); |
|
319 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8); | |
320 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp ); |
|
320 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp ); | |
321 | result = LFR_SUCCESSFUL; |
|
321 | result = LFR_SUCCESSFUL; | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | return result; |
|
324 | return result; | |
325 | } |
|
325 | } | |
326 |
|
326 | |||
327 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
327 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
328 | { |
|
328 | { | |
329 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
329 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
330 | * |
|
330 | * | |
331 | * @param TC points to the TeleCommand packet that is being processed |
|
331 | * @param TC points to the TeleCommand packet that is being processed | |
332 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
332 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
333 | * |
|
333 | * | |
334 | */ |
|
334 | */ | |
335 |
|
335 | |||
336 | int result; |
|
336 | int result; | |
337 | unsigned char msb; |
|
337 | unsigned char msb; | |
338 | unsigned char lsb; |
|
338 | unsigned char lsb; | |
339 |
|
339 | |||
340 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ]; |
|
340 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ]; | |
341 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ]; |
|
341 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ]; | |
342 |
|
342 | |||
343 | parameter_dump_packet.sy_lfr_n_asm_p[0] = msb; |
|
343 | parameter_dump_packet.sy_lfr_n_asm_p[0] = msb; | |
344 | parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb; |
|
344 | parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb; | |
345 | result = LFR_SUCCESSFUL; |
|
345 | result = LFR_SUCCESSFUL; | |
346 |
|
346 | |||
347 | return result; |
|
347 | return result; | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
350 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
351 | { |
|
351 | { | |
352 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0). |
|
352 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0). | |
353 | * |
|
353 | * | |
354 | * @param TC points to the TeleCommand packet that is being processed |
|
354 | * @param TC points to the TeleCommand packet that is being processed | |
355 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
355 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
356 | * |
|
356 | * | |
357 | */ |
|
357 | */ | |
358 |
|
358 | |||
359 | int status; |
|
359 | int status; | |
360 |
|
360 | |||
361 | status = LFR_SUCCESSFUL; |
|
361 | status = LFR_SUCCESSFUL; | |
362 |
|
362 | |||
363 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ]; |
|
363 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ]; | |
364 |
|
364 | |||
365 | return status; |
|
365 | return status; | |
366 | } |
|
366 | } | |
367 |
|
367 | |||
368 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
368 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
369 | { |
|
369 | { | |
370 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
370 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
371 | * |
|
371 | * | |
372 | * @param TC points to the TeleCommand packet that is being processed |
|
372 | * @param TC points to the TeleCommand packet that is being processed | |
373 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
373 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
374 | * |
|
374 | * | |
375 | */ |
|
375 | */ | |
376 |
|
376 | |||
377 | int status; |
|
377 | int status; | |
378 |
|
378 | |||
379 | status = LFR_SUCCESSFUL; |
|
379 | status = LFR_SUCCESSFUL; | |
380 |
|
380 | |||
381 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ]; |
|
381 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ]; | |
382 |
|
382 | |||
383 | return status; |
|
383 | return status; | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
386 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
387 | { |
|
387 | { | |
388 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
388 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
389 | * |
|
389 | * | |
390 | * @param TC points to the TeleCommand packet that is being processed |
|
390 | * @param TC points to the TeleCommand packet that is being processed | |
391 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
391 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
392 | * |
|
392 | * | |
393 | */ |
|
393 | */ | |
394 |
|
394 | |||
395 | int status; |
|
395 | int status; | |
396 |
|
396 | |||
397 | status = LFR_SUCCESSFUL; |
|
397 | status = LFR_SUCCESSFUL; | |
398 |
|
398 | |||
399 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
399 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
400 |
|
400 | |||
401 | return status; |
|
401 | return status; | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | //********************** |
|
404 | //********************** | |
405 | // BURST MODE PARAMETERS |
|
405 | // BURST MODE PARAMETERS | |
406 |
|
406 | |||
407 | //********************* |
|
407 | //********************* | |
408 | // SBM1 MODE PARAMETERS |
|
408 | // SBM1 MODE PARAMETERS | |
409 |
|
409 | |||
410 | //********************* |
|
410 | //********************* | |
411 | // SBM2 MODE PARAMETERS |
|
411 | // SBM2 MODE PARAMETERS | |
412 |
|
412 | |||
413 | //********** |
|
413 | //********** | |
414 | // init dump |
|
414 | // init dump | |
415 |
|
415 | |||
416 | void init_parameter_dump( void ) |
|
416 | void init_parameter_dump( void ) | |
417 | { |
|
417 | { | |
418 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
418 | /** This function initialize the parameter_dump_packet global variable with default values. | |
419 | * |
|
419 | * | |
420 | */ |
|
420 | */ | |
421 |
|
421 | |||
422 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
422 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
423 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
423 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
424 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
424 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
425 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
425 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
426 | parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); |
|
426 | parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); | |
427 | parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; |
|
427 | parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; | |
428 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
428 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
429 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
429 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
430 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
430 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
431 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
431 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
432 | // DATA FIELD HEADER |
|
432 | // DATA FIELD HEADER | |
433 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
433 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
434 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
434 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
435 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
435 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
436 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
436 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
437 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
437 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
438 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
438 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
439 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
439 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
440 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
440 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
441 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
441 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
442 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
442 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
443 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
443 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
444 |
|
444 | |||
445 | //****************** |
|
445 | //****************** | |
446 | // COMMON PARAMETERS |
|
446 | // COMMON PARAMETERS | |
447 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; |
|
447 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; | |
448 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; |
|
448 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; | |
449 |
|
449 | |||
450 | //****************** |
|
450 | //****************** | |
451 | // NORMAL PARAMETERS |
|
451 | // NORMAL PARAMETERS | |
452 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8); |
|
452 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8); | |
453 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L ); |
|
453 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L ); | |
454 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8); |
|
454 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8); | |
455 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P ); |
|
455 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P ); | |
456 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8); |
|
456 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8); | |
457 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); |
|
457 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); | |
458 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; |
|
458 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; | |
459 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; |
|
459 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; | |
|
460 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3; | |||
460 |
|
461 | |||
461 | //***************** |
|
462 | //***************** | |
462 | // BURST PARAMETERS |
|
463 | // BURST PARAMETERS | |
463 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
464 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
464 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
465 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
465 |
|
466 | |||
466 | //**************** |
|
467 | //**************** | |
467 | // SBM1 PARAMETERS |
|
468 | // SBM1 PARAMETERS | |
468 | 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 |
|
469 | 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 | |
469 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
470 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
470 |
|
471 | |||
471 | //**************** |
|
472 | //**************** | |
472 | // SBM2 PARAMETERS |
|
473 | // SBM2 PARAMETERS | |
473 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
474 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
474 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
475 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
475 | } |
|
476 | } | |
476 |
|
477 | |||
477 |
|
478 | |||
478 |
|
479 | |||
479 |
|
480 | |||
480 |
|
481 | |||
481 |
|
482 | |||
482 |
|
483 |
@@ -1,1350 +1,1300 | |||||
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 | //***************** |
|
12 | //***************** | |
13 | // waveform headers |
|
13 | // waveform headers | |
14 | // SWF |
|
14 | // SWF | |
15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; | |
16 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
16 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; | |
17 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
17 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; | |
18 | // CWF |
|
18 | // CWF | |
19 |
Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ |
|
19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ]; | |
20 |
Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ |
|
20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ]; | |
21 |
Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ]; | |
22 |
Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ |
|
22 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ]; | |
23 |
Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ |
|
23 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ]; | |
24 |
|
24 | |||
25 | //************** |
|
25 | //************** | |
26 | // waveform ring |
|
26 | // waveform ring | |
27 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
27 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; | |
28 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
28 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; | |
29 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
29 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; | |
30 | ring_node *current_ring_node_f0; |
|
30 | ring_node *current_ring_node_f0; | |
31 | ring_node *ring_node_to_send_swf_f0; |
|
31 | ring_node *ring_node_to_send_swf_f0; | |
32 | ring_node *current_ring_node_f1; |
|
32 | ring_node *current_ring_node_f1; | |
33 | ring_node *ring_node_to_send_swf_f1; |
|
33 | ring_node *ring_node_to_send_swf_f1; | |
34 | ring_node *ring_node_to_send_cwf_f1; |
|
34 | ring_node *ring_node_to_send_cwf_f1; | |
35 | ring_node *current_ring_node_f2; |
|
35 | ring_node *current_ring_node_f2; | |
36 | ring_node *ring_node_to_send_swf_f2; |
|
36 | ring_node *ring_node_to_send_swf_f2; | |
37 | ring_node *ring_node_to_send_cwf_f2; |
|
37 | ring_node *ring_node_to_send_cwf_f2; | |
38 |
|
38 | |||
39 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
39 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
40 | { |
|
40 | { | |
41 | /** This is the interrupt sub routine called by the waveform picker core. |
|
41 | /** This is the interrupt sub routine called by the waveform picker core. | |
42 | * |
|
42 | * | |
43 | * This ISR launch different actions depending mainly on two pieces of information: |
|
43 | * This ISR launch different actions depending mainly on two pieces of information: | |
44 | * 1. the values read in the registers of the waveform picker. |
|
44 | * 1. the values read in the registers of the waveform picker. | |
45 | * 2. the current LFR mode. |
|
45 | * 2. the current LFR mode. | |
46 | * |
|
46 | * | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | static unsigned char nb_swf = 0; |
|
49 | static unsigned char nb_swf = 0; | |
50 |
|
50 | |||
51 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
51 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
52 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
52 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
53 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
53 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
54 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
54 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full | |
55 | // (1) change the receiving buffer for the waveform picker |
|
55 | // (1) change the receiving buffer for the waveform picker | |
56 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
56 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { | |
57 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); |
|
57 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); | |
58 | } |
|
58 | } | |
59 | else { |
|
59 | else { | |
60 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); |
|
60 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); | |
61 | } |
|
61 | } | |
62 | // (2) send an event for the waveforms transmission |
|
62 | // (2) send an event for the waveforms transmission | |
63 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
63 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
64 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
64 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
65 | } |
|
65 | } | |
66 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
66 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] | |
67 | } |
|
67 | } | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | switch(lfrCurrentMode) |
|
70 | switch(lfrCurrentMode) | |
71 | { |
|
71 | { | |
72 | //******** |
|
72 | //******** | |
73 | // STANDBY |
|
73 | // STANDBY | |
74 | case(LFR_MODE_STANDBY): |
|
74 | case(LFR_MODE_STANDBY): | |
75 | break; |
|
75 | break; | |
76 |
|
76 | |||
77 | //****** |
|
77 | //****** | |
78 | // NORMAL |
|
78 | // NORMAL | |
79 | case(LFR_MODE_NORMAL): |
|
79 | case(LFR_MODE_NORMAL): | |
80 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
80 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits | |
81 | { |
|
81 | { | |
82 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
82 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
83 | } |
|
83 | } | |
84 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits |
|
84 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits | |
85 | { |
|
85 | { | |
86 | // change F0 ring node |
|
86 | // change F0 ring node | |
87 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
87 | ring_node_to_send_swf_f0 = current_ring_node_f0; | |
88 | current_ring_node_f0 = current_ring_node_f0->next; |
|
88 | current_ring_node_f0 = current_ring_node_f0->next; | |
89 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
89 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; | |
90 | // change F1 ring node |
|
90 | // change F1 ring node | |
91 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
91 | ring_node_to_send_swf_f1 = current_ring_node_f1; | |
92 | current_ring_node_f1 = current_ring_node_f1->next; |
|
92 | current_ring_node_f1 = current_ring_node_f1->next; | |
93 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
93 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; | |
94 | // change F2 ring node |
|
94 | // change F2 ring node | |
95 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
95 | ring_node_to_send_swf_f2 = current_ring_node_f2; | |
96 | current_ring_node_f2 = current_ring_node_f2->next; |
|
96 | current_ring_node_f2 = current_ring_node_f2->next; | |
97 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
97 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; | |
98 | // |
|
98 | // | |
99 | // if (nb_swf < 2) |
|
99 | // if (nb_swf < 2) | |
100 | if (true) |
|
100 | if (true) | |
101 | { |
|
101 | { | |
102 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
102 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
103 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
103 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
104 | } |
|
104 | } | |
105 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] |
|
105 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] | |
106 | nb_swf = nb_swf + 1; |
|
106 | nb_swf = nb_swf + 1; | |
107 | } |
|
107 | } | |
108 | else |
|
108 | else | |
109 | { |
|
109 | { | |
110 | reset_wfp_burst_enable(); |
|
110 | reset_wfp_burst_enable(); | |
111 | nb_swf = 0; |
|
111 | nb_swf = 0; | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | break; |
|
116 | break; | |
117 |
|
117 | |||
118 | //****** |
|
118 | //****** | |
119 | // BURST |
|
119 | // BURST | |
120 | case(LFR_MODE_BURST): |
|
120 | case(LFR_MODE_BURST): | |
121 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
121 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit | |
122 | // (1) change the receiving buffer for the waveform picker |
|
122 | // (1) change the receiving buffer for the waveform picker | |
123 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
123 | ring_node_to_send_cwf_f2 = current_ring_node_f2; | |
124 | current_ring_node_f2 = current_ring_node_f2->next; |
|
124 | current_ring_node_f2 = current_ring_node_f2->next; | |
125 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
125 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; | |
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_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
127 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != 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 & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
130 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 | |
131 | } |
|
131 | } | |
132 | break; |
|
132 | break; | |
133 |
|
133 | |||
134 | //***** |
|
134 | //***** | |
135 | // SBM1 |
|
135 | // SBM1 | |
136 | case(LFR_MODE_SBM1): |
|
136 | case(LFR_MODE_SBM1): | |
137 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
137 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit | |
138 | // (1) change the receiving buffer for the waveform picker |
|
138 | // (1) change the receiving buffer for the waveform picker | |
139 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
139 | ring_node_to_send_cwf_f1 = current_ring_node_f1; | |
140 | current_ring_node_f1 = current_ring_node_f1->next; |
|
140 | current_ring_node_f1 = current_ring_node_f1->next; | |
141 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
141 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; | |
142 | // (2) send an event for the waveforms transmission |
|
142 | // (2) send an event for the waveforms transmission | |
143 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { |
|
143 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { | |
144 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
144 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
145 | } |
|
145 | } | |
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 |
|
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 | |
147 | } |
|
147 | } | |
148 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
148 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit | |
149 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
149 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
150 | } |
|
150 | } | |
151 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
151 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit | |
152 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
152 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
153 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
153 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
154 | } |
|
154 | } | |
155 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 |
|
155 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 | |
156 | } |
|
156 | } | |
157 | break; |
|
157 | break; | |
158 |
|
158 | |||
159 | //***** |
|
159 | //***** | |
160 | // SBM2 |
|
160 | // SBM2 | |
161 | case(LFR_MODE_SBM2): |
|
161 | case(LFR_MODE_SBM2): | |
162 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
162 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit | |
163 | // (1) change the receiving buffer for the waveform picker |
|
163 | // (1) change the receiving buffer for the waveform picker | |
164 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
164 | ring_node_to_send_cwf_f2 = current_ring_node_f2; | |
165 | current_ring_node_f2 = current_ring_node_f2->next; |
|
165 | current_ring_node_f2 = current_ring_node_f2->next; | |
166 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
166 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; | |
167 | // (2) send an event for the waveforms transmission |
|
167 | // (2) send an event for the waveforms transmission | |
168 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { |
|
168 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { | |
169 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
169 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
170 | } |
|
170 | } | |
171 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
171 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 | |
172 | } |
|
172 | } | |
173 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
173 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit | |
174 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
174 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
175 | } |
|
175 | } | |
176 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
176 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit | |
177 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
177 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
178 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
178 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
179 | } |
|
179 | } | |
180 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 |
|
180 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 | |
181 | } |
|
181 | } | |
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_isr_alt( rtems_vector_number vector ) |
|
191 | rtems_isr waveforms_isr_alt( rtems_vector_number vector ) | |
192 | { |
|
192 | { | |
193 | /** This is the interrupt sub routine called by the waveform picker core. |
|
193 | /** This is the interrupt sub routine called by the waveform picker core. | |
194 | * |
|
194 | * | |
195 | * This ISR launch different actions depending mainly on two pieces of information: |
|
195 | * This ISR launch different actions depending mainly on two pieces of information: | |
196 | * 1. the values read in the registers of the waveform picker. |
|
196 | * 1. the values read in the registers of the waveform picker. | |
197 | * 2. the current LFR mode. |
|
197 | * 2. the current LFR mode. | |
198 | * |
|
198 | * | |
199 | */ |
|
199 | */ | |
200 |
|
200 | |||
201 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
201 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
202 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
202 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
203 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
203 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
204 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
204 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full | |
205 | // (1) change the receiving buffer for the waveform picker |
|
205 | // (1) change the receiving buffer for the waveform picker | |
206 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
206 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { | |
207 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); |
|
207 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); | |
208 | } |
|
208 | } | |
209 | else { |
|
209 | else { | |
210 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); |
|
210 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); | |
211 | } |
|
211 | } | |
212 | // (2) send an event for the waveforms transmission |
|
212 | // (2) send an event for the waveforms transmission | |
213 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
213 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
214 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
214 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
215 | } |
|
215 | } | |
216 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
216 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] | |
217 | } |
|
217 | } | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | switch(lfrCurrentMode) |
|
220 | switch(lfrCurrentMode) | |
221 | { |
|
221 | { | |
222 | //******** |
|
222 | //******** | |
223 | // STANDBY |
|
223 | // STANDBY | |
224 | case(LFR_MODE_STANDBY): |
|
224 | case(LFR_MODE_STANDBY): | |
225 | break; |
|
225 | break; | |
226 |
|
226 | |||
227 | //****** |
|
227 | //****** | |
228 | // NORMAL |
|
228 | // NORMAL | |
229 | case(LFR_MODE_NORMAL): |
|
229 | case(LFR_MODE_NORMAL): | |
230 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
230 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits | |
231 | { |
|
231 | { | |
232 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
232 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
233 | } |
|
233 | } | |
234 | if ( (waveform_picker_regs->status & 0x01) == 0x01) // [0001] check the f0 full bit |
|
234 | if ( (waveform_picker_regs->status & 0x01) == 0x01) // [0001] check the f0 full bit | |
235 | { |
|
235 | { | |
236 | // change F0 ring node |
|
236 | // change F0 ring node | |
237 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
237 | ring_node_to_send_swf_f0 = current_ring_node_f0; | |
238 | current_ring_node_f0 = current_ring_node_f0->next; |
|
238 | current_ring_node_f0 = current_ring_node_f0->next; | |
239 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
239 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; | |
240 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1110 1110 1110] |
|
240 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1110 1110 1110] | |
241 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F0 ) != RTEMS_SUCCESSFUL) { |
|
241 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F0 ) != RTEMS_SUCCESSFUL) { | |
242 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
242 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
243 | } |
|
243 | } | |
244 | } |
|
244 | } | |
245 | if ( (waveform_picker_regs->status & 0x02) == 0x02) // [0010] check the f1 full bit |
|
245 | if ( (waveform_picker_regs->status & 0x02) == 0x02) // [0010] check the f1 full bit | |
246 | { |
|
246 | { | |
247 | // change F1 ring node |
|
247 | // change F1 ring node | |
248 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
248 | ring_node_to_send_swf_f1 = current_ring_node_f1; | |
249 | current_ring_node_f1 = current_ring_node_f1->next; |
|
249 | current_ring_node_f1 = current_ring_node_f1->next; | |
250 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
250 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; | |
251 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1101 1101 1101] |
|
251 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1101 1101 1101] | |
252 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F1 ) != RTEMS_SUCCESSFUL) { |
|
252 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F1 ) != RTEMS_SUCCESSFUL) { | |
253 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
253 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
254 | } |
|
254 | } | |
255 | } |
|
255 | } | |
256 | if ( (waveform_picker_regs->status & 0x04) == 0x04) // [0100] check the f2 full bit |
|
256 | if ( (waveform_picker_regs->status & 0x04) == 0x04) // [0100] check the f2 full bit | |
257 | { |
|
257 | { | |
258 | // change F2 ring node |
|
258 | // change F2 ring node | |
259 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
259 | ring_node_to_send_swf_f2 = current_ring_node_f2; | |
260 | current_ring_node_f2 = current_ring_node_f2->next; |
|
260 | current_ring_node_f2 = current_ring_node_f2->next; | |
261 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
261 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; | |
262 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1011 1011 1011] |
|
262 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1011 1011 1011] | |
263 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F2 ) != RTEMS_SUCCESSFUL) { |
|
263 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL_SWF_F2 ) != RTEMS_SUCCESSFUL) { | |
264 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
264 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
265 | } |
|
265 | } | |
266 | } |
|
266 | } | |
267 | break; |
|
267 | break; | |
268 |
|
268 | |||
269 | //****** |
|
269 | //****** | |
270 | // BURST |
|
270 | // BURST | |
271 | case(LFR_MODE_BURST): |
|
271 | case(LFR_MODE_BURST): | |
272 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
272 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit | |
273 | // (1) change the receiving buffer for the waveform picker |
|
273 | // (1) change the receiving buffer for the waveform picker | |
274 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
274 | ring_node_to_send_cwf_f2 = current_ring_node_f2; | |
275 | current_ring_node_f2 = current_ring_node_f2->next; |
|
275 | current_ring_node_f2 = current_ring_node_f2->next; | |
276 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
276 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; | |
277 | // (2) send an event for the waveforms transmission |
|
277 | // (2) send an event for the waveforms transmission | |
278 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
278 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
279 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
279 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
280 | } |
|
280 | } | |
281 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
281 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 | |
282 | } |
|
282 | } | |
283 | break; |
|
283 | break; | |
284 |
|
284 | |||
285 | //***** |
|
285 | //***** | |
286 | // SBM1 |
|
286 | // SBM1 | |
287 | case(LFR_MODE_SBM1): |
|
287 | case(LFR_MODE_SBM1): | |
288 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
288 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit | |
289 | // (1) change the receiving buffer for the waveform picker |
|
289 | // (1) change the receiving buffer for the waveform picker | |
290 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
290 | ring_node_to_send_cwf_f1 = current_ring_node_f1; | |
291 | current_ring_node_f1 = current_ring_node_f1->next; |
|
291 | current_ring_node_f1 = current_ring_node_f1->next; | |
292 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
292 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; | |
293 | // (2) send an event for the waveforms transmission |
|
293 | // (2) send an event for the waveforms transmission | |
294 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { |
|
294 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { | |
295 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
295 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
296 | } |
|
296 | } | |
297 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 |
|
297 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 | |
298 | } |
|
298 | } | |
299 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
299 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit | |
300 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
300 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
301 | } |
|
301 | } | |
302 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
302 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit | |
303 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
303 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
304 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
304 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
305 | } |
|
305 | } | |
306 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 |
|
306 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 | |
307 | } |
|
307 | } | |
308 | break; |
|
308 | break; | |
309 |
|
309 | |||
310 | //***** |
|
310 | //***** | |
311 | // SBM2 |
|
311 | // SBM2 | |
312 | case(LFR_MODE_SBM2): |
|
312 | case(LFR_MODE_SBM2): | |
313 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
313 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit | |
314 | // (1) change the receiving buffer for the waveform picker |
|
314 | // (1) change the receiving buffer for the waveform picker | |
315 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
315 | ring_node_to_send_cwf_f2 = current_ring_node_f2; | |
316 | current_ring_node_f2 = current_ring_node_f2->next; |
|
316 | current_ring_node_f2 = current_ring_node_f2->next; | |
317 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
317 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; | |
318 | // (2) send an event for the waveforms transmission |
|
318 | // (2) send an event for the waveforms transmission | |
319 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { |
|
319 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { | |
320 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
320 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
321 | } |
|
321 | } | |
322 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
322 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 | |
323 | } |
|
323 | } | |
324 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
324 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit | |
325 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
325 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
326 | } |
|
326 | } | |
327 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
327 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit | |
328 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
328 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
329 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
329 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
330 | } |
|
330 | } | |
331 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 |
|
331 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 | |
332 | } |
|
332 | } | |
333 | break; |
|
333 | break; | |
334 |
|
334 | |||
335 | //******** |
|
335 | //******** | |
336 | // DEFAULT |
|
336 | // DEFAULT | |
337 | default: |
|
337 | default: | |
338 | break; |
|
338 | break; | |
339 | } |
|
339 | } | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
342 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
343 | { |
|
343 | { | |
344 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
344 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
345 | * |
|
345 | * | |
346 | * @param unused is the starting argument of the RTEMS task |
|
346 | * @param unused is the starting argument of the RTEMS task | |
347 | * |
|
347 | * | |
348 | * The following data packets are sent by this task: |
|
348 | * The following data packets are sent by this task: | |
349 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
349 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
350 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
350 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
351 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
351 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
352 | * |
|
352 | * | |
353 | */ |
|
353 | */ | |
354 |
|
354 | |||
355 | rtems_event_set event_out; |
|
355 | rtems_event_set event_out; | |
356 | rtems_id queue_id; |
|
356 | rtems_id queue_id; | |
357 | rtems_status_code status; |
|
357 | rtems_status_code status; | |
358 |
|
358 | |||
359 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
359 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); | |
360 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
360 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); | |
361 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
361 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); | |
362 |
|
362 | |||
363 | init_waveforms(); |
|
363 | init_waveforms(); | |
364 |
|
364 | |||
365 | status = get_message_queue_id_send( &queue_id ); |
|
365 | status = get_message_queue_id_send( &queue_id ); | |
366 | if (status != RTEMS_SUCCESSFUL) |
|
366 | if (status != RTEMS_SUCCESSFUL) | |
367 | { |
|
367 | { | |
368 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
368 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | BOOT_PRINTF("in WFRM ***\n") |
|
371 | BOOT_PRINTF("in WFRM ***\n") | |
372 |
|
372 | |||
373 | while(1){ |
|
373 | while(1){ | |
374 | // wait for an RTEMS_EVENT |
|
374 | // wait for an RTEMS_EVENT | |
375 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
375 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 | |
376 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM |
|
376 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM | |
377 | | RTEMS_EVENT_MODE_NORMAL_SWF_F0 |
|
377 | | RTEMS_EVENT_MODE_NORMAL_SWF_F0 | |
378 | | RTEMS_EVENT_MODE_NORMAL_SWF_F1 |
|
378 | | RTEMS_EVENT_MODE_NORMAL_SWF_F1 | |
379 | | RTEMS_EVENT_MODE_NORMAL_SWF_F2, |
|
379 | | RTEMS_EVENT_MODE_NORMAL_SWF_F2, | |
380 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
380 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
381 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
381 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
382 | { |
|
382 | { | |
383 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
383 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); | |
384 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
384 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); | |
385 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
385 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); | |
386 | } |
|
386 | } | |
387 | if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F0) == RTEMS_EVENT_MODE_NORMAL_SWF_F0) |
|
387 | if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F0) == RTEMS_EVENT_MODE_NORMAL_SWF_F0) | |
388 | { |
|
388 | { | |
389 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
389 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); | |
390 | } |
|
390 | } | |
391 | if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F1) == RTEMS_EVENT_MODE_NORMAL_SWF_F1) |
|
391 | if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F1) == RTEMS_EVENT_MODE_NORMAL_SWF_F1) | |
392 | { |
|
392 | { | |
393 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
393 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); | |
394 | } |
|
394 | } | |
395 | if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F2) == RTEMS_EVENT_MODE_NORMAL_SWF_F2) |
|
395 | if ( (event_out & RTEMS_EVENT_MODE_NORMAL_SWF_F2) == RTEMS_EVENT_MODE_NORMAL_SWF_F2) | |
396 | { |
|
396 | { | |
397 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
397 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); | |
398 | } |
|
398 | } | |
399 | } |
|
399 | } | |
400 | } |
|
400 | } | |
401 |
|
401 | |||
402 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
402 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
403 | { |
|
403 | { | |
404 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
404 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
405 | * |
|
405 | * | |
406 | * @param unused is the starting argument of the RTEMS task |
|
406 | * @param unused is the starting argument of the RTEMS task | |
407 | * |
|
407 | * | |
408 | * The following data packet is sent by this task: |
|
408 | * The following data packet is sent by this task: | |
409 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
409 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
410 | * |
|
410 | * | |
411 | */ |
|
411 | */ | |
412 |
|
412 | |||
413 | rtems_event_set event_out; |
|
413 | rtems_event_set event_out; | |
414 | rtems_id queue_id; |
|
414 | rtems_id queue_id; | |
415 | rtems_status_code status; |
|
415 | rtems_status_code status; | |
416 |
|
416 | |||
417 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); |
|
417 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); | |
418 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); |
|
418 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); | |
419 |
|
419 | |||
420 | status = get_message_queue_id_send( &queue_id ); |
|
420 | status = get_message_queue_id_send( &queue_id ); | |
421 | if (status != RTEMS_SUCCESSFUL) |
|
421 | if (status != RTEMS_SUCCESSFUL) | |
422 | { |
|
422 | { | |
423 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
423 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
424 | } |
|
424 | } | |
425 |
|
425 | |||
426 | BOOT_PRINTF("in CWF3 ***\n") |
|
426 | BOOT_PRINTF("in CWF3 ***\n") | |
427 |
|
427 | |||
428 | while(1){ |
|
428 | while(1){ | |
429 | // wait for an RTEMS_EVENT |
|
429 | // wait for an RTEMS_EVENT | |
430 | rtems_event_receive( RTEMS_EVENT_0, |
|
430 | rtems_event_receive( RTEMS_EVENT_0, | |
431 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
431 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
432 | PRINTF("send CWF F3 \n") |
|
432 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
|
433 | { | |||
|
434 | PRINTF("send CWF_LONG_F3\n") | |||
|
435 | } | |||
|
436 | else | |||
|
437 | { | |||
|
438 | PRINTF("send CWF_F3 (light)\n") | |||
|
439 | } | |||
433 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
440 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { | |
434 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
441 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
435 | { |
|
442 | { | |
436 | send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
443 | send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); | |
437 | } |
|
444 | } | |
438 | else |
|
445 | else | |
439 | { |
|
446 | { | |
440 | send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id ); |
|
447 | send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id ); | |
441 | } |
|
448 | } | |
442 | } |
|
449 | } | |
443 | else |
|
450 | else | |
444 | { |
|
451 | { | |
445 |
if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x0 |
|
452 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
446 | { |
|
453 | { | |
447 | send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
454 | send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); | |
448 | } |
|
455 | } | |
449 | else |
|
456 | else | |
450 | { |
|
457 | { | |
451 | send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id ); |
|
458 | send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id ); | |
452 | } |
|
459 | } | |
453 |
|
460 | |||
454 | } |
|
461 | } | |
455 | } |
|
462 | } | |
456 | } |
|
463 | } | |
457 |
|
464 | |||
458 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
465 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
459 | { |
|
466 | { | |
460 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
467 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
461 | * |
|
468 | * | |
462 | * @param unused is the starting argument of the RTEMS task |
|
469 | * @param unused is the starting argument of the RTEMS task | |
463 | * |
|
470 | * | |
464 | * The following data packet is sent by this function: |
|
471 | * The following data packet is sent by this function: | |
465 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
472 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
466 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
473 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
467 | * |
|
474 | * | |
468 | */ |
|
475 | */ | |
469 |
|
476 | |||
470 | rtems_event_set event_out; |
|
477 | rtems_event_set event_out; | |
471 | rtems_id queue_id; |
|
478 | rtems_id queue_id; | |
472 | rtems_status_code status; |
|
479 | rtems_status_code status; | |
473 |
|
480 | |||
474 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
481 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); | |
475 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
482 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); | |
476 |
|
483 | |||
477 | status = get_message_queue_id_send( &queue_id ); |
|
484 | status = get_message_queue_id_send( &queue_id ); | |
478 | if (status != RTEMS_SUCCESSFUL) |
|
485 | if (status != RTEMS_SUCCESSFUL) | |
479 | { |
|
486 | { | |
480 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
487 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
481 | } |
|
488 | } | |
482 |
|
489 | |||
483 | BOOT_PRINTF("in CWF2 ***\n") |
|
490 | BOOT_PRINTF("in CWF2 ***\n") | |
484 |
|
491 | |||
485 | while(1){ |
|
492 | while(1){ | |
486 | // wait for an RTEMS_EVENT |
|
493 | // wait for an RTEMS_EVENT | |
487 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
494 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, | |
488 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
495 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
489 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
496 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
490 | { |
|
497 | { | |
491 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
498 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); | |
492 | } |
|
499 | } | |
493 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
500 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
494 | { |
|
501 | { | |
495 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
502 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); | |
496 | } |
|
503 | } | |
497 | } |
|
504 | } | |
498 | } |
|
505 | } | |
499 |
|
506 | |||
500 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
507 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
501 | { |
|
508 | { | |
502 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
509 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
503 | * |
|
510 | * | |
504 | * @param unused is the starting argument of the RTEMS task |
|
511 | * @param unused is the starting argument of the RTEMS task | |
505 | * |
|
512 | * | |
506 | * The following data packet is sent by this function: |
|
513 | * The following data packet is sent by this function: | |
507 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
514 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
508 | * |
|
515 | * | |
509 | */ |
|
516 | */ | |
510 |
|
517 | |||
511 | rtems_event_set event_out; |
|
518 | rtems_event_set event_out; | |
512 | rtems_id queue_id; |
|
519 | rtems_id queue_id; | |
513 | rtems_status_code status; |
|
520 | rtems_status_code status; | |
514 |
|
521 | |||
515 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
522 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); | |
516 |
|
523 | |||
517 | status = get_message_queue_id_send( &queue_id ); |
|
524 | status = get_message_queue_id_send( &queue_id ); | |
518 | if (status != RTEMS_SUCCESSFUL) |
|
525 | if (status != RTEMS_SUCCESSFUL) | |
519 | { |
|
526 | { | |
520 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
527 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
521 | } |
|
528 | } | |
522 |
|
529 | |||
523 | BOOT_PRINTF("in CWF1 ***\n") |
|
530 | BOOT_PRINTF("in CWF1 ***\n") | |
524 |
|
531 | |||
525 | while(1){ |
|
532 | while(1){ | |
526 | // wait for an RTEMS_EVENT |
|
533 | // wait for an RTEMS_EVENT | |
527 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
534 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, | |
528 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
535 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
529 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
536 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); | |
530 | } |
|
537 | } | |
531 | } |
|
538 | } | |
532 |
|
539 | |||
533 | //****************** |
|
540 | //****************** | |
534 | // general functions |
|
541 | // general functions | |
535 | void init_waveforms( void ) |
|
542 | void init_waveforms( void ) | |
536 | { |
|
543 | { | |
537 | int i = 0; |
|
544 | int i = 0; | |
538 |
|
545 | |||
539 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
546 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
540 | { |
|
547 | { | |
541 | //*** |
|
548 | //*** | |
542 | // F0 |
|
549 | // F0 | |
543 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // |
|
550 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // | |
544 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // |
|
551 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // | |
545 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // |
|
552 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // | |
546 |
|
553 | |||
547 | //*** |
|
554 | //*** | |
548 | // F1 |
|
555 | // F1 | |
549 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; |
|
556 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; | |
550 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; |
|
557 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; | |
551 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
558 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; | |
552 |
|
559 | |||
553 | //*** |
|
560 | //*** | |
554 | // F2 |
|
561 | // F2 | |
555 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; |
|
562 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; | |
556 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; |
|
563 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; | |
557 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
564 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; | |
558 |
|
565 | |||
559 | //*** |
|
566 | //*** | |
560 | // F3 |
|
567 | // F3 | |
561 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; |
|
568 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; | |
562 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; |
|
569 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; | |
563 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; |
|
570 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; | |
564 | } |
|
571 | } | |
565 | } |
|
572 | } | |
566 |
|
573 | |||
567 | void init_waveform_rings( void ) |
|
574 | void init_waveform_rings( void ) | |
568 | { |
|
575 | { | |
569 | unsigned char i; |
|
576 | unsigned char i; | |
570 |
|
577 | |||
571 | // F0 RING |
|
578 | // F0 RING | |
572 | waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1]; |
|
579 | waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1]; | |
573 | waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1]; |
|
580 | waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1]; | |
574 | waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0]; |
|
581 | waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0]; | |
575 |
|
582 | |||
576 | waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0]; |
|
583 | waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0]; | |
577 | waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2]; |
|
584 | waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2]; | |
578 | waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0]; |
|
585 | waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0]; | |
579 |
|
586 | |||
580 | for(i=1; i<NB_RING_NODES_F0-1; i++) |
|
587 | for(i=1; i<NB_RING_NODES_F0-1; i++) | |
581 | { |
|
588 | { | |
582 | waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1]; |
|
589 | waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1]; | |
583 | waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1]; |
|
590 | waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1]; | |
584 | waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0]; |
|
591 | waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0]; | |
585 | } |
|
592 | } | |
586 |
|
593 | |||
587 | // F1 RING |
|
594 | // F1 RING | |
588 | waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1]; |
|
595 | waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1]; | |
589 | waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1]; |
|
596 | waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1]; | |
590 | waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0]; |
|
597 | waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0]; | |
591 |
|
598 | |||
592 | waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0]; |
|
599 | waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0]; | |
593 | waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2]; |
|
600 | waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2]; | |
594 | waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0]; |
|
601 | waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0]; | |
595 |
|
602 | |||
596 | for(i=1; i<NB_RING_NODES_F1-1; i++) |
|
603 | for(i=1; i<NB_RING_NODES_F1-1; i++) | |
597 | { |
|
604 | { | |
598 | waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1]; |
|
605 | waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1]; | |
599 | waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1]; |
|
606 | waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1]; | |
600 | waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0]; |
|
607 | waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0]; | |
601 | } |
|
608 | } | |
602 |
|
609 | |||
603 | // F2 RING |
|
610 | // F2 RING | |
604 | waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1]; |
|
611 | waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1]; | |
605 | waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1]; |
|
612 | waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1]; | |
606 | waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0]; |
|
613 | waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0]; | |
607 |
|
614 | |||
608 | waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0]; |
|
615 | waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0]; | |
609 | waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2]; |
|
616 | waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2]; | |
610 | waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0]; |
|
617 | waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0]; | |
611 |
|
618 | |||
612 | for(i=1; i<NB_RING_NODES_F2-1; i++) |
|
619 | for(i=1; i<NB_RING_NODES_F2-1; i++) | |
613 | { |
|
620 | { | |
614 | waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1]; |
|
621 | waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1]; | |
615 | waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1]; |
|
622 | waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1]; | |
616 | waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0]; |
|
623 | waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0]; | |
617 | } |
|
624 | } | |
618 |
|
625 | |||
619 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
626 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
620 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
627 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
621 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
628 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
622 |
|
629 | |||
623 | } |
|
630 | } | |
624 |
|
631 | |||
625 | void reset_current_ring_nodes( void ) |
|
632 | void reset_current_ring_nodes( void ) | |
626 | { |
|
633 | { | |
627 | current_ring_node_f0 = waveform_ring_f0; |
|
634 | current_ring_node_f0 = waveform_ring_f0; | |
628 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
635 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
629 |
|
636 | |||
630 | current_ring_node_f1 = waveform_ring_f1; |
|
637 | current_ring_node_f1 = waveform_ring_f1; | |
631 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
638 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
632 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
639 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
633 |
|
640 | |||
634 | current_ring_node_f2 = waveform_ring_f2; |
|
641 | current_ring_node_f2 = waveform_ring_f2; | |
635 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
642 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
636 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
643 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
637 | } |
|
644 | } | |
638 |
|
645 | |||
639 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
646 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) | |
640 | { |
|
647 | { | |
641 | unsigned char i; |
|
648 | unsigned char i; | |
642 |
|
649 | |||
643 | for (i=0; i<7; i++) |
|
650 | for (i=0; i<7; i++) | |
644 | { |
|
651 | { | |
645 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
652 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; | |
646 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
653 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
647 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
654 | headerSWF[ i ].reserved = DEFAULT_RESERVED; | |
648 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
655 | headerSWF[ i ].userApplication = CCSDS_USER_APP; | |
649 | headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
656 | headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
650 | headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
657 | headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
651 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
658 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
652 | if (i == 6) |
|
659 | if (i == 6) | |
653 | { |
|
660 | { | |
654 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
661 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
655 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
662 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
656 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
663 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
657 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
664 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
658 | } |
|
665 | } | |
659 | else |
|
666 | else | |
660 | { |
|
667 | { | |
661 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
668 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
662 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
669 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
663 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
670 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
664 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
671 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
665 | } |
|
672 | } | |
666 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
673 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
667 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
674 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
668 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
675 | headerSWF[ i ].pktNr = i+1; // PKT_NR | |
669 | // DATA FIELD HEADER |
|
676 | // DATA FIELD HEADER | |
670 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
677 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
671 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
678 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
672 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
679 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
673 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
680 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; | |
674 | // AUXILIARY DATA HEADER |
|
681 | // AUXILIARY DATA HEADER | |
675 | headerSWF[ i ].time[0] = 0x00; |
|
682 | headerSWF[ i ].time[0] = 0x00; | |
676 | headerSWF[ i ].time[0] = 0x00; |
|
683 | headerSWF[ i ].time[0] = 0x00; | |
677 | headerSWF[ i ].time[0] = 0x00; |
|
684 | headerSWF[ i ].time[0] = 0x00; | |
678 | headerSWF[ i ].time[0] = 0x00; |
|
685 | headerSWF[ i ].time[0] = 0x00; | |
679 | headerSWF[ i ].time[0] = 0x00; |
|
686 | headerSWF[ i ].time[0] = 0x00; | |
680 | headerSWF[ i ].time[0] = 0x00; |
|
687 | headerSWF[ i ].time[0] = 0x00; | |
681 | headerSWF[ i ].sid = sid; |
|
688 | headerSWF[ i ].sid = sid; | |
682 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
689 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; | |
683 | } |
|
690 | } | |
684 | return LFR_SUCCESSFUL; |
|
691 | return LFR_SUCCESSFUL; | |
685 | } |
|
692 | } | |
686 |
|
693 | |||
687 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
694 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) | |
688 | { |
|
695 | { | |
689 | unsigned int i; |
|
696 | unsigned int i; | |
690 |
|
697 | |||
691 |
for (i=0; i< |
|
698 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) | |
692 | { |
|
699 | { | |
693 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
700 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; | |
694 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
701 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
695 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
702 | headerCWF[ i ].reserved = DEFAULT_RESERVED; | |
696 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
703 | headerCWF[ i ].userApplication = CCSDS_USER_APP; | |
697 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
704 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
698 | { |
|
705 | { | |
699 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); |
|
706 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); | |
700 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); |
|
707 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); | |
701 | } |
|
708 | } | |
702 | else |
|
709 | else | |
703 | { |
|
710 | { | |
704 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
711 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
705 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
712 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
706 | } |
|
713 | } | |
707 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
714 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
708 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
715 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
709 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
716 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
710 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
717 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
711 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
718 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
712 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
719 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
713 | // DATA FIELD HEADER |
|
720 | // DATA FIELD HEADER | |
714 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
721 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
715 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
722 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
716 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
723 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
717 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
724 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; | |
718 | // AUXILIARY DATA HEADER |
|
725 | // AUXILIARY DATA HEADER | |
719 | headerCWF[ i ].sid = sid; |
|
726 | headerCWF[ i ].sid = sid; | |
720 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
727 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; | |
721 | headerCWF[ i ].time[0] = 0x00; |
|
728 | headerCWF[ i ].time[0] = 0x00; | |
722 | headerCWF[ i ].time[0] = 0x00; |
|
729 | headerCWF[ i ].time[0] = 0x00; | |
723 | headerCWF[ i ].time[0] = 0x00; |
|
730 | headerCWF[ i ].time[0] = 0x00; | |
724 | headerCWF[ i ].time[0] = 0x00; |
|
731 | headerCWF[ i ].time[0] = 0x00; | |
725 | headerCWF[ i ].time[0] = 0x00; |
|
732 | headerCWF[ i ].time[0] = 0x00; | |
726 | headerCWF[ i ].time[0] = 0x00; |
|
733 | headerCWF[ i ].time[0] = 0x00; | |
727 | } |
|
734 | } | |
728 | return LFR_SUCCESSFUL; |
|
735 | return LFR_SUCCESSFUL; | |
729 | } |
|
736 | } | |
730 |
|
737 | |||
731 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
738 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) | |
732 | { |
|
739 | { | |
733 | unsigned int i; |
|
740 | unsigned int i; | |
734 |
|
741 | |||
735 | for (i=0; i<7; i++) |
|
742 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) | |
736 | { |
|
743 | { | |
737 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
744 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; | |
738 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
745 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
739 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
746 | headerCWF[ i ].reserved = DEFAULT_RESERVED; | |
740 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
747 | headerCWF[ i ].userApplication = CCSDS_USER_APP; | |
741 |
|
748 | |||
742 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
749 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
743 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
750 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
744 |
|
751 | |||
745 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
752 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
746 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
753 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
747 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
754 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
748 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
755 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
749 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
756 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
750 |
|
757 | |||
751 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
758 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
752 | // DATA FIELD HEADER |
|
759 | // DATA FIELD HEADER | |
753 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
760 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
754 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
761 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
755 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
762 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
756 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
763 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; | |
757 | // AUXILIARY DATA HEADER |
|
764 | // AUXILIARY DATA HEADER | |
758 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
765 | headerCWF[ i ].sid = SID_NORM_CWF_F3; | |
759 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
766 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; | |
760 | headerCWF[ i ].time[0] = 0x00; |
|
767 | headerCWF[ i ].time[0] = 0x00; | |
761 | headerCWF[ i ].time[0] = 0x00; |
|
768 | headerCWF[ i ].time[0] = 0x00; | |
762 | headerCWF[ i ].time[0] = 0x00; |
|
769 | headerCWF[ i ].time[0] = 0x00; | |
763 | headerCWF[ i ].time[0] = 0x00; |
|
770 | headerCWF[ i ].time[0] = 0x00; | |
764 | headerCWF[ i ].time[0] = 0x00; |
|
771 | headerCWF[ i ].time[0] = 0x00; | |
765 | headerCWF[ i ].time[0] = 0x00; |
|
772 | headerCWF[ i ].time[0] = 0x00; | |
766 | } |
|
773 | } | |
767 | return LFR_SUCCESSFUL; |
|
774 | return LFR_SUCCESSFUL; | |
768 | } |
|
775 | } | |
769 |
|
776 | |||
770 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
777 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, | |
771 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
778 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) | |
772 | { |
|
779 | { | |
773 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
780 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
774 | * |
|
781 | * | |
775 | * @param waveform points to the buffer containing the data that will be send. |
|
782 | * @param waveform points to the buffer containing the data that will be send. | |
776 | * @param sid is the source identifier of the data that will be sent. |
|
783 | * @param sid is the source identifier of the data that will be sent. | |
777 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
784 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
778 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
785 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
779 | * contain information to setup the transmission of the data packets. |
|
786 | * contain information to setup the transmission of the data packets. | |
780 | * |
|
787 | * | |
781 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
788 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
782 | * |
|
789 | * | |
783 | */ |
|
790 | */ | |
784 |
|
791 | |||
785 | unsigned int i; |
|
792 | unsigned int i; | |
786 | int ret; |
|
793 | int ret; | |
787 | unsigned int coarseTime; |
|
794 | unsigned int coarseTime; | |
788 | unsigned int fineTime; |
|
795 | unsigned int fineTime; | |
789 | rtems_status_code status; |
|
796 | rtems_status_code status; | |
790 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
797 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
791 |
|
798 | |||
792 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
799 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header | |
793 | spw_ioctl_send_SWF.options = 0; |
|
800 | spw_ioctl_send_SWF.options = 0; | |
794 |
|
801 | |||
795 | ret = LFR_DEFAULT; |
|
802 | ret = LFR_DEFAULT; | |
796 |
|
803 | |||
797 | PRINTF1("sid = %d, ", sid) |
|
804 | DEBUG_PRINTF1("sid = %d, ", sid) | |
798 | PRINTF2("coarse = %x, fine = %x\n", waveform[0], waveform[1]) |
|
805 | DEBUG_PRINTF2("coarse = %x, fine = %x\n", waveform[0], waveform[1]) | |
|
806 | ||||
|
807 | coarseTime = waveform[0]; | |||
|
808 | fineTime = waveform[1]; | |||
799 |
|
809 | |||
800 | for (i=0; i<7; i++) // send waveform |
|
810 | for (i=0; i<7; i++) // send waveform | |
801 | { |
|
811 | { | |
802 | #ifdef VHDL_DEV |
|
|||
803 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
812 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; | |
804 | #else |
|
|||
805 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
|||
806 | #endif |
|
|||
807 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
813 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; | |
808 | // BUILD THE DATA |
|
814 | // BUILD THE DATA | |
809 | if (i==6) { |
|
815 | if (i==6) { | |
810 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
816 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
811 | } |
|
817 | } | |
812 | else { |
|
818 | else { | |
813 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
819 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
814 | } |
|
820 | } | |
815 | // SET PACKET SEQUENCE COUNTER |
|
821 | // SET PACKET SEQUENCE COUNTER | |
816 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
822 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); | |
817 | // SET PACKET TIME |
|
823 | // SET PACKET TIME | |
818 | #ifdef VHDL_DEV |
|
824 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); | |
819 | coarseTime = waveform[0]; |
|
825 | // | |
820 | fineTime = waveform[1]; |
|
|||
821 | compute_acquisition_time( &coarseTime, &fineTime, sid, i); |
|
|||
822 |
|
||||
823 | headerSWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime >> 24 ); |
|
|||
824 | headerSWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime >> 16 ); |
|
|||
825 | headerSWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime >> 8 ); |
|
|||
826 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime ); |
|
|||
827 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime >> 8 ); |
|
|||
828 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime ); |
|
|||
829 | #else |
|
|||
830 | headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
|||
831 | headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
|||
832 | headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
|||
833 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
|||
834 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
|||
835 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
|||
836 | #endif |
|
|||
837 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
826 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
838 | headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
827 | headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
839 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
828 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
840 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
829 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); | |
841 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
830 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
842 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
831 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); | |
843 | // SEND PACKET |
|
832 | // SEND PACKET | |
844 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
833 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); | |
845 | if (status != RTEMS_SUCCESSFUL) { |
|
834 | if (status != RTEMS_SUCCESSFUL) { | |
846 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
835 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
847 | ret = LFR_DEFAULT; |
|
836 | ret = LFR_DEFAULT; | |
848 | } |
|
837 | } | |
849 |
|
|
838 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds | |
850 | } |
|
839 | } | |
851 |
|
840 | |||
852 | return ret; |
|
841 | return ret; | |
853 | } |
|
842 | } | |
854 |
|
843 | |||
855 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
844 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, | |
856 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
845 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) | |
857 | { |
|
846 | { | |
858 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
847 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
859 | * |
|
848 | * | |
860 | * @param waveform points to the buffer containing the data that will be send. |
|
849 | * @param waveform points to the buffer containing the data that will be send. | |
861 | * @param sid is the source identifier of the data that will be sent. |
|
850 | * @param sid is the source identifier of the data that will be sent. | |
862 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
851 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
863 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
852 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
864 | * contain information to setup the transmission of the data packets. |
|
853 | * contain information to setup the transmission of the data packets. | |
865 | * |
|
854 | * | |
866 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
855 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
867 | * |
|
856 | * | |
868 | */ |
|
857 | */ | |
869 |
|
858 | |||
870 | unsigned int i; |
|
859 | unsigned int i; | |
871 | int ret; |
|
860 | int ret; | |
872 |
unsigned |
|
861 | unsigned int coarseTime; | |
873 |
unsigned |
|
862 | unsigned int fineTime; | |
874 | rtems_status_code status; |
|
863 | rtems_status_code status; | |
875 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
864 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
876 |
|
865 | |||
877 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
866 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header | |
878 | spw_ioctl_send_CWF.options = 0; |
|
867 | spw_ioctl_send_CWF.options = 0; | |
879 |
|
868 | |||
880 | ret = LFR_DEFAULT; |
|
869 | ret = LFR_DEFAULT; | |
881 |
|
870 | |||
882 | for (i=0; i<7; i++) // send waveform |
|
871 | coarseTime = waveform[0]; | |
|
872 | fineTime = waveform[1]; | |||
|
873 | ||||
|
874 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |||
883 | { |
|
875 | { | |
884 | int coarseTime = 0x00; |
|
|||
885 | int fineTime = 0x00; |
|
|||
886 | #ifdef VHDL_DEV |
|
|||
887 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
876 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; | |
888 | #else |
|
|||
889 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
|||
890 | #endif |
|
|||
891 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
877 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; | |
892 | // BUILD THE DATA |
|
878 | // BUILD THE DATA | |
893 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
879 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
894 | // SET PACKET SEQUENCE COUNTER |
|
880 | // SET PACKET SEQUENCE COUNTER | |
895 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
881 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); | |
896 | // SET PACKET TIME |
|
882 | // SET PACKET TIME | |
897 | #ifdef VHDL_DEV |
|
883 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); | |
898 | coarseTimePtr = (unsigned char *) &waveform; |
|
884 | // | |
899 | fineTimePtr = (unsigned char *) &waveform[1]; |
|
885 | headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
900 | headerCWF[ i ].acquisitionTime[0] = coarseTimePtr[2]; |
|
886 | headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
901 | headerCWF[ i ].acquisitionTime[1] = coarseTimePtr[3]; |
|
887 | headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
902 | headerCWF[ i ].acquisitionTime[2] = coarseTimePtr[0]; |
|
888 | headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); | |
903 | headerCWF[ i ].acquisitionTime[3] = coarseTimePtr[1]; |
|
889 | headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
904 | headerCWF[ i ].acquisitionTime[4] = fineTimePtr[0]; |
|
890 | headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); | |
905 | headerCWF[ i ].acquisitionTime[5] = fineTimePtr[1]; |
|
|||
906 | #else |
|
|||
907 | coarseTime = time_management_regs->coarse_time; |
|
|||
908 | fineTime = time_management_regs->fine_time; |
|
|||
909 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
|||
910 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
|||
911 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
|||
912 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
|||
913 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
|||
914 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
|||
915 | #endif |
|
|||
916 |
|
||||
917 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
|||
918 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
|||
919 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
|||
920 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
|||
921 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
|||
922 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
|||
923 | // SEND PACKET |
|
891 | // SEND PACKET | |
924 | if (sid == SID_NORM_CWF_LONG_F3) |
|
892 | if (sid == SID_NORM_CWF_LONG_F3) | |
925 | { |
|
893 | { | |
926 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
894 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
927 | if (status != RTEMS_SUCCESSFUL) { |
|
895 | if (status != RTEMS_SUCCESSFUL) { | |
928 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
896 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
929 | ret = LFR_DEFAULT; |
|
897 | ret = LFR_DEFAULT; | |
930 | } |
|
898 | } | |
931 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
899 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); | |
932 | } |
|
900 | } | |
933 | else |
|
901 | else | |
934 | { |
|
902 | { | |
935 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
903 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
936 | if (status != RTEMS_SUCCESSFUL) { |
|
904 | if (status != RTEMS_SUCCESSFUL) { | |
937 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
905 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
938 | ret = LFR_DEFAULT; |
|
906 | ret = LFR_DEFAULT; | |
939 | } |
|
907 | } | |
940 | } |
|
908 | } | |
941 | } |
|
909 | } | |
942 |
|
910 | |||
943 | return ret; |
|
911 | return ret; | |
944 | } |
|
912 | } | |
945 |
|
913 | |||
946 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
914 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) | |
947 | { |
|
915 | { | |
948 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
916 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
949 | * |
|
917 | * | |
950 | * @param waveform points to the buffer containing the data that will be send. |
|
918 | * @param waveform points to the buffer containing the data that will be send. | |
951 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
919 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
952 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
920 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
953 | * contain information to setup the transmission of the data packets. |
|
921 | * contain information to setup the transmission of the data packets. | |
954 | * |
|
922 | * | |
955 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
923 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
956 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
924 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
957 | * |
|
925 | * | |
958 | */ |
|
926 | */ | |
959 |
|
927 | |||
960 | unsigned int i; |
|
928 | unsigned int i; | |
961 | int ret; |
|
929 | int ret; | |
962 |
unsigned |
|
930 | unsigned int coarseTime; | |
963 |
unsigned |
|
931 | unsigned int fineTime; | |
964 | rtems_status_code status; |
|
932 | rtems_status_code status; | |
965 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
933 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
966 | char *sample; |
|
934 | char *sample; | |
967 |
|
935 | |||
968 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
936 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header | |
969 | spw_ioctl_send_CWF.options = 0; |
|
937 | spw_ioctl_send_CWF.options = 0; | |
970 |
|
938 | |||
971 | ret = LFR_DEFAULT; |
|
939 | ret = LFR_DEFAULT; | |
972 |
|
940 | |||
973 | //********************** |
|
941 | //********************** | |
974 | // BUILD CWF3_light DATA |
|
942 | // BUILD CWF3_light DATA | |
975 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
943 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
976 | { |
|
944 | { | |
977 | #ifdef VHDL_DEV |
|
|||
978 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
945 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; | |
979 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; |
|
946 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; | |
980 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; |
|
947 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; | |
981 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; |
|
948 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; | |
982 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; |
|
949 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; | |
983 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; |
|
950 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; | |
984 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; |
|
951 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; | |
985 | #else |
|
|||
986 | sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; |
|
|||
987 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
|||
988 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
|||
989 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
|||
990 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
|||
991 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
|||
992 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
|||
993 | #endif |
|
|||
994 |
|
|
952 | } | |
995 |
|
953 | |||
|
954 | coarseTime = waveform[0]; | |||
|
955 | fineTime = waveform[1]; | |||
|
956 | ||||
996 | //********************* |
|
957 | //********************* | |
997 | // SEND CWF3_light DATA |
|
958 | // SEND CWF3_light DATA | |
998 |
|
959 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | ||
999 | for (i=0; i<7; i++) // send waveform |
|
|||
1000 | { |
|
960 | { | |
1001 | int coarseTime = 0x00; |
|
|||
1002 | int fineTime = 0x00; |
|
|||
1003 |
|
||||
1004 | #ifdef VHDL_DEV |
|
|||
1005 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES]; |
|
961 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES]; | |
1006 | #else |
|
|||
1007 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
|||
1008 | #endif |
|
|||
1009 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
962 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; | |
1010 | // BUILD THE DATA |
|
963 | // BUILD THE DATA | |
1011 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
964 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1012 | // SET PACKET SEQUENCE COUNTER |
|
965 | // SET PACKET SEQUENCE COUNTER | |
1013 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
966 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); | |
1014 | // SET PACKET TIME |
|
967 | // SET PACKET TIME | |
1015 | #ifdef VHDL_DEV |
|
968 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); | |
1016 | coarseTimePtr = (unsigned char *) &waveform; |
|
969 | // | |
1017 | fineTimePtr = (unsigned char *) &waveform[1]; |
|
970 | headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1018 | headerCWF[ i ].acquisitionTime[0] = coarseTimePtr[2]; |
|
971 | headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1019 | headerCWF[ i ].acquisitionTime[1] = coarseTimePtr[3]; |
|
972 | headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1020 | headerCWF[ i ].acquisitionTime[2] = coarseTimePtr[0]; |
|
973 | headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); | |
1021 | headerCWF[ i ].acquisitionTime[3] = coarseTimePtr[1]; |
|
974 | headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1022 | headerCWF[ i ].acquisitionTime[4] = fineTimePtr[0]; |
|
975 | headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); | |
1023 | headerCWF[ i ].acquisitionTime[5] = fineTimePtr[1]; |
|
|||
1024 | #else |
|
|||
1025 | coarseTime = time_management_regs->coarse_time; |
|
|||
1026 | fineTime = time_management_regs->fine_time; |
|
|||
1027 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
|||
1028 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
|||
1029 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
|||
1030 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
|||
1031 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
|||
1032 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
|||
1033 | #endif |
|
|||
1034 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
|||
1035 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
|||
1036 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
|||
1037 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
|||
1038 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
|||
1039 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
|||
1040 | // SEND PACKET |
|
976 | // SEND PACKET | |
1041 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
977 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
1042 | if (status != RTEMS_SUCCESSFUL) { |
|
978 | if (status != RTEMS_SUCCESSFUL) { | |
1043 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
979 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); | |
1044 | ret = LFR_DEFAULT; |
|
980 | ret = LFR_DEFAULT; | |
1045 | } |
|
981 | } | |
1046 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
982 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); | |
1047 | } |
|
983 | } | |
1048 |
|
984 | |||
1049 | return ret; |
|
985 | return ret; | |
1050 | } |
|
986 | } | |
1051 |
|
987 | |||
1052 |
void compute_acquisition_time( unsigned int |
|
988 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
|
989 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |||
1053 | { |
|
990 | { | |
1054 | unsigned long long int acquisitionTimeAsLong; |
|
991 | unsigned long long int acquisitionTimeAsLong; | |
1055 | unsigned char acquisitionTime[6]; |
|
992 | unsigned char localAcquisitionTime[6]; | |
1056 |
|
|
993 | double deltaT = 0.; | |
1057 |
|
994 | |||
1058 |
acquisitionTime[0] = (unsigned char) ( |
|
995 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 ); | |
1059 |
acquisitionTime[1] = (unsigned char) ( |
|
996 | localAcquisitionTime[1] = (unsigned char) ( coarseTime ); | |
1060 |
acquisitionTime[2] = (unsigned char) ( |
|
997 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 ); | |
1061 |
acquisitionTime[3] = (unsigned char) ( |
|
998 | localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 ); | |
1062 |
acquisitionTime[4] = (unsigned char) ( |
|
999 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 ); | |
1063 |
acquisitionTime[5] = (unsigned char) ( |
|
1000 | localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 ); | |
1064 |
|
1001 | |||
1065 | acquisitionTimeAsLong = ( (unsigned long long int) acquisitionTime[0] << 40 ) |
|
1002 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) | |
1066 | + ( (unsigned long long int) acquisitionTime[1] << 32 ) |
|
1003 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) | |
1067 | + ( acquisitionTime[2] << 24 ) |
|
1004 | + ( localAcquisitionTime[2] << 24 ) | |
1068 | + ( acquisitionTime[3] << 16 ) |
|
1005 | + ( localAcquisitionTime[3] << 16 ) | |
1069 | + ( acquisitionTime[4] << 8 ) |
|
1006 | + ( localAcquisitionTime[4] << 8 ) | |
1070 | + ( acquisitionTime[5] ); |
|
1007 | + ( localAcquisitionTime[5] ); | |
1071 |
|
1008 | |||
1072 | switch( sid ) |
|
1009 | switch( sid ) | |
1073 | { |
|
1010 | { | |
1074 | case SID_NORM_SWF_F0: |
|
1011 | case SID_NORM_SWF_F0: | |
1075 |
|
|
1012 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; | |
1076 |
|
|
1013 | break; | |
1077 |
|
1014 | |||
1078 | case SID_NORM_SWF_F1: |
|
1015 | case SID_NORM_SWF_F1: | |
1079 |
|
|
1016 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; | |
1080 |
|
|
1017 | break; | |
|
1018 | ||||
|
1019 | case SID_SBM1_CWF_F1: | |||
|
1020 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; | |||
|
1021 | break; | |||
1081 |
|
1022 | |||
1082 | case SID_NORM_SWF_F2: |
|
1023 | case SID_NORM_SWF_F2: | |
1083 |
|
|
1024 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; | |
1084 |
|
|
1025 | break; | |
|
1026 | ||||
|
1027 | case SID_SBM2_CWF_F2: | |||
|
1028 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |||
|
1029 | break; | |||
|
1030 | ||||
|
1031 | case SID_NORM_CWF_F3: | |||
|
1032 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; | |||
|
1033 | break; | |||
|
1034 | ||||
|
1035 | case SID_NORM_CWF_LONG_F3: | |||
|
1036 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; | |||
|
1037 | break; | |||
1085 |
|
1038 | |||
1086 | default: |
|
1039 | default: | |
1087 | deltaT = 0.; |
|
1040 | deltaT = 0.; | |
1088 | break; |
|
1041 | break; | |
1089 | } |
|
1042 | } | |
1090 |
|
1043 | |||
1091 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
1044 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
1092 |
|
1045 | // | ||
1093 |
|
|
1046 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); | |
1094 |
|
|
1047 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); | |
|
1048 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); | |||
|
1049 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); | |||
|
1050 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); | |||
|
1051 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); | |||
1095 | } |
|
1052 | } | |
1096 |
|
1053 | |||
1097 | //************** |
|
1054 | //************** | |
1098 | // wfp registers |
|
1055 | // wfp registers | |
1099 | void reset_wfp_burst_enable(void) |
|
1056 | void reset_wfp_burst_enable(void) | |
1100 | { |
|
1057 | { | |
1101 | /** This function resets the waveform picker burst_enable register. |
|
1058 | /** This function resets the waveform picker burst_enable register. | |
1102 | * |
|
1059 | * | |
1103 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1060 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1104 | * |
|
1061 | * | |
1105 | */ |
|
1062 | */ | |
1106 |
|
1063 | |||
1107 | #ifdef VHDL_DEV |
|
|||
1108 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1064 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |
1109 | #else |
|
|||
1110 | waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
|||
1111 | #endif |
|
|||
1112 | } |
|
1065 | } | |
1113 |
|
1066 | |||
1114 | void reset_wfp_status( void ) |
|
1067 | void reset_wfp_status( void ) | |
1115 | { |
|
1068 | { | |
1116 | /** This function resets the waveform picker status register. |
|
1069 | /** This function resets the waveform picker status register. | |
1117 | * |
|
1070 | * | |
1118 | * All status bits are set to 0 [new_err full_err full]. |
|
1071 | * All status bits are set to 0 [new_err full_err full]. | |
1119 | * |
|
1072 | * | |
1120 | */ |
|
1073 | */ | |
1121 |
|
1074 | |||
1122 | #ifdef GSA |
|
|||
1123 | #else |
|
|||
1124 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1075 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |
1125 | #endif |
|
|||
1126 | } |
|
1076 | } | |
1127 |
|
1077 | |||
1128 | void reset_waveform_picker_regs(void) |
|
1078 | void reset_waveform_picker_regs(void) | |
1129 | { |
|
1079 | { | |
1130 | /** This function resets the waveform picker module registers. |
|
1080 | /** This function resets the waveform picker module registers. | |
1131 | * |
|
1081 | * | |
1132 | * The registers affected by this function are located at the following offset addresses: |
|
1082 | * The registers affected by this function are located at the following offset addresses: | |
1133 | * - 0x00 data_shaping |
|
1083 | * - 0x00 data_shaping | |
1134 | * - 0x04 run_burst_enable |
|
1084 | * - 0x04 run_burst_enable | |
1135 | * - 0x08 addr_data_f0 |
|
1085 | * - 0x08 addr_data_f0 | |
1136 | * - 0x0C addr_data_f1 |
|
1086 | * - 0x0C addr_data_f1 | |
1137 | * - 0x10 addr_data_f2 |
|
1087 | * - 0x10 addr_data_f2 | |
1138 | * - 0x14 addr_data_f3 |
|
1088 | * - 0x14 addr_data_f3 | |
1139 | * - 0x18 status |
|
1089 | * - 0x18 status | |
1140 | * - 0x1C delta_snapshot |
|
1090 | * - 0x1C delta_snapshot | |
1141 | * - 0x20 delta_f0 |
|
1091 | * - 0x20 delta_f0 | |
1142 | * - 0x24 delta_f0_2 |
|
1092 | * - 0x24 delta_f0_2 | |
1143 | * - 0x28 delta_f1 |
|
1093 | * - 0x28 delta_f1 | |
1144 | * - 0x2c delta_f2 |
|
1094 | * - 0x2c delta_f2 | |
1145 | * - 0x30 nb_data_by_buffer |
|
1095 | * - 0x30 nb_data_by_buffer | |
1146 | * - 0x34 nb_snapshot_param |
|
1096 | * - 0x34 nb_snapshot_param | |
1147 | * - 0x38 start_date |
|
1097 | * - 0x38 start_date | |
1148 | * - 0x3c nb_word_in_buffer |
|
1098 | * - 0x3c nb_word_in_buffer | |
1149 | * |
|
1099 | * | |
1150 | */ |
|
1100 | */ | |
1151 |
|
1101 | |||
1152 | waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW |
|
1102 | waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW | |
1153 | waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1103 | waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1154 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 |
|
1104 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 | |
1155 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c |
|
1105 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c | |
1156 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 |
|
1106 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 | |
1157 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14 |
|
1107 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14 | |
1158 | waveform_picker_regs->status = 0x00; // 0x18 |
|
1108 | waveform_picker_regs->status = 0x00; // 0x18 | |
1159 | // |
|
1109 | // | |
1160 | set_wfp_delta_snapshot(); // 0x1c |
|
1110 | set_wfp_delta_snapshot(); // 0x1c | |
1161 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1111 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1162 | set_wfp_delta_f1(); // 0x28 |
|
1112 | set_wfp_delta_f1(); // 0x28 | |
1163 | set_wfp_delta_f2(); // 0x2c |
|
1113 | set_wfp_delta_f2(); // 0x2c | |
1164 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1114 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) | |
1165 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1115 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) | |
1166 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1116 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) | |
1167 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1117 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) | |
1168 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1118 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) | |
1169 |
// 2 |
|
1119 | // 2688 = 8 * 336 | |
1170 |
waveform_picker_regs->nb_data_by_buffer = 0x |
|
1120 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 | |
1171 |
waveform_picker_regs->snapshot_param = 0x |
|
1121 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples | |
1172 | waveform_picker_regs->start_date = 0x00; // 0x38 |
|
1122 | waveform_picker_regs->start_date = 0x00; // 0x38 | |
1173 |
waveform_picker_regs->nb_word_in_buffer = 0x1 |
|
1123 | waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 | |
1174 | } |
|
1124 | } | |
1175 |
|
1125 | |||
1176 | void set_wfp_data_shaping( void ) |
|
1126 | void set_wfp_data_shaping( void ) | |
1177 | { |
|
1127 | { | |
1178 | /** This function sets the data_shaping register of the waveform picker module. |
|
1128 | /** This function sets the data_shaping register of the waveform picker module. | |
1179 | * |
|
1129 | * | |
1180 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1130 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1181 | * bw_sp0_sp1_r0_r1 |
|
1131 | * bw_sp0_sp1_r0_r1 | |
1182 | * |
|
1132 | * | |
1183 | */ |
|
1133 | */ | |
1184 |
|
1134 | |||
1185 | unsigned char data_shaping; |
|
1135 | unsigned char data_shaping; | |
1186 |
|
1136 | |||
1187 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1137 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1188 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1138 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1189 |
|
1139 | |||
1190 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
1140 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; | |
1191 |
|
1141 | |||
1192 | waveform_picker_regs->data_shaping = |
|
1142 | waveform_picker_regs->data_shaping = | |
1193 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
1143 | ( (data_shaping & 0x10) >> 4 ) // BW | |
1194 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
1144 | + ( (data_shaping & 0x08) >> 2 ) // SP0 | |
1195 | + ( (data_shaping & 0x04) ) // SP1 |
|
1145 | + ( (data_shaping & 0x04) ) // SP1 | |
1196 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
1146 | + ( (data_shaping & 0x02) << 2 ) // R0 | |
1197 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
1147 | + ( (data_shaping & 0x01) << 4 ); // R1 | |
1198 | } |
|
1148 | } | |
1199 |
|
1149 | |||
1200 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1150 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1201 | { |
|
1151 | { | |
1202 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1152 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1203 | * |
|
1153 | * | |
1204 | * @param mode is the LFR mode to launch. |
|
1154 | * @param mode is the LFR mode to launch. | |
1205 | * |
|
1155 | * | |
1206 | * The burst bits shall be before the enable bits. |
|
1156 | * The burst bits shall be before the enable bits. | |
1207 | * |
|
1157 | * | |
1208 | */ |
|
1158 | */ | |
1209 |
|
1159 | |||
1210 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1160 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1211 | // the burst bits shall be set first, before the enable bits |
|
1161 | // the burst bits shall be set first, before the enable bits | |
1212 | switch(mode) { |
|
1162 | switch(mode) { | |
1213 | case(LFR_MODE_NORMAL): |
|
1163 | case(LFR_MODE_NORMAL): | |
1214 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1164 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable | |
1215 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1165 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 | |
1216 | break; |
|
1166 | break; | |
1217 | case(LFR_MODE_BURST): |
|
1167 | case(LFR_MODE_BURST): | |
1218 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1168 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1219 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1169 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 | |
1220 | break; |
|
1170 | break; | |
1221 | case(LFR_MODE_SBM1): |
|
1171 | case(LFR_MODE_SBM1): | |
1222 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1172 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled | |
1223 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1173 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1224 | break; |
|
1174 | break; | |
1225 | case(LFR_MODE_SBM2): |
|
1175 | case(LFR_MODE_SBM2): | |
1226 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1176 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1227 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1177 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1228 | break; |
|
1178 | break; | |
1229 | default: |
|
1179 | default: | |
1230 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1180 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
1231 | break; |
|
1181 | break; | |
1232 | } |
|
1182 | } | |
1233 | } |
|
1183 | } | |
1234 |
|
1184 | |||
1235 | void set_wfp_delta_snapshot( void ) |
|
1185 | void set_wfp_delta_snapshot( void ) | |
1236 | { |
|
1186 | { | |
1237 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1187 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1238 | * |
|
1188 | * | |
1239 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1189 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1240 | * - sy_lfr_n_swf_p[0] |
|
1190 | * - sy_lfr_n_swf_p[0] | |
1241 | * - sy_lfr_n_swf_p[1] |
|
1191 | * - sy_lfr_n_swf_p[1] | |
1242 | * |
|
1192 | * | |
1243 | */ |
|
1193 | */ | |
1244 |
|
1194 | |||
1245 | unsigned int delta_snapshot; |
|
1195 | unsigned int delta_snapshot; | |
1246 | unsigned int delta_snapshot_in_T2; |
|
1196 | unsigned int delta_snapshot_in_T2; | |
1247 |
|
1197 | |||
1248 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1198 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
1249 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1199 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1250 |
|
1200 | |||
1251 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1201 | delta_snapshot_in_T2 = delta_snapshot * 256; | |
1252 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes |
|
1202 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes | |
1253 | } |
|
1203 | } | |
1254 |
|
1204 | |||
1255 | void set_wfp_delta_f0_f0_2( void ) |
|
1205 | void set_wfp_delta_f0_f0_2( void ) | |
1256 | { |
|
1206 | { | |
1257 | unsigned int delta_snapshot; |
|
1207 | unsigned int delta_snapshot; | |
1258 | unsigned int nb_samples_per_snapshot; |
|
1208 | unsigned int nb_samples_per_snapshot; | |
1259 | float delta_f0_in_float; |
|
1209 | float delta_f0_in_float; | |
1260 |
|
1210 | |||
1261 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1211 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1262 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1212 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1263 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1213 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; | |
1264 |
|
1214 | |||
1265 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1215 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1266 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits |
|
1216 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits | |
1267 | } |
|
1217 | } | |
1268 |
|
1218 | |||
1269 | void set_wfp_delta_f1( void ) |
|
1219 | void set_wfp_delta_f1( void ) | |
1270 | { |
|
1220 | { | |
1271 | unsigned int delta_snapshot; |
|
1221 | unsigned int delta_snapshot; | |
1272 | unsigned int nb_samples_per_snapshot; |
|
1222 | unsigned int nb_samples_per_snapshot; | |
1273 | float delta_f1_in_float; |
|
1223 | float delta_f1_in_float; | |
1274 |
|
1224 | |||
1275 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1225 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1276 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1226 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1277 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1227 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; | |
1278 |
|
1228 | |||
1279 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1229 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1280 | } |
|
1230 | } | |
1281 |
|
1231 | |||
1282 | void set_wfp_delta_f2() |
|
1232 | void set_wfp_delta_f2() | |
1283 | { |
|
1233 | { | |
1284 | unsigned int delta_snapshot; |
|
1234 | unsigned int delta_snapshot; | |
1285 | unsigned int nb_samples_per_snapshot; |
|
1235 | unsigned int nb_samples_per_snapshot; | |
1286 |
|
1236 | |||
1287 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1237 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1288 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1238 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1289 |
|
1239 | |||
1290 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1240 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; | |
1291 | } |
|
1241 | } | |
1292 |
|
1242 | |||
1293 | //***************** |
|
1243 | //***************** | |
1294 | // local parameters |
|
1244 | // local parameters | |
1295 | void set_local_nb_interrupt_f0_MAX( void ) |
|
1245 | void set_local_nb_interrupt_f0_MAX( void ) | |
1296 | { |
|
1246 | { | |
1297 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. |
|
1247 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. | |
1298 | * |
|
1248 | * | |
1299 | * This parameter is used for the SM validation only.\n |
|
1249 | * This parameter is used for the SM validation only.\n | |
1300 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices |
|
1250 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices | |
1301 | * module before launching a basic processing. |
|
1251 | * module before launching a basic processing. | |
1302 | * |
|
1252 | * | |
1303 | */ |
|
1253 | */ | |
1304 |
|
1254 | |||
1305 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 |
|
1255 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 | |
1306 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; |
|
1256 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; | |
1307 | } |
|
1257 | } | |
1308 |
|
1258 | |||
1309 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1259 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1310 | { |
|
1260 | { | |
1311 | unsigned short *sequence_cnt; |
|
1261 | unsigned short *sequence_cnt; | |
1312 | unsigned short segmentation_grouping_flag; |
|
1262 | unsigned short segmentation_grouping_flag; | |
1313 | unsigned short new_packet_sequence_control; |
|
1263 | unsigned short new_packet_sequence_control; | |
1314 |
|
1264 | |||
1315 | if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2) |
|
1265 | if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2) | |
1316 | || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) ) |
|
1266 | || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) ) | |
1317 | { |
|
1267 | { | |
1318 | sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1268 | sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1319 | } |
|
1269 | } | |
1320 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) ) |
|
1270 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) ) | |
1321 | { |
|
1271 | { | |
1322 | sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1272 | sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1323 | } |
|
1273 | } | |
1324 | else |
|
1274 | else | |
1325 | { |
|
1275 | { | |
1326 | sequence_cnt = NULL; |
|
1276 | sequence_cnt = NULL; | |
1327 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1277 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1328 | } |
|
1278 | } | |
1329 |
|
1279 | |||
1330 | if (sequence_cnt != NULL) |
|
1280 | if (sequence_cnt != NULL) | |
1331 | { |
|
1281 | { | |
1332 | segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8; |
|
1282 | segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8; | |
1333 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1283 | *sequence_cnt = (*sequence_cnt) & 0x3fff; | |
1334 |
|
1284 | |||
1335 | new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ; |
|
1285 | new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ; | |
1336 |
|
1286 | |||
1337 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1287 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1338 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1288 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1339 |
|
1289 | |||
1340 | // increment the sequence counter for the next packet |
|
1290 | // increment the sequence counter for the next packet | |
1341 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1291 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1342 | { |
|
1292 | { | |
1343 | *sequence_cnt = *sequence_cnt + 1; |
|
1293 | *sequence_cnt = *sequence_cnt + 1; | |
1344 | } |
|
1294 | } | |
1345 | else |
|
1295 | else | |
1346 | { |
|
1296 | { | |
1347 | *sequence_cnt = 0; |
|
1297 | *sequence_cnt = 0; | |
1348 | } |
|
1298 | } | |
1349 | } |
|
1299 | } | |
1350 | } |
|
1300 | } |
General Comments 0
You need to be logged in to leave comments.
Login now