##// END OF EJS Templates
waveform buffers declaration modified...
paul -
r131:4a63795e87ea VHDLib206
parent child
Show More
@@ -0,0 +1,70
1 #ifndef FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
3
4 #define NB_BINS_PER_SM 128
5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 //
12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 3
13 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
15 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
16 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
18 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
19 #define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3
20 #define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3
21 //
22 #define NB_BINS_PER_ASM_F0 88
23 #define NB_BINS_PER_PKT_ASM_F0 44
24 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
25 #define ASM_F0_INDICE_START 17 // 88 bins
26 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
27 //
28 #define NB_BINS_PER_ASM_F1 104
29 #define NB_BINS_PER_PKT_ASM_F1 52
30 #define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2
31 #define ASM_F1_INDICE_START 6 // 104 bins
32 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
33 //
34 #define NB_BINS_PER_ASM_F2 96
35 #define NB_BINS_PER_PKT_ASM_F2 48
36 #define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2
37 #define ASM_F2_INDICE_START 7 // 96 bins
38 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
39 //
40 #define NB_BINS_COMPRESSED_SM_F0 11
41 #define NB_BINS_COMPRESSED_SM_F1 13
42 #define NB_BINS_COMPRESSED_SM_F2 12
43 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
44 #define NB_BINS_COMPRESSED_SM_SBM_F1 26
45 #define NB_BINS_COMPRESSED_SM_SBM_F2 24
46 //
47 #define NB_BYTES_PER_BP1 9
48 //
49 #define NB_BINS_TO_AVERAGE_ASM_F0 8
50 #define NB_BINS_TO_AVERAGE_ASM_F1 8
51 #define NB_BINS_TO_AVERAGE_ASM_F2 8
52 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
53 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
54 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
55 //
56 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
57 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
58 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS
59 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
60 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
61 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS
62 #define TOTAL_SIZE_BP1_NORM_F0 99 // 9 * 11 UNSIGNED CHAR
63 #define TOTAL_SIZE_BP1_SBM_F0 198 // 9 * 22 UNSIGNED CHAR
64 // GENERAL
65 #define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function
66 #define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function
67 #define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function
68
69 #endif // FSW_PARAMS_PROCESSING_H
70
@@ -0,0 +1,8
1 #ifndef FSW_PARAMS_WF_HANDLER_H
2 #define FSW_PARAMS_WF_HANDLER_H
3
4 #define WFRM_BUFFER 8128 // (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62
5 // (2688 * 3 ) + 2 + 62 = 8128 = 0X1FC0
6 // 8128 * 4 = 32512 = 0x7F00
7
8 #endif // FSW_PARAMS_WF_HANDLER_H
@@ -1,268 +1,268
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue May 6 15:49:26 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue May 13 07:12:26 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=7 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/basic_parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_misc.c \
49 49 ../src/fsw_init.c \
50 50 ../src/fsw_globals.c \
51 51 ../src/fsw_spacewire.c \
52 52 ../src/tc_load_dump_parameters.c \
53 53 ../src/tm_lfr_tc_exe.c \
54 54 ../src/tc_acceptance.c \
55 55 ../src/basic_parameters/basic_parameters.c \
56 56 ../src/processing/fsw_processing.c \
57 57 ../src/processing/avf0_prc0.c \
58 58 ../src/processing/avf1_prc1.c \
59 59 ../src/processing/avf2_prc2.c
60 60 OBJECTS = obj/wf_handler.o \
61 61 obj/tc_handler.o \
62 62 obj/fsw_misc.o \
63 63 obj/fsw_init.o \
64 64 obj/fsw_globals.o \
65 65 obj/fsw_spacewire.o \
66 66 obj/tc_load_dump_parameters.o \
67 67 obj/tm_lfr_tc_exe.o \
68 68 obj/tc_acceptance.o \
69 69 obj/basic_parameters.o \
70 70 obj/fsw_processing.o \
71 71 obj/avf0_prc0.o \
72 72 obj/avf1_prc1.o \
73 73 obj/avf2_prc2.o
74 74 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
75 75 /usr/lib64/qt4/mkspecs/common/linux.conf \
76 76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
77 77 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
78 78 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/qconfig.pri \
81 81 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
82 82 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
83 83 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
84 84 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
85 85 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
86 86 sparc.pri \
87 87 /usr/lib64/qt4/mkspecs/features/release.prf \
88 88 /usr/lib64/qt4/mkspecs/features/default_post.prf \
89 89 /usr/lib64/qt4/mkspecs/features/shared.prf \
90 90 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
91 91 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
92 92 /usr/lib64/qt4/mkspecs/features/resources.prf \
93 93 /usr/lib64/qt4/mkspecs/features/uic.prf \
94 94 /usr/lib64/qt4/mkspecs/features/yacc.prf \
95 95 /usr/lib64/qt4/mkspecs/features/lex.prf \
96 96 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
97 97 fsw-qt.pro
98 98 QMAKE_TARGET = fsw
99 99 DESTDIR = bin/
100 100 TARGET = bin/fsw
101 101
102 102 first: all
103 103 ####### Implicit rules
104 104
105 105 .SUFFIXES: .o .c .cpp .cc .cxx .C
106 106
107 107 .cpp.o:
108 108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109 109
110 110 .cc.o:
111 111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112 112
113 113 .cxx.o:
114 114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
115 115
116 116 .C.o:
117 117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
118 118
119 119 .c.o:
120 120 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
121 121
122 122 ####### Build rules
123 123
124 124 all: Makefile $(TARGET)
125 125
126 126 $(TARGET): $(OBJECTS)
127 127 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
128 128 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
129 129
130 130 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
131 131 /usr/lib64/qt4/mkspecs/common/linux.conf \
132 132 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
133 133 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
134 134 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/qconfig.pri \
137 137 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
138 138 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
139 139 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
140 140 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
141 141 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
142 142 sparc.pri \
143 143 /usr/lib64/qt4/mkspecs/features/release.prf \
144 144 /usr/lib64/qt4/mkspecs/features/default_post.prf \
145 145 /usr/lib64/qt4/mkspecs/features/shared.prf \
146 146 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
147 147 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
148 148 /usr/lib64/qt4/mkspecs/features/resources.prf \
149 149 /usr/lib64/qt4/mkspecs/features/uic.prf \
150 150 /usr/lib64/qt4/mkspecs/features/yacc.prf \
151 151 /usr/lib64/qt4/mkspecs/features/lex.prf \
152 152 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
153 153 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
154 154 /usr/lib64/qt4/mkspecs/common/unix.conf:
155 155 /usr/lib64/qt4/mkspecs/common/linux.conf:
156 156 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
157 157 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
158 158 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/qconfig.pri:
161 161 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
162 162 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
163 163 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
164 164 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
165 165 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
166 166 sparc.pri:
167 167 /usr/lib64/qt4/mkspecs/features/release.prf:
168 168 /usr/lib64/qt4/mkspecs/features/default_post.prf:
169 169 /usr/lib64/qt4/mkspecs/features/shared.prf:
170 170 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
171 171 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
172 172 /usr/lib64/qt4/mkspecs/features/resources.prf:
173 173 /usr/lib64/qt4/mkspecs/features/uic.prf:
174 174 /usr/lib64/qt4/mkspecs/features/yacc.prf:
175 175 /usr/lib64/qt4/mkspecs/features/lex.prf:
176 176 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
177 177 qmake: FORCE
178 178 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
179 179
180 180 dist:
181 181 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
182 182 $(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
183 183
184 184
185 185 clean:compiler_clean
186 186 -$(DEL_FILE) $(OBJECTS)
187 187 -$(DEL_FILE) *~ core *.core
188 188
189 189
190 190 ####### Sub-libraries
191 191
192 192 distclean: clean
193 193 -$(DEL_FILE) $(TARGET)
194 194 -$(DEL_FILE) Makefile
195 195
196 196
197 197 grmon:
198 198 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
199 199
200 200 check: first
201 201
202 202 compiler_rcc_make_all:
203 203 compiler_rcc_clean:
204 204 compiler_uic_make_all:
205 205 compiler_uic_clean:
206 206 compiler_image_collection_make_all: qmake_image_collection.cpp
207 207 compiler_image_collection_clean:
208 208 -$(DEL_FILE) qmake_image_collection.cpp
209 209 compiler_yacc_decl_make_all:
210 210 compiler_yacc_decl_clean:
211 211 compiler_yacc_impl_make_all:
212 212 compiler_yacc_impl_clean:
213 213 compiler_lex_make_all:
214 214 compiler_lex_clean:
215 215 compiler_clean:
216 216
217 217 ####### Compile
218 218
219 219 obj/wf_handler.o: ../src/wf_handler.c
220 220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
221 221
222 222 obj/tc_handler.o: ../src/tc_handler.c
223 223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
224 224
225 225 obj/fsw_misc.o: ../src/fsw_misc.c
226 226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
227 227
228 228 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
229 229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
230 230
231 231 obj/fsw_globals.o: ../src/fsw_globals.c
232 232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
233 233
234 234 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
235 235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
236 236
237 237 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
238 238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
239 239
240 240 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
241 241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
242 242
243 243 obj/tc_acceptance.o: ../src/tc_acceptance.c
244 244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
245 245
246 246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
247 247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
248 248
249 249 obj/fsw_processing.o: ../src/processing/fsw_processing.c
250 250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
251 251
252 252 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
253 253 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
254 254
255 255 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
256 256 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
257 257
258 258 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
259 259 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
260 260
261 261 ####### Install
262 262
263 263 install: FORCE
264 264
265 265 uninstall: FORCE
266 266
267 267 FORCE:
268 268
@@ -1,91 +1,92
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 4 CONFIG += console verbose cpu_usage_report
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-1-0
11 11 DEFINES += SW_VERSION_N1=1 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 14 DEFINES += SW_VERSION_N4=7 # internal
15 15
16 16 contains( CONFIG, debug_tch ) {
17 17 DEFINES += DEBUG_TCH
18 18 }
19 19
20 20 contains( CONFIG, vhdl_dev ) {
21 21 DEFINES += VHDL_DEV
22 22 }
23 23
24 24 contains( CONFIG, verbose ) {
25 25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 26 }
27 27
28 28 contains( CONFIG, debug_messages ) {
29 29 DEFINES += DEBUG_MESSAGES
30 30 }
31 31
32 32 contains( CONFIG, cpu_usage_report ) {
33 33 DEFINES += PRINT_TASK_STATISTICS
34 34 }
35 35
36 36 contains( CONFIG, stack_report ) {
37 37 DEFINES += PRINT_STACK_REPORT
38 38 }
39 39
40 40 contains( CONFIG, boot_messages ) {
41 41 DEFINES += BOOT_MESSAGES
42 42 }
43 43
44 44 #doxygen.target = doxygen
45 45 #doxygen.commands = doxygen ../doc/Doxyfile
46 46 #QMAKE_EXTRA_TARGETS += doxygen
47 47
48 48 TARGET = fsw
49 49
50 50 INCLUDEPATH += \
51 51 ../src \
52 52 ../header \
53 53 ../header/processing \
54 54 ../src/basic_parameters
55 55
56 56 SOURCES += \
57 57 ../src/wf_handler.c \
58 58 ../src/tc_handler.c \
59 59 ../src/fsw_misc.c \
60 60 ../src/fsw_init.c \
61 61 ../src/fsw_globals.c \
62 62 ../src/fsw_spacewire.c \
63 63 ../src/tc_load_dump_parameters.c \
64 64 ../src/tm_lfr_tc_exe.c \
65 65 ../src/tc_acceptance.c \
66 66 ../src/basic_parameters/basic_parameters.c \
67 67 ../src/processing/fsw_processing.c \
68 68 ../src/processing/avf0_prc0.c \
69 69 ../src/processing/avf1_prc1.c \
70 70 ../src/processing/avf2_prc2.c
71 71
72 72 HEADERS += \
73 73 ../header/wf_handler.h \
74 74 ../header/tc_handler.h \
75 75 ../header/grlib_regs.h \
76 76 ../header/fsw_params.h \
77 77 ../header/fsw_misc.h \
78 78 ../header/fsw_init.h \
79 79 ../header/ccsds_types.h \
80 80 ../header/fsw_spacewire.h \
81 81 ../header/tc_load_dump_parameters.h \
82 82 ../header/tm_lfr_tc_exe.h \
83 83 ../header/tc_acceptance.h \
84 84 ../header/fsw_params_nb_bytes.h \
85 85 ../src/basic_parameters/basic_parameters.h \
86 86 ../header/fsw_params_processing.h \
87 87 ../header/processing/fsw_processing.h \
88 88 ../header/processing/avf0_prc0.h \
89 89 ../header/processing/avf1_prc1.h \
90 ../header/processing/avf2_prc2.h
90 ../header/processing/avf2_prc2.h \
91 ../header/fsw_params_wf_handler.h
91 92
@@ -1,201 +1,201
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-05-12T06:56:36. -->
3 <!-- Written by QtCreator 3.0.1, 2014-05-13T07:49:30. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 118 </valuemap>
119 119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 126 </valuemap>
127 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 131 </valuemap>
132 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 153 <value type="int">0</value>
154 154 <value type="int">1</value>
155 155 <value type="int">2</value>
156 156 <value type="int">3</value>
157 157 <value type="int">4</value>
158 158 <value type="int">5</value>
159 159 <value type="int">6</value>
160 160 <value type="int">7</value>
161 161 <value type="int">8</value>
162 162 <value type="int">9</value>
163 163 <value type="int">10</value>
164 164 <value type="int">11</value>
165 165 <value type="int">12</value>
166 166 <value type="int">13</value>
167 167 <value type="int">14</value>
168 168 </valuelist>
169 169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 187 </valuemap>
188 188 </data>
189 189 <data>
190 190 <variable>ProjectExplorer.Project.TargetCount</variable>
191 191 <value type="int">1</value>
192 192 </data>
193 193 <data>
194 194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
195 <value type="QByteArray">{cdbf9cdc-1e84-406e-889b-c4feef49e75c}</value>
196 196 </data>
197 197 <data>
198 198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 199 <value type="int">15</value>
200 200 </data>
201 201 </qtcreator>
@@ -1,250 +1,251
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "fsw_params_nb_bytes.h"
7 7 #include "tm_byte_positions.h"
8 8 #include "ccsds_types.h"
9 9
10 10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 11 #define UART_DEVICE_NAME "/dev/console"
12 12
13 13 typedef struct ring_node
14 14 {
15 15 struct ring_node *previous;
16 16 int buffer_address;
17 17 struct ring_node *next;
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 21 //************************
22 22 // flight software version
23 23 // this parameters is handled by the Qt project options
24 24
25 25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 28 #define TIME_OFFSET 2
29 29 #define TIME_OFFSET_IN_BYTES 8
30 30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 31 #define NB_BYTES_SWF_BLK (2 * 6)
32 32 #define NB_WORDS_SWF_BLK 3
33 33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 #define NB_RING_NODES_F3 3 // AT LEAST 3
38 39
39 40 //**********
40 41 // LFR MODES
41 42 #define LFR_MODE_STANDBY 0
42 43 #define LFR_MODE_NORMAL 1
43 44 #define LFR_MODE_BURST 2
44 45 #define LFR_MODE_SBM1 3
45 46 #define LFR_MODE_SBM2 4
46 47
47 48 #define TDS_MODE_LFM 5
48 49 #define TDS_MODE_STANDBY 0
49 50 #define TDS_MODE_NORMAL 1
50 51 #define TDS_MODE_BURST 2
51 52 #define TDS_MODE_SBM1 3
52 53 #define TDS_MODE_SBM2 4
53 54
54 55 #define THR_MODE_STANDBY 0
55 56 #define THR_MODE_NORMAL 1
56 57 #define THR_MODE_BURST 2
57 58
58 59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
59 60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
60 61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
61 62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
62 63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
63 64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
64 65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
65 66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
66 67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
67 68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
68 69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
69 70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
70 71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
71 72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
72 73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
73 74 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
74 75 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
75 76 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
76 77 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
77 78
78 79 //****************************
79 80 // LFR DEFAULT MODE PARAMETERS
80 81 // COMMON
81 82 #define DEFAULT_SY_LFR_COMMON0 0x00
82 83 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
83 84 // NORM
84 85 #define SY_LFR_N_SWF_L 2048 // nb sample
85 86 #define SY_LFR_N_SWF_P 300 // sec
86 87 #define SY_LFR_N_ASM_P 3600 // sec
87 88 #define SY_LFR_N_BP_P0 4 // sec
88 89 #define SY_LFR_N_BP_P1 20 // sec
89 90 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
90 91 #define MIN_DELTA_SNAPSHOT 16 // sec
91 92 // BURST
92 93 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
93 94 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
94 95 // SBM1
95 96 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
96 97 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
97 98 // SBM2
98 99 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
99 100 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
100 101 // ADDITIONAL PARAMETERS
101 102 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
102 103 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
103 104 // STATUS WORD
104 105 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
105 106 #define DEFAULT_STATUS_WORD_BYTE1 0x00
106 107 //
107 108 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
108 109 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
109 110 //****************************
110 111
111 112 //*****************************
112 113 // APB REGISTERS BASE ADDRESSES
113 114 #define REGS_ADDR_APBUART 0x80000100
114 115 #define REGS_ADDR_GPTIMER 0x80000300
115 116 #define REGS_ADDR_GRSPW 0x80000500
116 117 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
117 118 #define REGS_ADDR_GRGPIO 0x80000b00
118 119
119 120 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
120 121 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
121 122
122 123 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
123 124 #define APBUART_CTRL_REG_MASK_TE 0x00000002
124 125 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
125 126
126 127 //**********
127 128 // IRQ LINES
128 129 #define IRQ_SM_SIMULATOR 9
129 130 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
130 131 #define IRQ_WAVEFORM_PICKER 14
131 132 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
132 133 #define IRQ_SPECTRAL_MATRIX 6
133 134 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
134 135
135 136 //*****
136 137 // TIME
137 138 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
138 139 #define TIMER_SM_SIMULATOR 1
139 140 #define HK_PERIOD 100 // 100 * 10ms => 1s
140 141 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
141 142 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
142 143
143 144 //**********
144 145 // LPP CODES
145 146 #define LFR_SUCCESSFUL 0
146 147 #define LFR_DEFAULT 1
147 148 #define LFR_EXE_ERROR 2
148 149
149 150 //******
150 151 // RTEMS
151 152 #define TASKID_RECV 1
152 153 #define TASKID_ACTN 2
153 154 #define TASKID_SPIQ 3
154 155 #define TASKID_STAT 4
155 156 #define TASKID_AVF0 5
156 157 #define TASKID_SWBD 6
157 158 #define TASKID_WFRM 7
158 159 #define TASKID_DUMB 8
159 160 #define TASKID_HOUS 9
160 161 #define TASKID_PRC0 10
161 162 #define TASKID_CWF3 11
162 163 #define TASKID_CWF2 12
163 164 #define TASKID_CWF1 13
164 165 #define TASKID_SEND 14
165 166 #define TASKID_WTDG 15
166 167 #define TASKID_AVF1 16
167 168 #define TASKID_PRC1 17
168 169 #define TASKID_AVF2 18
169 170 #define TASKID_PRC2 19
170 171
171 172 #define TASK_PRIORITY_SPIQ 5
172 173 #define TASK_PRIORITY_WTDG 20
173 174 #define TASK_PRIORITY_HOUS 30
174 175 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
175 176 #define TASK_PRIORITY_CWF2 35 //
176 177 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
177 178 #define TASK_PRIORITY_WFRM 40
178 179 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
179 180 #define TASK_PRIORITY_SEND 45
180 181 #define TASK_PRIORITY_RECV 50
181 182 #define TASK_PRIORITY_ACTN 50
182 183 #define TASK_PRIORITY_AVF0 60
183 184 #define TASK_PRIORITY_AVF1 70
184 185 #define TASK_PRIORITY_PRC0 100
185 186 #define TASK_PRIORITY_PRC1 100
186 187 #define TASK_PRIORITY_AVF2 110
187 188 #define TASK_PRIORITY_PRC2 110
188 189 #define TASK_PRIORITY_STAT 200
189 190 #define TASK_PRIORITY_DUMB 200
190 191
191 192 #define MSG_QUEUE_COUNT_RECV 10
192 193 #define MSG_QUEUE_COUNT_SEND 50
193 194 #define MSG_QUEUE_COUNT_PRC0 10
194 195 #define MSG_QUEUE_COUNT_PRC1 10
195 196 #define MSG_QUEUE_COUNT_PRC2 5
196 197 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
197 198 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
198 199 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
199 200 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
200 201 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
201 202
202 203 #define QUEUE_RECV 0
203 204 #define QUEUE_SEND 1
204 205 #define QUEUE_PRC0 2
205 206 #define QUEUE_PRC1 3
206 207 #define QUEUE_PRC2 4
207 208
208 209 //*******
209 210 // MACROS
210 211 #ifdef PRINT_MESSAGES_ON_CONSOLE
211 212 #define PRINTF(x) printf(x);
212 213 #define PRINTF1(x,y) printf(x,y);
213 214 #define PRINTF2(x,y,z) printf(x,y,z);
214 215 #else
215 216 #define PRINTF(x) ;
216 217 #define PRINTF1(x,y) ;
217 218 #define PRINTF2(x,y,z) ;
218 219 #endif
219 220
220 221 #ifdef BOOT_MESSAGES
221 222 #define BOOT_PRINTF(x) printf(x);
222 223 #define BOOT_PRINTF1(x,y) printf(x,y);
223 224 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
224 225 #else
225 226 #define BOOT_PRINTF(x) ;
226 227 #define BOOT_PRINTF1(x,y) ;
227 228 #define BOOT_PRINTF2(x,y,z) ;
228 229 #endif
229 230
230 231 #ifdef DEBUG_MESSAGES
231 232 #define DEBUG_PRINTF(x) printf(x);
232 233 #define DEBUG_PRINTF1(x,y) printf(x,y);
233 234 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
234 235 #else
235 236 #define DEBUG_PRINTF(x) ;
236 237 #define DEBUG_PRINTF1(x,y) ;
237 238 #define DEBUG_PRINTF2(x,y,z) ;
238 239 #endif
239 240
240 241 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
241 242
242 243 struct param_local_str{
243 244 unsigned int local_sbm1_nb_cwf_sent;
244 245 unsigned int local_sbm1_nb_cwf_max;
245 246 unsigned int local_sbm2_nb_cwf_sent;
246 247 unsigned int local_sbm2_nb_cwf_max;
247 248 unsigned int local_nb_interrupt_f0_MAX;
248 249 };
249 250
250 251 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,98 +1,95
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "fsw_misc.h"
12 #include "fsw_params_wf_handler.h"
12 13
13 14 #define pi 3.1415
14 15
15 16 extern int fdSPW;
16 17
17 18 //*****************
18 19 // waveform buffers
19 // F0
20 //extern volatile int wf_snap_f0[ ];
21 // F1 F2
22 extern volatile int wf_snap_f0[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ];
23 extern volatile int wf_snap_f1[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ];
24 extern volatile int wf_snap_f2[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ];
25 // F3
26 extern volatile int wf_cont_f3_a[ ];
27 extern volatile int wf_cont_f3_b[ ];
20 extern volatile int wf_snap_f0[ ];
21 extern volatile int wf_snap_f1[ ];
22 extern volatile int wf_snap_f2[ ];
23 extern volatile int wf_cont_f3[ ];
28 24 extern char wf_cont_f3_light[ ];
29 25
30 26 extern waveform_picker_regs_new_t *waveform_picker_regs;
31 27 extern time_management_regs_t *time_management_regs;
32 28 extern Packet_TM_LFR_HK_t housekeeping_packet;
33 29 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
34 30 extern struct param_local_str param_local;
35 31
36 32 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
37 33 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
38 34
39 35 extern rtems_id Task_id[20]; /* array of task ids */
40 36
41 37 extern unsigned char lfrCurrentMode;
42 38
43 39 //**********
44 40 // RTEMS_ISR
45 41 void reset_extractSWF( void );
46 42 rtems_isr waveforms_isr( rtems_vector_number vector );
47 43
48 44 //***********
49 45 // RTEMS_TASK
50 46 rtems_task wfrm_task( rtems_task_argument argument );
51 47 rtems_task cwf3_task( rtems_task_argument argument );
52 48 rtems_task cwf2_task( rtems_task_argument argument );
53 49 rtems_task cwf1_task( rtems_task_argument argument );
54 50 rtems_task swbd_task( rtems_task_argument argument );
55 51
56 52 //******************
57 53 // general functions
58 54 void init_waveforms( void );
59 55 void init_waveform_rings( void );
56 void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] );
60 57 void reset_current_ring_nodes( void );
61 58 //
62 59 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
63 60 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
64 61 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
65 62 //
66 63 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
67 64 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
68 65 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
69 66 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
70 67 //
71 68 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
72 69 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
73 70 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
74 71 void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node );
75 72 //
76 73 rtems_id get_pkts_queue_id( void );
77 74
78 75 //**************
79 76 // wfp registers
80 77 // RESET
81 78 void reset_wfp_burst_enable( void );
82 79 void reset_wfp_status(void);
83 80 void reset_waveform_picker_regs( void );
84 81 // SET
85 82 void set_wfp_data_shaping(void);
86 83 void set_wfp_burst_enable_register( unsigned char mode );
87 84 void set_wfp_delta_snapshot( void );
88 85 void set_wfp_delta_f0_f0_2( void );
89 86 void set_wfp_delta_f1( void );
90 87 void set_wfp_delta_f2( void );
91 88
92 89 //*****************
93 90 // local parameters
94 91 void set_local_nb_interrupt_f0_MAX( void );
95 92
96 93 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
97 94
98 95 #endif // WF_HANDLER_H_INCLUDED
@@ -1,75 +1,73
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 #include "fsw_params_wf_handler.h"
23 24
24 25 // RTEMS GLOBAL VARIABLES
25 26 rtems_name misc_name[5];
26 27 rtems_id misc_id[5];
27 28 rtems_name Task_name[20]; /* array of task names */
28 29 rtems_id Task_id[20]; /* array of task ids */
29 30 unsigned int maxCount;
30 31 int fdSPW = 0;
31 32 int fdUART = 0;
32 33 unsigned char lfrCurrentMode;
33 34
34 35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
35 36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
36 37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
37 38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
38 // F0
39 volatile int wf_snap_f0[ NB_RING_NODES_F0 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
40 // F1 F2
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
43 // F3
44 volatile int wf_cont_f3_a [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
45 volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
39 // F0 F1 F2 F3
40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
46 44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
47 45
48 46 //***********************************
49 47 // SPECTRAL MATRICES GLOBAL VARIABLES
50 48
51 49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
52 50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
54 52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
55 53
56 54 // APB CONFIGURATION REGISTERS
57 55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
58 56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
59 57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
60 58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
61 59
62 60 // MODE PARAMETERS
63 61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
64 62 struct param_local_str param_local;
65 63
66 64 // HK PACKETS
67 65 Packet_TM_LFR_HK_t housekeeping_packet;
68 66 // sequence counters are incremented by APID (PID + CAT) and destination ID
69 67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
70 68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
71 69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
72 70 spw_stats spacewire_stats;
73 71 spw_stats spacewire_stats_backup;
74 72
75 73
@@ -1,366 +1,366
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "avf0_prc0.h"
11 11 #include "fsw_processing.h"
12 12
13 13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14 14
15 15 //***
16 16 // F0
17 17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19 19
20 20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
21 21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
22 22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
23 23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
24 unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
24 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
26 26
27 27 //************
28 28 // RTEMS TASKS
29 29
30 30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
31 31 {
32 32 int i;
33 33
34 34 rtems_event_set event_out;
35 35 rtems_status_code status;
36 36 rtems_id queue_id_prc0;
37 37 asm_msg msgForMATR;
38 38 ring_node_sm *ring_node_tab[8];
39 39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
40 40 ring_node_asm *current_ring_node_asm_norm_f0;
41 41
42 42 unsigned int nb_norm_bp1;
43 43 unsigned int nb_norm_bp2;
44 44 unsigned int nb_norm_asm;
45 45 unsigned int nb_sbm_bp1;
46 46 unsigned int nb_sbm_bp2;
47 47
48 48 nb_norm_bp1 = 0;
49 49 nb_norm_bp2 = 0;
50 50 nb_norm_asm = 0;
51 51 nb_sbm_bp1 = 0;
52 52 nb_sbm_bp2 = 0;
53 53
54 54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
55 55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
56 56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
57 57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
58 58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
59 59
60 60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
61 61
62 62 status = get_message_queue_id_prc0( &queue_id_prc0 );
63 63 if (status != RTEMS_SUCCESSFUL)
64 64 {
65 65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
66 66 }
67 67
68 68 while(1){
69 69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70 70 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
71 71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 72 {
73 73 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
74 74 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
75 75 }
76 76
77 77 // compute the average and store it in the averaged_sm_f1 buffer
78 78 SM_average( current_ring_node_asm_norm_f0->matrix,
79 79 current_ring_node_asm_burst_sbm_f0->matrix,
80 80 ring_node_tab,
81 81 nb_norm_bp1, nb_sbm_bp1 );
82 82
83 83 // update nb_average
84 84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
85 85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
86 86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
87 87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89 89
90 90 //****************************************
91 91 // initialize the mesage for the MATR task
92 92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
93 93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 98 msgForMATR.fineTime = time_management_regs->fine_time;
99 99
100 100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 101 {
102 102 nb_sbm_bp1 = 0;
103 103 // set another ring for the ASM storage
104 104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 105 if ( (lfrCurrentMode == LFR_MODE_BURST)
106 106 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
107 107 {
108 108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
109 109 }
110 110 }
111 111
112 112 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
113 113 {
114 114 nb_sbm_bp2 = 0;
115 115 if ( (lfrCurrentMode == LFR_MODE_BURST)
116 116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
117 117 {
118 118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
119 119 }
120 120 }
121 121
122 122 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
123 123 {
124 124 nb_norm_bp1 = 0;
125 125 // set another ring for the ASM storage
126 126 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
127 127 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
128 128 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
129 129 {
130 130 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
131 131 }
132 132 }
133 133
134 134 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
135 135 {
136 136 nb_norm_bp2 = 0;
137 137 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
138 138 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
139 139 {
140 140 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
141 141 }
142 142 }
143 143
144 144 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
145 145 {
146 146 nb_norm_asm = 0;
147 147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 149 {
150 150 // PRINTF1("%lld\n", localTime)
151 151 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
152 152 }
153 153 }
154 154
155 155 //*************************
156 156 // send the message to MATR
157 157 if (msgForMATR.event != 0x00)
158 158 {
159 159 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
160 160 }
161 161
162 162 if (status != RTEMS_SUCCESSFUL) {
163 163 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
164 164 }
165 165 }
166 166 }
167 167
168 168 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
169 169 {
170 170 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
171 171 size_t size; // size of the incoming TC packet
172 172 asm_msg *incomingMsg;
173 173 //
174 174 spw_ioctl_pkt_send spw_ioctl_send_ASM;
175 175 rtems_status_code status;
176 176 rtems_id queue_id;
177 177 rtems_id queue_id_q_p0;
178 178 Header_TM_LFR_SCIENCE_ASM_t headerASM;
179 179 bp_packet_with_spare packet_norm_bp1_f0;
180 180 bp_packet packet_norm_bp2_f0;
181 181 bp_packet packet_sbm_bp1_f0;
182 182 bp_packet packet_sbm_bp2_f0;
183 183
184 184 unsigned long long int localTime;
185 185
186 186 ASM_init_header( &headerASM );
187 187
188 188 //*************
189 189 // NORM headers
190 190 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
191 191 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
192 192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
193 193 BP_init_header( &packet_norm_bp2_f0.header,
194 194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
195 195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
196 196
197 197 //****************************
198 198 // BURST SBM1 and SBM2 headers
199 199 if ( lfrRequestedMode == LFR_MODE_BURST )
200 200 {
201 201 BP_init_header( &packet_sbm_bp1_f0.header,
202 202 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
203 203 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
204 204 BP_init_header( &packet_sbm_bp2_f0.header,
205 205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
206 206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
207 207 }
208 208 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
209 209 {
210 210 BP_init_header( &packet_sbm_bp1_f0.header,
211 211 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
212 212 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
213 213 BP_init_header( &packet_sbm_bp2_f0.header,
214 214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
215 215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
216 216 }
217 217 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
218 218 {
219 219 BP_init_header( &packet_sbm_bp1_f0.header,
220 220 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
221 221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 222 BP_init_header( &packet_sbm_bp2_f0.header,
223 223 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
224 224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
225 225 }
226 226 else
227 227 {
228 228 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
229 229 }
230 230
231 231 status = get_message_queue_id_send( &queue_id );
232 232 if (status != RTEMS_SUCCESSFUL)
233 233 {
234 234 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
235 235 }
236 236 status = get_message_queue_id_prc0( &queue_id_q_p0);
237 237 if (status != RTEMS_SUCCESSFUL)
238 238 {
239 239 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
240 240 }
241 241
242 242 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
243 243
244 244 while(1){
245 245 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
246 246 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
247 247
248 248 incomingMsg = (asm_msg*) incomingData;
249 249
250 250 localTime = getTimeAsUnsignedLongLongInt( );
251 251 //****************
252 252 //****************
253 253 // BURST SBM1 SBM2
254 254 //****************
255 255 //****************
256 256 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
257 257 {
258 258 // 1) compress the matrix for Basic Parameters calculation
259 259 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
260 260 nb_sm_before_f0.burst_sbm_bp1,
261 261 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
262 262 ASM_F0_INDICE_START);
263 263 // 2) compute the BP1 set
264 264 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
265 265 // 3) send the BP1 set
266 266 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
267 267 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
268 268 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
269 269 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
270 270 // 4) compute the BP2 set if needed
271 271 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
272 272 {
273 273 // 1) compute the BP2 set
274 274
275 275 // 2) send the BP2 set
276 276 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 277 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
278 278 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
279 279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
280 280 }
281 281 }
282 282
283 283 //*****
284 284 //*****
285 285 // NORM
286 286 //*****
287 287 //*****
288 288 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
289 289 {
290 290 // 1) compress the matrix for Basic Parameters calculation
291 291 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
292 292 nb_sm_before_f0.norm_bp1,
293 293 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
294 294 ASM_F0_INDICE_START );
295 295 // 2) compute the BP1 set
296 296 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
297 297 // 3) send the BP1 set
298 298 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
299 299 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
300 300 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
301 301 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
302 302 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
303 303 {
304 304 // 1) compute the BP2 set using the same ASM as the one used for BP1
305 305
306 306 // 2) send the BP2 set
307 307 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
308 308 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
309 309 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
310 310 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
311 311 }
312 312 }
313 313
314 314 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
315 315 {
316 316 // 1) reorganize the ASM and divide
317 317 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
318 318 asm_f0_reorganized,
319 319 nb_sm_before_f0.norm_bp1 );
320 320 // 2) convert the float array in a char array
321 321 ASM_convert( asm_f0_reorganized, asm_f0_char);
322 322 // 3) send the spectral matrix packets
323 323 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
324 324 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
325 325 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
326 326 }
327 327
328 328 }
329 329 }
330 330
331 331 //**********
332 332 // FUNCTIONS
333 333
334 334 void reset_nb_sm_f0( unsigned char lfrMode )
335 335 {
336 336 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
337 337 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
338 338 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
339 339 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
340 340 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
341 341 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
342 342 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
343 343 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
344 344 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
345 345
346 346 if (lfrMode == LFR_MODE_SBM1)
347 347 {
348 348 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
349 349 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
350 350 }
351 351 else if (lfrMode == LFR_MODE_SBM2)
352 352 {
353 353 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
354 354 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
355 355 }
356 356 else if (lfrMode == LFR_MODE_BURST)
357 357 {
358 358 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
359 359 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
360 360 }
361 361 else
362 362 {
363 363 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
364 364 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
365 365 }
366 366 }
@@ -1,1348 +1,1315
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 //*****************
13 13 // waveform headers
14 14 // SWF
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 18 // CWF
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24 24
25 25 //**************
26 26 // waveform ring
27 27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 ring_node waveform_ring_f3[NB_RING_NODES_F3];
30 31 ring_node *current_ring_node_f0;
31 32 ring_node *ring_node_to_send_swf_f0;
32 33 ring_node *current_ring_node_f1;
33 34 ring_node *ring_node_to_send_swf_f1;
34 35 ring_node *ring_node_to_send_cwf_f1;
35 36 ring_node *current_ring_node_f2;
36 37 ring_node *ring_node_to_send_swf_f2;
37 38 ring_node *ring_node_to_send_cwf_f2;
39 ring_node *current_ring_node_f3;
40 ring_node *ring_node_to_send_cwf_f3;
38 41
39 42 bool extractSWF = false;
40 43 bool swf_f0_ready = false;
41 44 bool swf_f1_ready = false;
42 45 bool swf_f2_ready = false;
43 46
44 47 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45 48
46 49 //*********************
47 50 // Interrupt SubRoutine
48 51
49 52 void reset_extractSWF( void )
50 53 {
51 54 extractSWF = false;
52 55 swf_f0_ready = false;
53 56 swf_f1_ready = false;
54 57 swf_f2_ready = false;
55 58 }
56 59
57 60 rtems_isr waveforms_isr( rtems_vector_number vector )
58 61 {
59 62 /** This is the interrupt sub routine called by the waveform picker core.
60 63 *
61 64 * This ISR launch different actions depending mainly on two pieces of information:
62 65 * 1. the values read in the registers of the waveform picker.
63 66 * 2. the current LFR mode.
64 67 *
65 68 */
66 69
67 70 rtems_status_code status;
68 71
69 72 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
70 73 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
71 74 { // in modes other than STANDBY and BURST, send the CWF_F3 data
72 75 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
73 76 // (1) change the receiving buffer for the waveform picker
74 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
75 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
76 }
77 else {
78 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
79 }
77 ring_node_to_send_cwf_f3 = current_ring_node_f3;
78 current_ring_node_f3 = current_ring_node_f3->next;
79 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
80 80 // (2) send an event for the waveforms transmission
81 81 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 82 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 83 }
84 84 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
85 85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 86 }
87 87 }
88 88
89 89 switch(lfrCurrentMode)
90 90 {
91 91 //********
92 92 // STANDBY
93 93 case(LFR_MODE_STANDBY):
94 94 break;
95 95
96 96 //******
97 97 // NORMAL
98 98 case(LFR_MODE_NORMAL):
99 99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 100 {
101 101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 102 }
103 103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 104 {
105 105 // change F0 ring node
106 106 ring_node_to_send_swf_f0 = current_ring_node_f0;
107 107 current_ring_node_f0 = current_ring_node_f0->next;
108 108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
109 109 // change F1 ring node
110 110 ring_node_to_send_swf_f1 = current_ring_node_f1;
111 111 current_ring_node_f1 = current_ring_node_f1->next;
112 112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
113 113 // change F2 ring node
114 114 ring_node_to_send_swf_f2 = current_ring_node_f2;
115 115 current_ring_node_f2 = current_ring_node_f2->next;
116 116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
117 117 //
118 118 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
119 119 {
120 120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 121 }
122 122 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
123 123 }
124 124 break;
125 125
126 126 //******
127 127 // BURST
128 128 case(LFR_MODE_BURST):
129 129 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
130 130 // (1) change the receiving buffer for the waveform picker
131 131 ring_node_to_send_cwf_f2 = current_ring_node_f2;
132 132 current_ring_node_f2 = current_ring_node_f2->next;
133 133 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
134 134 // (2) send an event for the waveforms transmission
135 135 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
136 136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 137 }
138 138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
139 139 }
140 140 break;
141 141
142 142 //*****
143 143 // SBM1
144 144 case(LFR_MODE_SBM1):
145 145 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
146 146 // (1) change the receiving buffer for the waveform picker
147 147 ring_node_to_send_cwf_f1 = current_ring_node_f1;
148 148 current_ring_node_f1 = current_ring_node_f1->next;
149 149 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
150 150 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
151 151 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
152 152 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
153 153 }
154 154 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
155 155 swf_f0_ready = true;
156 156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
157 157 }
158 158 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
159 159 swf_f2_ready = true;
160 160 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
161 161 }
162 162 break;
163 163
164 164 //*****
165 165 // SBM2
166 166 case(LFR_MODE_SBM2):
167 167 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
168 168 // (1) change the receiving buffer for the waveform picker
169 169 ring_node_to_send_cwf_f2 = current_ring_node_f2;
170 170 current_ring_node_f2 = current_ring_node_f2->next;
171 171 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
172 172 // (2) send an event for the waveforms transmission
173 173 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
174 174 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
175 175 }
176 176 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
177 177 swf_f0_ready = true;
178 178 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
179 179 }
180 180 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
181 181 swf_f1_ready = true;
182 182 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
183 183 }
184 184 break;
185 185
186 186 //********
187 187 // DEFAULT
188 188 default:
189 189 break;
190 190 }
191 191 }
192 192
193 193 //************
194 194 // RTEMS TASKS
195 195
196 196 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
197 197 {
198 198 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
199 199 *
200 200 * @param unused is the starting argument of the RTEMS task
201 201 *
202 202 * The following data packets are sent by this task:
203 203 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
204 204 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
205 205 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
206 206 *
207 207 */
208 208
209 209 rtems_event_set event_out;
210 210 rtems_id queue_id;
211 211 rtems_status_code status;
212 212
213 213 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
214 214 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
215 215 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
216 216
217 217 init_waveforms();
218 218
219 219 status = get_message_queue_id_send( &queue_id );
220 220 if (status != RTEMS_SUCCESSFUL)
221 221 {
222 222 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
223 223 }
224 224
225 225 BOOT_PRINTF("in WFRM ***\n")
226 226
227 227 while(1){
228 228 // wait for an RTEMS_EVENT
229 229 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
230 230 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
231 231 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
232 232 if (event_out == RTEMS_EVENT_MODE_NORMAL)
233 233 {
234 234 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
235 235 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
236 236 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
237 237 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
238 238 }
239 239 if (event_out == RTEMS_EVENT_MODE_SBM1)
240 240 {
241 241 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
242 242 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
243 243 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
244 244 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
245 245 }
246 246 if (event_out == RTEMS_EVENT_MODE_SBM2)
247 247 {
248 248 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
249 249 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
250 250 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
251 251 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
252 252 }
253 253 }
254 254 }
255 255
256 256 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
257 257 {
258 258 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
259 259 *
260 260 * @param unused is the starting argument of the RTEMS task
261 261 *
262 262 * The following data packet is sent by this task:
263 263 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
264 264 *
265 265 */
266 266
267 267 rtems_event_set event_out;
268 268 rtems_id queue_id;
269 269 rtems_status_code status;
270 270
271 271 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
272 272 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
273 273
274 274 status = get_message_queue_id_send( &queue_id );
275 275 if (status != RTEMS_SUCCESSFUL)
276 276 {
277 277 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
278 278 }
279 279
280 280 BOOT_PRINTF("in CWF3 ***\n")
281 281
282 282 while(1){
283 283 // wait for an RTEMS_EVENT
284 284 rtems_event_receive( RTEMS_EVENT_0,
285 285 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
286 286 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
287 287 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
288 288 {
289 289 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
290 290 {
291 291 PRINTF("send CWF_LONG_F3\n")
292 send_waveform_CWF(
293 (volatile int*) current_ring_node_f3->buffer_address,
294 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
292 295 }
293 296 else
294 297 {
295 298 PRINTF("send CWF_F3 (light)\n")
296 }
297 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
298 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
299 {
300 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
301 }
302 else
303 {
304 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
305 }
299 send_waveform_CWF3_light(
300 (volatile int*) current_ring_node_f3->buffer_address,
301 headerCWF_F3_light, queue_id );
306 302 }
307 else
308 {
309 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
310 {
311 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
312 }
313 else
314 {
315 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
316 }
317 303
318 }
319 304 }
320 305 else
321 306 {
322 307 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
323 308 }
324 309 }
325 310 }
326 311
327 312 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
328 313 {
329 314 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
330 315 *
331 316 * @param unused is the starting argument of the RTEMS task
332 317 *
333 318 * The following data packet is sent by this function:
334 319 * - TM_LFR_SCIENCE_BURST_CWF_F2
335 320 * - TM_LFR_SCIENCE_SBM2_CWF_F2
336 321 *
337 322 */
338 323
339 324 rtems_event_set event_out;
340 325 rtems_id queue_id;
341 326 rtems_status_code status;
342 327
343 328 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
344 329 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
345 330
346 331 status = get_message_queue_id_send( &queue_id );
347 332 if (status != RTEMS_SUCCESSFUL)
348 333 {
349 334 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
350 335 }
351 336
352 337 BOOT_PRINTF("in CWF2 ***\n")
353 338
354 339 while(1){
355 340 // wait for an RTEMS_EVENT
356 341 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
357 342 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
358 343 if (event_out == RTEMS_EVENT_MODE_BURST)
359 344 {
360 345 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
361 346 }
362 347 if (event_out == RTEMS_EVENT_MODE_SBM2)
363 348 {
364 349 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
365 350 // launch snapshot extraction if needed
366 351 if (extractSWF == true)
367 352 {
368 353 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
369 354 // extract the snapshot
370 355 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
371 356 // send the snapshot when built
372 357 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
373 358 extractSWF = false;
374 359 }
375 360 if (swf_f0_ready && swf_f1_ready)
376 361 {
377 362 extractSWF = true;
378 363 swf_f0_ready = false;
379 364 swf_f1_ready = false;
380 365 }
381 366 }
382 367 }
383 368 }
384 369
385 370 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
386 371 {
387 372 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
388 373 *
389 374 * @param unused is the starting argument of the RTEMS task
390 375 *
391 376 * The following data packet is sent by this function:
392 377 * - TM_LFR_SCIENCE_SBM1_CWF_F1
393 378 *
394 379 */
395 380
396 381 rtems_event_set event_out;
397 382 rtems_id queue_id;
398 383 rtems_status_code status;
399 384
400 385 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
401 386
402 387 status = get_message_queue_id_send( &queue_id );
403 388 if (status != RTEMS_SUCCESSFUL)
404 389 {
405 390 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
406 391 }
407 392
408 393 BOOT_PRINTF("in CWF1 ***\n")
409 394
410 395 while(1){
411 396 // wait for an RTEMS_EVENT
412 397 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
413 398 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
414 399 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
415 400 // launch snapshot extraction if needed
416 401 if (extractSWF == true)
417 402 {
418 403 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
419 404 // launch the snapshot extraction
420 405 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
421 406 extractSWF = false;
422 407 }
423 408 if (swf_f0_ready == true)
424 409 {
425 410 extractSWF = true;
426 411 swf_f0_ready = false; // this step shall be executed only one time
427 412 }
428 413 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
429 414 {
430 415 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
431 416 swf_f1_ready = false;
432 417 swf_f2_ready = false;
433 418 }
434 419 }
435 420 }
436 421
437 422 rtems_task swbd_task(rtems_task_argument argument)
438 423 {
439 424 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
440 425 *
441 426 * @param unused is the starting argument of the RTEMS task
442 427 *
443 428 */
444 429
445 430 rtems_event_set event_out;
446 431
447 432 BOOT_PRINTF("in SWBD ***\n")
448 433
449 434 while(1){
450 435 // wait for an RTEMS_EVENT
451 436 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
452 437 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
453 438 if (event_out == RTEMS_EVENT_MODE_SBM1)
454 439 {
455 440 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
456 441 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
457 442 }
458 443 else
459 444 {
460 445 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
461 446 }
462 447 }
463 448 }
464 449
465 450 //******************
466 451 // general functions
467 452 void init_waveforms( void )
468 453 {
469 454 int i = 0;
470 455
471 456 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
472 457 {
473 458 //***
474 459 // F0
475 460 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
476 461 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
477 462 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
478 463
479 464 //***
480 465 // F1
481 466 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
482 467 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
483 468 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
484 469
485 470 //***
486 471 // F2
487 472 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
488 473 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
489 474 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
490 475
491 476 //***
492 477 // F3
493 478 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
494 479 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
495 480 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
496 481 }
497 482 }
498 483
499 484 void init_waveform_rings( void )
500 485 {
501 unsigned char i;
502
503 486 // F0 RING
504 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
505 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
506 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
507
508 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
509 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
510 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
511
512 for(i=1; i<NB_RING_NODES_F0-1; i++)
513 {
514 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
515 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
516 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
517 }
518
487 init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 );
519 488 // F1 RING
520 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
521 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
522 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
523
524 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
525 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
526 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
527
528 for(i=1; i<NB_RING_NODES_F1-1; i++)
529 {
530 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
531 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
532 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
533 }
534
489 init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 );
535 490 // F2 RING
536 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
537 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
538 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
539
540 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
541 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
542 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
543
544 for(i=1; i<NB_RING_NODES_F2-1; i++)
545 {
546 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
547 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
548 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
549 }
491 init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 );
492 // F3 RING
493 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
550 494
551 495 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
552 496 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
553 497 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
498 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
499 }
554 500
501 void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] )
502 {
503 unsigned char i;
504
505 waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ];
506 waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ];
507 waveform_ring[0].buffer_address = (int) &wfrm[0];
508
509 waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ];
510 waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ];
511 waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ];
512
513 for(i=1; i<nbNodes-1; i++)
514 {
515 waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ];
516 waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ];
517 waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ];
518 }
555 519 }
556 520
557 521 void reset_current_ring_nodes( void )
558 522 {
559 523 current_ring_node_f0 = waveform_ring_f0;
560 524 ring_node_to_send_swf_f0 = waveform_ring_f0;
561 525
562 526 current_ring_node_f1 = waveform_ring_f1;
563 527 ring_node_to_send_cwf_f1 = waveform_ring_f1;
564 528 ring_node_to_send_swf_f1 = waveform_ring_f1;
565 529
566 530 current_ring_node_f2 = waveform_ring_f2;
567 531 ring_node_to_send_cwf_f2 = waveform_ring_f2;
568 532 ring_node_to_send_swf_f2 = waveform_ring_f2;
533
534 current_ring_node_f3 = waveform_ring_f3;
535 ring_node_to_send_cwf_f3 = waveform_ring_f3;
569 536 }
570 537
571 538 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
572 539 {
573 540 unsigned char i;
574 541
575 542 for (i=0; i<7; i++)
576 543 {
577 544 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
578 545 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
579 546 headerSWF[ i ].reserved = DEFAULT_RESERVED;
580 547 headerSWF[ i ].userApplication = CCSDS_USER_APP;
581 548 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
582 549 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
583 550 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
584 551 if (i == 6)
585 552 {
586 553 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
587 554 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
588 555 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
589 556 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
590 557 }
591 558 else
592 559 {
593 560 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
594 561 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
595 562 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
596 563 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
597 564 }
598 565 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
599 566 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
600 567 headerSWF[ i ].pktNr = i+1; // PKT_NR
601 568 // DATA FIELD HEADER
602 569 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
603 570 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
604 571 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
605 572 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
606 573 // AUXILIARY DATA HEADER
607 574 headerSWF[ i ].time[0] = 0x00;
608 575 headerSWF[ i ].time[0] = 0x00;
609 576 headerSWF[ i ].time[0] = 0x00;
610 577 headerSWF[ i ].time[0] = 0x00;
611 578 headerSWF[ i ].time[0] = 0x00;
612 579 headerSWF[ i ].time[0] = 0x00;
613 580 headerSWF[ i ].sid = sid;
614 581 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
615 582 }
616 583 return LFR_SUCCESSFUL;
617 584 }
618 585
619 586 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
620 587 {
621 588 unsigned int i;
622 589
623 590 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
624 591 {
625 592 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
626 593 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
627 594 headerCWF[ i ].reserved = DEFAULT_RESERVED;
628 595 headerCWF[ i ].userApplication = CCSDS_USER_APP;
629 596 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
630 597 {
631 598 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
632 599 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
633 600 }
634 601 else
635 602 {
636 603 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
637 604 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
638 605 }
639 606 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
640 607 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
641 608 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
642 609 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
643 610 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
644 611 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
645 612 // DATA FIELD HEADER
646 613 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
647 614 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
648 615 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
649 616 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
650 617 // AUXILIARY DATA HEADER
651 618 headerCWF[ i ].sid = sid;
652 619 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
653 620 headerCWF[ i ].time[0] = 0x00;
654 621 headerCWF[ i ].time[0] = 0x00;
655 622 headerCWF[ i ].time[0] = 0x00;
656 623 headerCWF[ i ].time[0] = 0x00;
657 624 headerCWF[ i ].time[0] = 0x00;
658 625 headerCWF[ i ].time[0] = 0x00;
659 626 }
660 627 return LFR_SUCCESSFUL;
661 628 }
662 629
663 630 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
664 631 {
665 632 unsigned int i;
666 633
667 634 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
668 635 {
669 636 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
670 637 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
671 638 headerCWF[ i ].reserved = DEFAULT_RESERVED;
672 639 headerCWF[ i ].userApplication = CCSDS_USER_APP;
673 640
674 641 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
675 642 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
676 643
677 644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
678 645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
679 646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
680 647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
681 648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
682 649
683 650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
684 651 // DATA FIELD HEADER
685 652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
686 653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
687 654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
688 655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
689 656 // AUXILIARY DATA HEADER
690 657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
691 658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
692 659 headerCWF[ i ].time[0] = 0x00;
693 660 headerCWF[ i ].time[0] = 0x00;
694 661 headerCWF[ i ].time[0] = 0x00;
695 662 headerCWF[ i ].time[0] = 0x00;
696 663 headerCWF[ i ].time[0] = 0x00;
697 664 headerCWF[ i ].time[0] = 0x00;
698 665 }
699 666 return LFR_SUCCESSFUL;
700 667 }
701 668
702 669 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
703 670 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
704 671 {
705 672 /** This function sends SWF CCSDS packets (F2, F1 or F0).
706 673 *
707 674 * @param waveform points to the buffer containing the data that will be send.
708 675 * @param sid is the source identifier of the data that will be sent.
709 676 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
710 677 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
711 678 * contain information to setup the transmission of the data packets.
712 679 *
713 680 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
714 681 *
715 682 */
716 683
717 684 unsigned int i;
718 685 int ret;
719 686 unsigned int coarseTime;
720 687 unsigned int fineTime;
721 688 rtems_status_code status;
722 689 spw_ioctl_pkt_send spw_ioctl_send_SWF;
723 690
724 691 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
725 692 spw_ioctl_send_SWF.options = 0;
726 693
727 694 ret = LFR_DEFAULT;
728 695
729 696 coarseTime = waveform[0];
730 697 fineTime = waveform[1];
731 698
732 699 for (i=0; i<7; i++) // send waveform
733 700 {
734 701 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
735 702 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
736 703 // BUILD THE DATA
737 704 if (i==6) {
738 705 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
739 706 }
740 707 else {
741 708 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
742 709 }
743 710 // SET PACKET SEQUENCE COUNTER
744 711 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
745 712 // SET PACKET TIME
746 713 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
747 714 //
748 715 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
749 716 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
750 717 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
751 718 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
752 719 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
753 720 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
754 721 // SEND PACKET
755 722 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
756 723 if (status != RTEMS_SUCCESSFUL) {
757 724 printf("%d-%d, ERR %d\n", sid, i, (int) status);
758 725 ret = LFR_DEFAULT;
759 726 }
760 727 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
761 728 }
762 729
763 730 return ret;
764 731 }
765 732
766 733 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
767 734 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
768 735 {
769 736 /** This function sends CWF CCSDS packets (F2, F1 or F0).
770 737 *
771 738 * @param waveform points to the buffer containing the data that will be send.
772 739 * @param sid is the source identifier of the data that will be sent.
773 740 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
774 741 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
775 742 * contain information to setup the transmission of the data packets.
776 743 *
777 744 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
778 745 *
779 746 */
780 747
781 748 unsigned int i;
782 749 int ret;
783 750 unsigned int coarseTime;
784 751 unsigned int fineTime;
785 752 rtems_status_code status;
786 753 spw_ioctl_pkt_send spw_ioctl_send_CWF;
787 754
788 755 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
789 756 spw_ioctl_send_CWF.options = 0;
790 757
791 758 ret = LFR_DEFAULT;
792 759
793 760 coarseTime = waveform[0];
794 761 fineTime = waveform[1];
795 762
796 763 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
797 764 {
798 765 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
799 766 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
800 767 // BUILD THE DATA
801 768 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
802 769 // SET PACKET SEQUENCE COUNTER
803 770 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
804 771 // SET PACKET TIME
805 772 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
806 773 //
807 774 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
808 775 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
809 776 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
810 777 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
811 778 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
812 779 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
813 780 // SEND PACKET
814 781 if (sid == SID_NORM_CWF_LONG_F3)
815 782 {
816 783 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
817 784 if (status != RTEMS_SUCCESSFUL) {
818 785 printf("%d-%d, ERR %d\n", sid, i, (int) status);
819 786 ret = LFR_DEFAULT;
820 787 }
821 788 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
822 789 }
823 790 else
824 791 {
825 792 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
826 793 if (status != RTEMS_SUCCESSFUL) {
827 794 printf("%d-%d, ERR %d\n", sid, i, (int) status);
828 795 ret = LFR_DEFAULT;
829 796 }
830 797 }
831 798 }
832 799
833 800 return ret;
834 801 }
835 802
836 803 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
837 804 {
838 805 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
839 806 *
840 807 * @param waveform points to the buffer containing the data that will be send.
841 808 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
842 809 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
843 810 * contain information to setup the transmission of the data packets.
844 811 *
845 812 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
846 813 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
847 814 *
848 815 */
849 816
850 817 unsigned int i;
851 818 int ret;
852 819 unsigned int coarseTime;
853 820 unsigned int fineTime;
854 821 rtems_status_code status;
855 822 spw_ioctl_pkt_send spw_ioctl_send_CWF;
856 823 char *sample;
857 824
858 825 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
859 826 spw_ioctl_send_CWF.options = 0;
860 827
861 828 ret = LFR_DEFAULT;
862 829
863 830 //**********************
864 831 // BUILD CWF3_light DATA
865 832 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
866 833 {
867 834 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
868 835 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
869 836 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
870 837 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
871 838 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
872 839 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
873 840 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
874 841 }
875 842
876 843 coarseTime = waveform[0];
877 844 fineTime = waveform[1];
878 845
879 846 //*********************
880 847 // SEND CWF3_light DATA
881 848 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
882 849 {
883 850 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];
884 851 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
885 852 // BUILD THE DATA
886 853 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
887 854 // SET PACKET SEQUENCE COUNTER
888 855 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
889 856 // SET PACKET TIME
890 857 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
891 858 //
892 859 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
893 860 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
894 861 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
895 862 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
896 863 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
897 864 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
898 865 // SEND PACKET
899 866 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
900 867 if (status != RTEMS_SUCCESSFUL) {
901 868 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
902 869 ret = LFR_DEFAULT;
903 870 }
904 871 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
905 872 }
906 873
907 874 return ret;
908 875 }
909 876
910 877 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
911 878 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
912 879 {
913 880 unsigned long long int acquisitionTimeAsLong;
914 881 unsigned char localAcquisitionTime[6];
915 882 double deltaT;
916 883
917 884 deltaT = 0.;
918 885
919 886 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
920 887 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
921 888 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
922 889 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
923 890 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
924 891 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
925 892
926 893 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
927 894 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
928 895 + ( localAcquisitionTime[2] << 24 )
929 896 + ( localAcquisitionTime[3] << 16 )
930 897 + ( localAcquisitionTime[4] << 8 )
931 898 + ( localAcquisitionTime[5] );
932 899
933 900 switch( sid )
934 901 {
935 902 case SID_NORM_SWF_F0:
936 903 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
937 904 break;
938 905
939 906 case SID_NORM_SWF_F1:
940 907 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
941 908 break;
942 909
943 910 case SID_NORM_SWF_F2:
944 911 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
945 912 break;
946 913
947 914 case SID_SBM1_CWF_F1:
948 915 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
949 916 break;
950 917
951 918 case SID_SBM2_CWF_F2:
952 919 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
953 920 break;
954 921
955 922 case SID_BURST_CWF_F2:
956 923 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
957 924 break;
958 925
959 926 case SID_NORM_CWF_F3:
960 927 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
961 928 break;
962 929
963 930 case SID_NORM_CWF_LONG_F3:
964 931 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
965 932 break;
966 933
967 934 default:
968 935 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
969 936 deltaT = 0.;
970 937 break;
971 938 }
972 939
973 940 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
974 941 //
975 942 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
976 943 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
977 944 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
978 945 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
979 946 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
980 947 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
981 948
982 949 }
983 950
984 951 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
985 952 {
986 953 unsigned int i;
987 954 unsigned long long int centerTime_asLong;
988 955 unsigned long long int acquisitionTimeF0_asLong;
989 956 unsigned long long int acquisitionTime_asLong;
990 957 unsigned long long int bufferAcquisitionTime_asLong;
991 958 unsigned char *ptr1;
992 959 unsigned char *ptr2;
993 960 unsigned char nb_ring_nodes;
994 961 unsigned long long int frequency_asLong;
995 962 unsigned long long int nbTicksPerSample_asLong;
996 963 unsigned long long int nbSamplesPart1_asLong;
997 964 unsigned long long int sampleOffset_asLong;
998 965
999 966 unsigned int deltaT_F0;
1000 967 unsigned int deltaT_F1;
1001 968 unsigned long long int deltaT_F2;
1002 969
1003 970 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1004 971 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1005 972 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1006 973 sampleOffset_asLong = 0x00;
1007 974
1008 975 // (1) get the f0 acquisition time
1009 976 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1010 977
1011 978 // (2) compute the central reference time
1012 979 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1013 980
1014 981 // (3) compute the acquisition time of the current snapshot
1015 982 switch(frequencyChannel)
1016 983 {
1017 984 case 1: // 1 is for F1 = 4096 Hz
1018 985 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1019 986 nb_ring_nodes = NB_RING_NODES_F1;
1020 987 frequency_asLong = 4096;
1021 988 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1022 989 break;
1023 990 case 2: // 2 is for F2 = 256 Hz
1024 991 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1025 992 nb_ring_nodes = NB_RING_NODES_F2;
1026 993 frequency_asLong = 256;
1027 994 nbTicksPerSample_asLong = 256; // 65536 / 256;
1028 995 break;
1029 996 default:
1030 997 acquisitionTime_asLong = centerTime_asLong;
1031 998 frequency_asLong = 256;
1032 999 nbTicksPerSample_asLong = 256;
1033 1000 break;
1034 1001 }
1035 1002
1036 1003 //****************************************************************************
1037 1004 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1038 1005 for (i=0; i<nb_ring_nodes; i++)
1039 1006 {
1040 1007 PRINTF1("%d ... ", i)
1041 1008 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1042 1009 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1043 1010 {
1044 1011 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1045 1012 break;
1046 1013 }
1047 1014 ring_node_to_send = ring_node_to_send->previous;
1048 1015 }
1049 1016
1050 1017 // (5) compute the number of samples to take in the current buffer
1051 1018 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1052 1019 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1053 1020 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1054 1021
1055 1022 // (6) compute the final acquisition time
1056 1023 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1057 1024 sampleOffset_asLong * nbTicksPerSample_asLong;
1058 1025
1059 1026 // (7) copy the acquisition time at the beginning of the extrated snapshot
1060 1027 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1061 1028 ptr2 = (unsigned char*) wf_snap_extracted;
1062 1029 ptr2[0] = ptr1[ 2 + 2 ];
1063 1030 ptr2[1] = ptr1[ 3 + 2 ];
1064 1031 ptr2[2] = ptr1[ 0 + 2 ];
1065 1032 ptr2[3] = ptr1[ 1 + 2 ];
1066 1033 ptr2[4] = ptr1[ 4 + 2 ];
1067 1034 ptr2[5] = ptr1[ 5 + 2 ];
1068 1035
1069 1036 // re set the synchronization bit
1070 1037
1071 1038
1072 1039 // copy the part 1 of the snapshot in the extracted buffer
1073 1040 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1074 1041 {
1075 1042 wf_snap_extracted[i + TIME_OFFSET] =
1076 1043 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1077 1044 }
1078 1045 // copy the part 2 of the snapshot in the extracted buffer
1079 1046 ring_node_to_send = ring_node_to_send->next;
1080 1047 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1081 1048 {
1082 1049 wf_snap_extracted[i + TIME_OFFSET] =
1083 1050 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1084 1051 }
1085 1052 }
1086 1053
1087 1054 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1088 1055 {
1089 1056 unsigned char *acquisitionTimeCharPtr;
1090 1057
1091 1058 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1092 1059
1093 1060 *acquisitionTimeAslong = 0x00;
1094 1061 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1095 1062 + ( acquisitionTimeCharPtr[1] << 16 )
1096 1063 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1097 1064 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1098 1065 + ( acquisitionTimeCharPtr[4] << 8 )
1099 1066 + ( acquisitionTimeCharPtr[5] );
1100 1067 }
1101 1068
1102 1069 //**************
1103 1070 // wfp registers
1104 1071 void reset_wfp_burst_enable(void)
1105 1072 {
1106 1073 /** This function resets the waveform picker burst_enable register.
1107 1074 *
1108 1075 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1109 1076 *
1110 1077 */
1111 1078
1112 1079 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1113 1080 }
1114 1081
1115 1082 void reset_wfp_status( void )
1116 1083 {
1117 1084 /** This function resets the waveform picker status register.
1118 1085 *
1119 1086 * All status bits are set to 0 [new_err full_err full].
1120 1087 *
1121 1088 */
1122 1089
1123 1090 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1124 1091 }
1125 1092
1126 1093 void reset_waveform_picker_regs(void)
1127 1094 {
1128 1095 /** This function resets the waveform picker module registers.
1129 1096 *
1130 1097 * The registers affected by this function are located at the following offset addresses:
1131 1098 * - 0x00 data_shaping
1132 1099 * - 0x04 run_burst_enable
1133 1100 * - 0x08 addr_data_f0
1134 1101 * - 0x0C addr_data_f1
1135 1102 * - 0x10 addr_data_f2
1136 1103 * - 0x14 addr_data_f3
1137 1104 * - 0x18 status
1138 1105 * - 0x1C delta_snapshot
1139 1106 * - 0x20 delta_f0
1140 1107 * - 0x24 delta_f0_2
1141 1108 * - 0x28 delta_f1
1142 1109 * - 0x2c delta_f2
1143 1110 * - 0x30 nb_data_by_buffer
1144 1111 * - 0x34 nb_snapshot_param
1145 1112 * - 0x38 start_date
1146 1113 * - 0x3c nb_word_in_buffer
1147 1114 *
1148 1115 */
1149 1116
1150 1117 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1151 1118 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1152 1119 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1153 1120 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1154 1121 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1155 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1122 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14
1156 1123 reset_wfp_status(); // 0x18
1157 1124 //
1158 1125 set_wfp_delta_snapshot(); // 0x1c
1159 1126 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1160 1127 set_wfp_delta_f1(); // 0x28
1161 1128 set_wfp_delta_f2(); // 0x2c
1162 1129 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1163 1130 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1164 1131 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1165 1132 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1166 1133 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1167 1134 // 2688 = 8 * 336
1168 1135 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1169 1136 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1170 1137 waveform_picker_regs->start_date = 0x00; // 0x38
1171 1138 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1172 1139 }
1173 1140
1174 1141 void set_wfp_data_shaping( void )
1175 1142 {
1176 1143 /** This function sets the data_shaping register of the waveform picker module.
1177 1144 *
1178 1145 * The value is read from one field of the parameter_dump_packet structure:\n
1179 1146 * bw_sp0_sp1_r0_r1
1180 1147 *
1181 1148 */
1182 1149
1183 1150 unsigned char data_shaping;
1184 1151
1185 1152 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1186 1153 // waveform picker : [R1 R0 SP1 SP0 BW]
1187 1154
1188 1155 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1189 1156
1190 1157 waveform_picker_regs->data_shaping =
1191 1158 ( (data_shaping & 0x10) >> 4 ) // BW
1192 1159 + ( (data_shaping & 0x08) >> 2 ) // SP0
1193 1160 + ( (data_shaping & 0x04) ) // SP1
1194 1161 + ( (data_shaping & 0x02) << 2 ) // R0
1195 1162 + ( (data_shaping & 0x01) << 4 ); // R1
1196 1163 }
1197 1164
1198 1165 void set_wfp_burst_enable_register( unsigned char mode )
1199 1166 {
1200 1167 /** This function sets the waveform picker burst_enable register depending on the mode.
1201 1168 *
1202 1169 * @param mode is the LFR mode to launch.
1203 1170 *
1204 1171 * The burst bits shall be before the enable bits.
1205 1172 *
1206 1173 */
1207 1174
1208 1175 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1209 1176 // the burst bits shall be set first, before the enable bits
1210 1177 switch(mode) {
1211 1178 case(LFR_MODE_NORMAL):
1212 1179 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1213 1180 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1214 1181 break;
1215 1182 case(LFR_MODE_BURST):
1216 1183 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1217 1184 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1218 1185 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1219 1186 break;
1220 1187 case(LFR_MODE_SBM1):
1221 1188 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1222 1189 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1223 1190 break;
1224 1191 case(LFR_MODE_SBM2):
1225 1192 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1226 1193 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1227 1194 break;
1228 1195 default:
1229 1196 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1230 1197 break;
1231 1198 }
1232 1199 }
1233 1200
1234 1201 void set_wfp_delta_snapshot( void )
1235 1202 {
1236 1203 /** This function sets the delta_snapshot register of the waveform picker module.
1237 1204 *
1238 1205 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1239 1206 * - sy_lfr_n_swf_p[0]
1240 1207 * - sy_lfr_n_swf_p[1]
1241 1208 *
1242 1209 */
1243 1210
1244 1211 unsigned int delta_snapshot;
1245 1212 unsigned int delta_snapshot_in_T2;
1246 1213
1247 1214 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1248 1215 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1249 1216
1250 1217 delta_snapshot_in_T2 = delta_snapshot * 256;
1251 1218 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1252 1219 }
1253 1220
1254 1221 void set_wfp_delta_f0_f0_2( void )
1255 1222 {
1256 1223 unsigned int delta_snapshot;
1257 1224 unsigned int nb_samples_per_snapshot;
1258 1225 float delta_f0_in_float;
1259 1226
1260 1227 delta_snapshot = waveform_picker_regs->delta_snapshot;
1261 1228 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1262 1229 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1263 1230
1264 1231 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1265 1232 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1266 1233 }
1267 1234
1268 1235 void set_wfp_delta_f1( void )
1269 1236 {
1270 1237 unsigned int delta_snapshot;
1271 1238 unsigned int nb_samples_per_snapshot;
1272 1239 float delta_f1_in_float;
1273 1240
1274 1241 delta_snapshot = waveform_picker_regs->delta_snapshot;
1275 1242 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1276 1243 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1277 1244
1278 1245 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1279 1246 }
1280 1247
1281 1248 void set_wfp_delta_f2()
1282 1249 {
1283 1250 unsigned int delta_snapshot;
1284 1251 unsigned int nb_samples_per_snapshot;
1285 1252
1286 1253 delta_snapshot = waveform_picker_regs->delta_snapshot;
1287 1254 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1288 1255
1289 1256 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1290 1257 }
1291 1258
1292 1259 //*****************
1293 1260 // local parameters
1294 1261 void set_local_nb_interrupt_f0_MAX( void )
1295 1262 {
1296 1263 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1297 1264 *
1298 1265 * This parameter is used for the SM validation only.\n
1299 1266 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1300 1267 * module before launching a basic processing.
1301 1268 *
1302 1269 */
1303 1270
1304 1271 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1305 1272 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1306 1273 }
1307 1274
1308 1275 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1309 1276 {
1310 1277 unsigned short *sequence_cnt;
1311 1278 unsigned short segmentation_grouping_flag;
1312 1279 unsigned short new_packet_sequence_control;
1313 1280
1314 1281 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1315 1282 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1316 1283 {
1317 1284 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1318 1285 }
1319 1286 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1320 1287 {
1321 1288 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1322 1289 }
1323 1290 else
1324 1291 {
1325 1292 sequence_cnt = (unsigned short *) NULL;
1326 1293 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1327 1294 }
1328 1295
1329 1296 if (sequence_cnt != NULL)
1330 1297 {
1331 1298 // increment the sequence counter
1332 1299 if ( *sequence_cnt < SEQ_CNT_MAX)
1333 1300 {
1334 1301 *sequence_cnt = *sequence_cnt + 1;
1335 1302 }
1336 1303 else
1337 1304 {
1338 1305 *sequence_cnt = 0;
1339 1306 }
1340 1307 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1341 1308 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1342 1309
1343 1310 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1344 1311
1345 1312 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1346 1313 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1347 1314 }
1348 1315 }
General Comments 0
You need to be logged in to leave comments. Login now