##// END OF EJS Templates
timegen version 0.0.0.1
paul -
r170:3efd0a6e1344 VHDL_0_1_28
parent child
Show More
@@ -1,273 +1,273
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Oct 9 10:12:36 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Fri Oct 24 13:25:08 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=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -fprofile-arcs -ftest-coverage -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/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS) -lgcov /opt/GCOV/01A/lib/overload.o -lc
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/processing/fsw_processing.c \
56 56 ../src/processing/avf0_prc0.c \
57 57 ../src/processing/avf1_prc1.c \
58 58 ../src/processing/avf2_prc2.c \
59 59 ../src/lfr_cpu_usage_report.c \
60 60 ../src/LFR_basic-parameters/basic_parameters.c
61 61 OBJECTS = obj/wf_handler.o \
62 62 obj/tc_handler.o \
63 63 obj/fsw_misc.o \
64 64 obj/fsw_init.o \
65 65 obj/fsw_globals.o \
66 66 obj/fsw_spacewire.o \
67 67 obj/tc_load_dump_parameters.o \
68 68 obj/tm_lfr_tc_exe.o \
69 69 obj/tc_acceptance.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 obj/lfr_cpu_usage_report.o \
75 75 obj/basic_parameters.o
76 76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 88 sparc.pri \
89 89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 99 fsw-qt.pro
100 100 QMAKE_TARGET = fsw
101 101 DESTDIR = bin/
102 102 TARGET = bin/fsw
103 103
104 104 first: all
105 105 ####### Implicit rules
106 106
107 107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108 108
109 109 .cpp.o:
110 110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 111
112 112 .cc.o:
113 113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114 114
115 115 .cxx.o:
116 116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117 117
118 118 .C.o:
119 119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120 120
121 121 .c.o:
122 122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123 123
124 124 ####### Build rules
125 125
126 126 all: Makefile $(TARGET)
127 127
128 128 $(TARGET): $(OBJECTS)
129 129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131 131
132 132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 144 sparc.pri \
145 145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 168 sparc.pri:
169 169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 179 qmake: FORCE
180 180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181 181
182 182 dist:
183 183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 184 $(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
185 185
186 186
187 187 clean:compiler_clean
188 188 -$(DEL_FILE) $(OBJECTS)
189 189 -$(DEL_FILE) *~ core *.core
190 190
191 191
192 192 ####### Sub-libraries
193 193
194 194 distclean: clean
195 195 -$(DEL_FILE) $(TARGET)
196 196 -$(DEL_FILE) Makefile
197 197
198 198
199 199 grmon:
200 200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201 201
202 202 check: first
203 203
204 204 compiler_rcc_make_all:
205 205 compiler_rcc_clean:
206 206 compiler_uic_make_all:
207 207 compiler_uic_clean:
208 208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 209 compiler_image_collection_clean:
210 210 -$(DEL_FILE) qmake_image_collection.cpp
211 211 compiler_yacc_decl_make_all:
212 212 compiler_yacc_decl_clean:
213 213 compiler_yacc_impl_make_all:
214 214 compiler_yacc_impl_clean:
215 215 compiler_lex_make_all:
216 216 compiler_lex_clean:
217 217 compiler_clean:
218 218
219 219 ####### Compile
220 220
221 221 obj/wf_handler.o: ../src/wf_handler.c
222 222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223 223
224 224 obj/tc_handler.o: ../src/tc_handler.c
225 225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226 226
227 227 obj/fsw_misc.o: ../src/fsw_misc.c
228 228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229 229
230 230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232 232
233 233 obj/fsw_globals.o: ../src/fsw_globals.c
234 234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235 235
236 236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238 238
239 239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241 241
242 242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244 244
245 245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247 247
248 248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250 250
251 251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253 253
254 254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256 256
257 257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259 259
260 260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262 262
263 263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265 265
266 266 ####### Install
267 267
268 268 install: FORCE
269 269
270 270 uninstall: FORCE
271 271
272 272 FORCE:
273 273
@@ -1,256 +1,259
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 unsigned coarseTime;
20 unsigned int fineTime;
19 21 } ring_node;
20 22
21 23 //************************
22 24 // flight software version
23 25 // this parameters is handled by the Qt project options
24 26
25 27 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 28 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 29 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 30 #define TIME_OFFSET 2
29 31 #define TIME_OFFSET_IN_BYTES 8
30 32 //#define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 33 #define NB_BYTES_SWF_BLK (2 * 6)
32 34 #define NB_WORDS_SWF_BLK 3
33 35 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 36 //#define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 37 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 38 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 39 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 40 #define NB_RING_NODES_F3 3 // AT LEAST 3
39 41
40 42 //**********
41 43 // LFR MODES
42 44 #define LFR_MODE_STANDBY 0
43 45 #define LFR_MODE_NORMAL 1
44 46 #define LFR_MODE_BURST 2
45 47 #define LFR_MODE_SBM1 3
46 48 #define LFR_MODE_SBM2 4
47 49
48 50 #define TDS_MODE_LFM 5
49 51 #define TDS_MODE_STANDBY 0
50 52 #define TDS_MODE_NORMAL 1
51 53 #define TDS_MODE_BURST 2
52 54 #define TDS_MODE_SBM1 3
53 55 #define TDS_MODE_SBM2 4
54 56
55 57 #define THR_MODE_STANDBY 0
56 58 #define THR_MODE_NORMAL 1
57 59 #define THR_MODE_BURST 2
58 60
59 61 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
60 62 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
61 63 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
62 64 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
63 65 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
64 66 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
65 67 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
66 68 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
67 69 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
68 70 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
69 71 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
70 72 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
71 73 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
72 74 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
73 75 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
74 76 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
75 77 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
76 78 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
77 79 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
78 80 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
79 81 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
80 82 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
81 83 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
82 84
83 85 //****************************
84 86 // LFR DEFAULT MODE PARAMETERS
85 87 // COMMON
86 88 #define DEFAULT_SY_LFR_COMMON0 0x00
87 89 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
88 90 // NORM
89 91 #define DFLT_SY_LFR_N_SWF_L 2048 // nb sample
90 92 #define DFLT_SY_LFR_N_SWF_P 300 // sec
91 93 #define DFLT_SY_LFR_N_ASM_P 3600 // sec
92 94 #define DFLT_SY_LFR_N_BP_P0 4 // sec
93 95 #define DFLT_SY_LFR_N_BP_P1 20 // sec
94 96 #define DFLT_SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
95 97 #define MIN_DELTA_SNAPSHOT 16 // sec
96 98 // BURST
97 99 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
98 100 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
99 101 // SBM1
100 102 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
101 103 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
102 104 // SBM2
103 105 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
104 106 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
105 107 // ADDITIONAL PARAMETERS
106 108 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
107 109 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
108 110 // STATUS WORD
109 111 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
110 112 #define DEFAULT_STATUS_WORD_BYTE1 0x00
111 113 //
112 114 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
113 115 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
114 116 //****************************
115 117
116 118 //*****************************
117 119 // APB REGISTERS BASE ADDRESSES
118 120 #define REGS_ADDR_APBUART 0x80000100
119 121 #define REGS_ADDR_GPTIMER 0x80000300
120 122 #define REGS_ADDR_GRSPW 0x80000500
121 123 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
122 124 #define REGS_ADDR_GRGPIO 0x80000b00
123 125
124 126 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
125 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
127 //#define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
128 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f54 // PDB >= 0.1.28
126 129 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
127 130
128 131 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
129 132 #define APBUART_CTRL_REG_MASK_TE 0x00000002
130 133 // scaler value = system_clock_frequency / ( baud_rate * 8 ) - 1
131 134 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400
132 135
133 136 //**********
134 137 // IRQ LINES
135 138 #define IRQ_SM_SIMULATOR 9
136 139 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
137 140 #define IRQ_WAVEFORM_PICKER 14
138 141 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
139 142 #define IRQ_SPECTRAL_MATRIX 6
140 143 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
141 144
142 145 //*****
143 146 // TIME
144 147 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
145 148 #define TIMER_SM_SIMULATOR 1
146 149 #define HK_PERIOD 100 // 100 * 10ms => 1s
147 150 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
148 151 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
149 152
150 153 //**********
151 154 // LPP CODES
152 155 #define LFR_SUCCESSFUL 0
153 156 #define LFR_DEFAULT 1
154 157 #define LFR_EXE_ERROR 2
155 158
156 159 //******
157 160 // RTEMS
158 161 #define TASKID_RECV 1
159 162 #define TASKID_ACTN 2
160 163 #define TASKID_SPIQ 3
161 164 #define TASKID_STAT 4
162 165 #define TASKID_AVF0 5
163 166 #define TASKID_SWBD 6
164 167 #define TASKID_WFRM 7
165 168 #define TASKID_DUMB 8
166 169 #define TASKID_HOUS 9
167 170 #define TASKID_PRC0 10
168 171 #define TASKID_CWF3 11
169 172 #define TASKID_CWF2 12
170 173 #define TASKID_CWF1 13
171 174 #define TASKID_SEND 14
172 175 #define TASKID_WTDG 15
173 176 #define TASKID_AVF1 16
174 177 #define TASKID_PRC1 17
175 178 #define TASKID_AVF2 18
176 179 #define TASKID_PRC2 19
177 180
178 181 #define TASK_PRIORITY_SPIQ 5
179 182 #define TASK_PRIORITY_WTDG 20
180 183 #define TASK_PRIORITY_HOUS 30
181 184 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
182 185 #define TASK_PRIORITY_CWF2 35 //
183 186 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
184 187 #define TASK_PRIORITY_WFRM 40
185 188 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
186 189 #define TASK_PRIORITY_SEND 45
187 190 #define TASK_PRIORITY_RECV 50
188 191 #define TASK_PRIORITY_ACTN 50
189 192 #define TASK_PRIORITY_AVF0 60
190 193 #define TASK_PRIORITY_AVF1 70
191 194 #define TASK_PRIORITY_PRC0 100
192 195 #define TASK_PRIORITY_PRC1 100
193 196 #define TASK_PRIORITY_AVF2 110
194 197 #define TASK_PRIORITY_PRC2 110
195 198 #define TASK_PRIORITY_STAT 200
196 199 #define TASK_PRIORITY_DUMB 200
197 200
198 201 #define MSG_QUEUE_COUNT_RECV 10
199 202 #define MSG_QUEUE_COUNT_SEND 50
200 203 #define MSG_QUEUE_COUNT_PRC0 10
201 204 #define MSG_QUEUE_COUNT_PRC1 10
202 205 #define MSG_QUEUE_COUNT_PRC2 5
203 206 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
204 207 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
205 208 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
206 209 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
207 210 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
208 211
209 212 #define QUEUE_RECV 0
210 213 #define QUEUE_SEND 1
211 214 #define QUEUE_PRC0 2
212 215 #define QUEUE_PRC1 3
213 216 #define QUEUE_PRC2 4
214 217
215 218 //*******
216 219 // MACROS
217 220 #ifdef PRINT_MESSAGES_ON_CONSOLE
218 221 #define PRINTF(x) printf(x);
219 222 #define PRINTF1(x,y) printf(x,y);
220 223 #define PRINTF2(x,y,z) printf(x,y,z);
221 224 #else
222 225 #define PRINTF(x) ;
223 226 #define PRINTF1(x,y) ;
224 227 #define PRINTF2(x,y,z) ;
225 228 #endif
226 229
227 230 #ifdef BOOT_MESSAGES
228 231 #define BOOT_PRINTF(x) printf(x);
229 232 #define BOOT_PRINTF1(x,y) printf(x,y);
230 233 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
231 234 #else
232 235 #define BOOT_PRINTF(x) ;
233 236 #define BOOT_PRINTF1(x,y) ;
234 237 #define BOOT_PRINTF2(x,y,z) ;
235 238 #endif
236 239
237 240 #ifdef DEBUG_MESSAGES
238 241 #define DEBUG_PRINTF(x) printf(x);
239 242 #define DEBUG_PRINTF1(x,y) printf(x,y);
240 243 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
241 244 #else
242 245 #define DEBUG_PRINTF(x) ;
243 246 #define DEBUG_PRINTF1(x,y) ;
244 247 #define DEBUG_PRINTF2(x,y,z) ;
245 248 #endif
246 249
247 250 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
248 251
249 252 struct param_local_str{
250 253 unsigned int local_sbm1_nb_cwf_sent;
251 254 unsigned int local_sbm1_nb_cwf_max;
252 255 unsigned int local_sbm2_nb_cwf_sent;
253 256 unsigned int local_sbm2_nb_cwf_max;
254 257 };
255 258
256 259 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,109 +1,122
1 1 #ifndef GRLIB_REGS_H_INCLUDED
2 2 #define GRLIB_REGS_H_INCLUDED
3 3
4 4 #define NB_GPTIMER 3
5 5
6 6 struct apbuart_regs_str{
7 7 volatile unsigned int data;
8 8 volatile unsigned int status;
9 9 volatile unsigned int ctrl;
10 10 volatile unsigned int scaler;
11 11 volatile unsigned int fifoDebug;
12 12 };
13 13
14 14 struct grgpio_regs_str{
15 15 volatile int io_port_data_register;
16 16 int io_port_output_register;
17 17 int io_port_direction_register;
18 18 int interrupt_mak_register;
19 19 int interrupt_polarity_register;
20 20 int interrupt_edge_register;
21 21 int bypass_register;
22 22 int reserved;
23 23 // 0x20-0x3c interrupt map register(s)
24 24 };
25 25
26 26 typedef struct {
27 27 volatile unsigned int counter;
28 28 volatile unsigned int reload;
29 29 volatile unsigned int ctrl;
30 30 volatile unsigned int unused;
31 31 } timer_regs_t;
32 32
33 33 typedef struct {
34 34 volatile unsigned int scaler_value;
35 35 volatile unsigned int scaler_reload;
36 36 volatile unsigned int conf;
37 37 volatile unsigned int unused0;
38 38 timer_regs_t timer[NB_GPTIMER];
39 39 } gptimer_regs_t;
40 40
41 41 typedef struct {
42 42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
43 43 volatile int coarse_time_load;
44 44 volatile int coarse_time;
45 45 volatile int fine_time;
46 46 } time_management_regs_t;
47 47
48 typedef struct {
49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
50 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
51 volatile int addr_data_f0; // 0x08 10 ***
52 volatile int addr_data_f1; // 0x0c 11 ***
53 volatile int addr_data_f2; // 0x10 100 ***
54 volatile int addr_data_f3; // 0x14 101 ***
55 volatile int status; // 0x18 110 ***
56 volatile int delta_snapshot; // 0x1c 111 ***
57 volatile int delta_f2_f1; // 0x20 0000 ***
58 volatile int delta_f2_f0; // 0x24 0001 ***
59 volatile int nb_burst_available;// 0x28 0010 ***
60 volatile int nb_snapshot_param; // 0x2c 0011 ***
61 } waveform_picker_regs_t;
62
48 // PDB >= 0.1.28
63 49 typedef struct{
64 50 int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
65 51 int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
66 int addr_data_f0; // 0x08
67 int addr_data_f1; // 0x0c
68 int addr_data_f2; // 0x10
69 int addr_data_f3; // 0x14
70 volatile int status; // 0x18
71 int delta_snapshot; // 0x1c
72 int delta_f0; // 0x20
73 int delta_f0_2; // 0x24
74 int delta_f1; // 0x28
75 int delta_f2; // 0x2c
76 int nb_data_by_buffer; // 0x30
77 int snapshot_param; // 0x34
78 int start_date; // 0x38
79 int nb_word_in_buffer; // 0x3c
80 } waveform_picker_regs_new_t;
52 int addr_data_f0_0; // 0x08
53 int addr_data_f0_1; // 0x0c
54 int addr_data_f1_0; // 0x10
55 int addr_data_f1_1; // 0x14
56 int addr_data_f2_0; // 0x18
57 int addr_data_f2_1; // 0x1c
58 int addr_data_f3_0; // 0x20
59 int addr_data_f3_1; // 0x24
60 volatile int status; // 0x28
61 int delta_snapshot; // 0x2c
62 int delta_f0; // 0x30
63 int delta_f0_2; // 0x34
64 int delta_f1; // 0x38
65 int delta_f2; // 0x3c
66 int nb_data_by_buffer; // 0x40 number of samples in a buffer = 2688
67 int snapshot_param; // 0x44
68 int start_date; // 0x48
69 //
70 volatile unsigned int f0_0_coarse_time; // 0x4c
71 volatile unsigned int f0_0_fine_time; // 0x50
72 volatile unsigned int f0_1_coarse_time; // 0x54
73 volatile unsigned int f0_1_fine_time; // 0x58
74 //
75 volatile unsigned int f1_0_coarse_time; // 0x5c
76 volatile unsigned int f1_0_fine_time; // 0x60
77 volatile unsigned int f1_1_coarse_time; // 0x64
78 volatile unsigned int f1_1_fine_time; // 0x68
79 //
80 volatile unsigned int f2_0_coarse_time; // 0x6c
81 volatile unsigned int f2_0_fine_time; // 0x70
82 volatile unsigned int f2_1_coarse_time; // 0x74
83 volatile unsigned int f2_1_fine_time; // 0x78
84 //
85 volatile unsigned int f3_0_coarse_time; // 0x7c
86 volatile unsigned int f3_0_fine_time; // 0x80
87 volatile unsigned int f3_1_coarse_time; // 0x84
88 volatile unsigned int f3_1_fine_time; // 0x88
89 //
90 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
91 } waveform_picker_regs_0_1_18_t;
81 92
82 93 typedef struct {
83 94 volatile int config; // 0x00
84 95 volatile int status; // 0x04
85 96 volatile int f0_0_address; // 0x08
86 97 volatile int f0_1_address; // 0x0C
87 98 //
88 99 volatile int f1_0_address; // 0x10
89 100 volatile int f1_1_address; // 0x14
90 101 volatile int f2_0_address; // 0x18
91 102 volatile int f2_1_address; // 0x1C
92 103 //
93 104 volatile unsigned int f0_0_coarse_time; // 0x20
94 105 volatile unsigned int f0_0_fine_time; // 0x24
95 106 volatile unsigned int f0_1_coarse_time; // 0x28
96 107 volatile unsigned int f0_1_fine_time; // 0x2C
97 108 //
98 109 volatile unsigned int f1_0_coarse_time; // 0x30
99 110 volatile unsigned int f1_0_fine_time; // 0x34
100 111 volatile unsigned int f1_1_coarse_time; // 0x38
101 112 volatile unsigned int f1_1_time_time; // 0x3C
102 113 //
103 114 volatile unsigned int f2_0_coarse_time; // 0x40
104 115 volatile unsigned int f2_0_fine_time; // 0x44
105 116 volatile unsigned int f2_1_coarse_time; // 0x48
106 117 volatile unsigned int f2_1_fine_time; // 0x4C
118 //
119 unsigned int matrix_length; // 0x50, length of a spectral matrix in burst 3200 / 16 = 200 = 0xc8
107 120 } spectral_matrix_regs_t;
108 121
109 122 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,92 +1,92
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 12 #include "fsw_params_wf_handler.h"
13 13
14 14 #define pi 3.1415
15 15
16 16 extern int fdSPW;
17 17
18 18 //*****************
19 19 // waveform buffers
20 20 extern volatile int wf_snap_f0[ ];
21 21 extern volatile int wf_snap_f1[ ];
22 22 extern volatile int wf_snap_f2[ ];
23 23 extern volatile int wf_cont_f3[ ];
24 24 extern char wf_cont_f3_light[ ];
25 25
26 extern waveform_picker_regs_new_t *waveform_picker_regs;
26 extern waveform_picker_regs_0_1_18_t *waveform_picker_regs;
27 27 extern time_management_regs_t *time_management_regs;
28 28 extern Packet_TM_LFR_HK_t housekeeping_packet;
29 29 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
30 30 extern struct param_local_str param_local;
31 31
32 32 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
33 33 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
34 34
35 35 extern rtems_id Task_id[20]; /* array of task ids */
36 36
37 37 extern unsigned char lfrCurrentMode;
38 38
39 39 //**********
40 40 // RTEMS_ISR
41 41 void reset_extractSWF( void );
42 42 rtems_isr waveforms_isr( rtems_vector_number vector );
43 43
44 44 //***********
45 45 // RTEMS_TASK
46 46 rtems_task wfrm_task( rtems_task_argument argument );
47 47 rtems_task cwf3_task( rtems_task_argument argument );
48 48 rtems_task cwf2_task( rtems_task_argument argument );
49 49 rtems_task cwf1_task( rtems_task_argument argument );
50 50 rtems_task swbd_task( rtems_task_argument argument );
51 51
52 52 //******************
53 53 // general functions
54 54 void WFP_init_rings( void );
55 55 void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] );
56 56 void WFP_reset_current_ring_nodes( void );
57 57 //
58 58 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
59 59 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
60 60 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
61 61 //
62 62 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 63 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 64 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 65 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 66 //
67 67 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 68 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
69 69 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
70 70 void snapshot_resynchronization( unsigned char *timePtr );
71 71 //
72 72 rtems_id get_pkts_queue_id( void );
73 73
74 74 //**************
75 75 // wfp registers
76 76 // RESET
77 77 void reset_wfp_burst_enable( void );
78 78 void reset_wfp_status(void);
79 79 void reset_waveform_picker_regs( void );
80 80 // SET
81 81 void set_wfp_data_shaping(void);
82 82 void set_wfp_burst_enable_register( unsigned char mode );
83 83 void set_wfp_delta_snapshot( void );
84 84 void set_wfp_delta_f0_f0_2( void );
85 85 void set_wfp_delta_f1( void );
86 86 void set_wfp_delta_f2( void );
87 87
88 88 //*****************
89 89 // local parameters
90 90 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
91 91
92 92 #endif // WF_HANDLER_H_INCLUDED
@@ -1,75 +1,75
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 23 #include "fsw_params_wf_handler.h"
24 24
25 25 // RTEMS GLOBAL VARIABLES
26 26 rtems_name misc_name[5];
27 27 rtems_id misc_id[5];
28 28 rtems_name Task_name[20]; /* array of task names */
29 29 rtems_id Task_id[20]; /* array of task ids */
30 30 unsigned int maxCount;
31 31 int fdSPW = 0;
32 32 int fdUART = 0;
33 33 unsigned char lfrCurrentMode;
34 34
35 35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
36 36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
37 37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
38 38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
39 39 // F0 F1 F2 F3
40 40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
45 45
46 46 //***********************************
47 47 // SPECTRAL MATRICES GLOBAL VARIABLES
48 48
49 49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
50 50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 53
54 54 // APB CONFIGURATION REGISTERS
55 55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
56 56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
57 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
58 58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
59 59
60 60 // MODE PARAMETERS
61 61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
62 62 struct param_local_str param_local;
63 63
64 64 // HK PACKETS
65 65 Packet_TM_LFR_HK_t housekeeping_packet;
66 66 // sequence counters are incremented by APID (PID + CAT) and destination ID
67 67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
68 68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
69 69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
70 70 unsigned short sequenceCounterHK;
71 71 unsigned short sequenceCounterParameterDump;
72 72 spw_stats spacewire_stats;
73 73 spw_stats spacewire_stats_backup;
74 74
75 75
@@ -1,696 +1,698
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 "fsw_processing.h"
11 11 #include "fsw_processing_globals.c"
12 12
13 13 unsigned int nb_sm_f0;
14 14 unsigned int nb_sm_f0_aux_f1;
15 15 unsigned int nb_sm_f1;
16 16 unsigned int nb_sm_f0_aux_f2;
17 17
18 18 //************************
19 19 // spectral matrices rings
20 20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 23 ring_node_sm *current_ring_node_sm_f0;
24 24 ring_node_sm *current_ring_node_sm_f1;
25 25 ring_node_sm *current_ring_node_sm_f2;
26 26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 28 ring_node_sm *ring_node_for_averaging_sm_f2;
29 29
30 30 //***********************************************************
31 31 // Interrupt Service Routine for spectral matrices processing
32 32
33 33 void spectral_matrices_isr_f0( void )
34 34 {
35 35 unsigned char status;
36 36 unsigned long long int time_0;
37 37 unsigned long long int time_1;
38 38 unsigned long long int syncBit0;
39 39 unsigned long long int syncBit1;
40 40
41 41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
42 42
43 43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47 47
48 48 switch(status)
49 49 {
50 50 case 0:
51 51 break;
52 52 case 3:
53 53 if ( time_0 < time_1 )
54 54 {
55 55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
57 57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
58 58 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
59 59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
61 61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
62 62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
63 63 }
64 64 else
65 65 {
66 66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
68 68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
69 69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
70 70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
72 72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
73 73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
74 74 }
75 75 spectral_matrix_regs->status = 0x03; // [0011]
76 76 break;
77 77 case 1:
78 78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
80 80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
81 81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
82 82 spectral_matrix_regs->status = 0x01; // [0001]
83 83 break;
84 84 case 2:
85 85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
87 87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
88 88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
89 89 spectral_matrix_regs->status = 0x02; // [0010]
90 90 break;
91 91 }
92 92 }
93 93
94 94 void spectral_matrices_isr_f1( void )
95 95 {
96 96 unsigned char status;
97 97 unsigned long long int time;
98 98 unsigned long long int syncBit;
99 99 rtems_status_code status_code;
100 100
101 101 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
102 102
103 103 switch(status)
104 104 {
105 105 case 0:
106 106 break;
107 107 case 3:
108 108 // UNEXPECTED VALUE
109 109 spectral_matrix_regs->status = 0xc0; // [1100]
110 110 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
111 111 break;
112 112 case 1:
113 113 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
114 114 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
115 115 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
116 116 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
117 117 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
118 118 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
119 119 spectral_matrix_regs->status = 0x04; // [0100]
120 120 break;
121 121 case 2:
122 122 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
123 123 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
124 124 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
125 125 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
126 126 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
127 127 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 128 spectral_matrix_regs->status = 0x08; // [1000]
129 129 break;
130 130 }
131 131 }
132 132
133 133 void spectral_matrices_isr_f2( void )
134 134 {
135 135 unsigned char status;
136 136 rtems_status_code status_code;
137 137
138 138 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
139 139
140 140 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
141 141
142 142 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
143 143
144 144 switch(status)
145 145 {
146 146 case 0:
147 147 break;
148 148 case 3:
149 149 // UNEXPECTED VALUE
150 150 spectral_matrix_regs->status = 0x30; // [0011 0000]
151 151 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
152 152 break;
153 153 case 1:
154 154 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
155 155 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
156 156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
157 157 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 159 {
160 160 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 161 }
162 162 break;
163 163 case 2:
164 164 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
165 165 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
166 166 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
167 167 spectral_matrix_regs->status = 0x20; // [0010 0000]
168 168 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
169 169 {
170 170 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
171 171 }
172 172 break;
173 173 }
174 174 }
175 175
176 176 void spectral_matrix_isr_error_handler( void )
177 177 {
178 178 rtems_status_code status_code;
179 179
180 180 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
181 181 {
182 182 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
183 183 }
184 184 }
185 185
186 186 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
187 187 {
188 188 // STATUS REGISTER
189 189 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
190 190 // 10 9 8
191 191 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
192 192 // 7 6 5 4 3 2 1 0
193 193
194 194 spectral_matrices_isr_f0();
195 195
196 196 spectral_matrices_isr_f1();
197 197
198 198 spectral_matrices_isr_f2();
199 199
200 200 // spectral_matrix_isr_error_handler();
201 201 }
202 202
203 203 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
204 204 {
205 205 rtems_status_code status_code;
206 206
207 207 //***
208 208 // F0
209 209 nb_sm_f0 = nb_sm_f0 + 1;
210 210 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
211 211 {
212 212 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
213 213 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
214 214 {
215 215 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
216 216 }
217 217 nb_sm_f0 = 0;
218 218 }
219 219
220 220 //***
221 221 // F1
222 222 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
223 223 if (nb_sm_f0_aux_f1 == 6)
224 224 {
225 225 nb_sm_f0_aux_f1 = 0;
226 226 nb_sm_f1 = nb_sm_f1 + 1;
227 227 }
228 228 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
229 229 {
230 230 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
231 231 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
232 232 {
233 233 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
234 234 }
235 235 nb_sm_f1 = 0;
236 236 }
237 237
238 238 //***
239 239 // F2
240 240 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
241 241 if (nb_sm_f0_aux_f2 == 96)
242 242 {
243 243 nb_sm_f0_aux_f2 = 0;
244 244 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
245 245 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
246 246 {
247 247 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
248 248 }
249 249 }
250 250 }
251 251
252 252 //******************
253 253 // Spectral Matrices
254 254
255 255 void reset_nb_sm( void )
256 256 {
257 257 nb_sm_f0 = 0;
258 258 nb_sm_f0_aux_f1 = 0;
259 259 nb_sm_f0_aux_f2 = 0;
260 260
261 261 nb_sm_f1 = 0;
262 262 }
263 263
264 264 void SM_init_rings( void )
265 265 {
266 266 unsigned char i;
267 267
268 268 // F0 RING
269 269 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
270 270 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
271 271 sm_ring_f0[0].buffer_address =
272 272 (int) &sm_f0[ 0 ];
273 273
274 274 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
275 275 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
276 276 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
277 277 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
278 278
279 279 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
280 280 {
281 281 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
282 282 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
283 283 sm_ring_f0[i].buffer_address =
284 284 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
285 285 }
286 286
287 287 // F1 RING
288 288 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
289 289 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
290 290 sm_ring_f1[0].buffer_address =
291 291 (int) &sm_f1[ 0 ];
292 292
293 293 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
294 294 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
295 295 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
296 296 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
297 297
298 298 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
299 299 {
300 300 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
301 301 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
302 302 sm_ring_f1[i].buffer_address =
303 303 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
304 304 }
305 305
306 306 // F2 RING
307 307 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
308 308 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
309 309 sm_ring_f2[0].buffer_address =
310 310 (int) &sm_f2[ 0 ];
311 311
312 312 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
313 313 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
314 314 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
315 315 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
316 316
317 317 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
318 318 {
319 319 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
320 320 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
321 321 sm_ring_f2[i].buffer_address =
322 322 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
323 323 }
324 324
325 325 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
326 326 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
327 327 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
328 328
329 329 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
330 330 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
331 331 }
332 332
333 333 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
334 334 {
335 335 unsigned char i;
336 336
337 337 //***************
338 338 // BUFFER ADDRESS
339 339 for(i=0; i<nbNodes; i++)
340 340 {
341 341 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
342 342 }
343 343
344 344 //*****
345 345 // NEXT
346 346 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
347 347 for(i=0; i<nbNodes-1; i++)
348 348 {
349 349 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
350 350 }
351 351
352 352 //*********
353 353 // PREVIOUS
354 354 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
355 355 for(i=1; i<nbNodes; i++)
356 356 {
357 357 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
358 358 }
359 359 }
360 360
361 361 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
362 362 {
363 363 unsigned char i;
364 364
365 365 ring[ nbNodes - 1 ].next
366 366 = (ring_node_asm*) &ring[ 0 ];
367 367
368 368 for(i=0; i<nbNodes-1; i++)
369 369 {
370 370 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
371 371 }
372 372 }
373 373
374 374 void SM_reset_current_ring_nodes( void )
375 375 {
376 376 current_ring_node_sm_f0 = sm_ring_f0[0].next;
377 377 current_ring_node_sm_f1 = sm_ring_f1[0].next;
378 378 current_ring_node_sm_f2 = sm_ring_f2[0].next;
379 379
380 380 ring_node_for_averaging_sm_f0 = sm_ring_f0;
381 381 ring_node_for_averaging_sm_f1 = sm_ring_f1;
382 382 ring_node_for_averaging_sm_f2 = sm_ring_f2;
383 383 }
384 384
385 385 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
386 386 {
387 387 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
388 388 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
389 389 header->reserved = 0x00;
390 390 header->userApplication = CCSDS_USER_APP;
391 391 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
392 392 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
393 393 header->packetSequenceControl[0] = 0xc0;
394 394 header->packetSequenceControl[1] = 0x00;
395 395 header->packetLength[0] = 0x00;
396 396 header->packetLength[1] = 0x00;
397 397 // DATA FIELD HEADER
398 398 header->spare1_pusVersion_spare2 = 0x10;
399 399 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
400 400 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
401 401 header->destinationID = TM_DESTINATION_ID_GROUND;
402 402 // AUXILIARY DATA HEADER
403 403 header->sid = 0x00;
404 404 header->biaStatusInfo = 0x00;
405 405 header->pa_lfr_pkt_cnt_asm = 0x00;
406 406 header->pa_lfr_pkt_nr_asm = 0x00;
407 407 header->time[0] = 0x00;
408 408 header->time[0] = 0x00;
409 409 header->time[0] = 0x00;
410 410 header->time[0] = 0x00;
411 411 header->time[0] = 0x00;
412 412 header->time[0] = 0x00;
413 413 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
414 414 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
415 415 }
416 416
417 417 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
418 418 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
419 419 {
420 420 unsigned int i;
421 421 unsigned int length = 0;
422 422 rtems_status_code status;
423 423
424 424 for (i=0; i<2; i++)
425 425 {
426 426 // (1) BUILD THE DATA
427 427 switch(sid)
428 428 {
429 429 case SID_NORM_ASM_F0:
430 430 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
431 431 spw_ioctl_send->data = &spectral_matrix[
432 432 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
433 433 ];
434 434 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
435 435 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
436 436 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
437 437 break;
438 438 case SID_NORM_ASM_F1:
439 439 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
440 440 spw_ioctl_send->data = &spectral_matrix[
441 441 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
442 442 ];
443 443 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
444 444 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
445 445 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
446 446 break;
447 447 case SID_NORM_ASM_F2:
448 448 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
449 449 spw_ioctl_send->data = &spectral_matrix[
450 450 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
451 451 ];
452 452 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
453 453 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
454 454 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
455 455 break;
456 456 default:
457 457 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
458 458 break;
459 459 }
460 460 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
461 461 spw_ioctl_send->hdr = (char *) header;
462 462 spw_ioctl_send->options = 0;
463 463
464 464 // (2) BUILD THE HEADER
465 465 increment_seq_counter_source_id( header->packetSequenceControl, sid );
466 466 header->packetLength[0] = (unsigned char) (length>>8);
467 467 header->packetLength[1] = (unsigned char) (length);
468 468 header->sid = (unsigned char) sid; // SID
469 469 header->pa_lfr_pkt_cnt_asm = 2;
470 470 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
471 471
472 472 // (3) SET PACKET TIME
473 473 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
474 474 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
475 475 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
476 476 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
477 477 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
478 478 header->time[5] = (unsigned char) (time_management_regs->fine_time);
479 479 //
480 480 header->acquisitionTime[0] = header->time[0];
481 481 header->acquisitionTime[1] = header->time[1];
482 482 header->acquisitionTime[2] = header->time[2];
483 483 header->acquisitionTime[3] = header->time[3];
484 484 header->acquisitionTime[4] = header->time[4];
485 485 header->acquisitionTime[5] = header->time[5];
486 486
487 487 // (4) SEND PACKET
488 488 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
489 489 if (status != RTEMS_SUCCESSFUL) {
490 490 printf("in ASM_send *** ERR %d\n", (int) status);
491 491 }
492 492 }
493 493 }
494 494
495 495 //*****************
496 496 // Basic Parameters
497 497
498 498 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
499 499 unsigned int apid, unsigned char sid,
500 500 unsigned int packetLength, unsigned char blkNr )
501 501 {
502 502 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
503 503 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
504 504 header->reserved = 0x00;
505 505 header->userApplication = CCSDS_USER_APP;
506 506 header->packetID[0] = (unsigned char) (apid >> 8);
507 507 header->packetID[1] = (unsigned char) (apid);
508 508 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
509 509 header->packetSequenceControl[1] = 0x00;
510 510 header->packetLength[0] = (unsigned char) (packetLength >> 8);
511 511 header->packetLength[1] = (unsigned char) (packetLength);
512 512 // DATA FIELD HEADER
513 513 header->spare1_pusVersion_spare2 = 0x10;
514 514 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
515 515 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
516 516 header->destinationID = TM_DESTINATION_ID_GROUND;
517 517 // AUXILIARY DATA HEADER
518 518 header->sid = sid;
519 519 header->biaStatusInfo = 0x00;
520 520 header->time[0] = 0x00;
521 521 header->time[0] = 0x00;
522 522 header->time[0] = 0x00;
523 523 header->time[0] = 0x00;
524 524 header->time[0] = 0x00;
525 525 header->time[0] = 0x00;
526 526 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
527 527 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
528 528 }
529 529
530 530 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
531 531 unsigned int apid, unsigned char sid,
532 532 unsigned int packetLength , unsigned char blkNr)
533 533 {
534 534 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
535 535 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
536 536 header->reserved = 0x00;
537 537 header->userApplication = CCSDS_USER_APP;
538 538 header->packetID[0] = (unsigned char) (apid >> 8);
539 539 header->packetID[1] = (unsigned char) (apid);
540 540 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
541 541 header->packetSequenceControl[1] = 0x00;
542 542 header->packetLength[0] = (unsigned char) (packetLength >> 8);
543 543 header->packetLength[1] = (unsigned char) (packetLength);
544 544 // DATA FIELD HEADER
545 545 header->spare1_pusVersion_spare2 = 0x10;
546 546 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
547 547 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
548 548 header->destinationID = TM_DESTINATION_ID_GROUND;
549 549 // AUXILIARY DATA HEADER
550 550 header->sid = sid;
551 551 header->biaStatusInfo = 0x00;
552 552 header->time[0] = 0x00;
553 553 header->time[0] = 0x00;
554 554 header->time[0] = 0x00;
555 555 header->time[0] = 0x00;
556 556 header->time[0] = 0x00;
557 557 header->time[0] = 0x00;
558 558 header->source_data_spare = 0x00;
559 559 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
560 560 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
561 561 }
562 562
563 563 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
564 564 {
565 565 rtems_status_code status;
566 566
567 567 // SET THE SEQUENCE_CNT PARAMETER
568 568 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
569 569 // SEND PACKET
570 570 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
571 571 if (status != RTEMS_SUCCESSFUL)
572 572 {
573 573 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
574 574 }
575 575 }
576 576
577 577 //******************
578 578 // general functions
579 579
580 580 void reset_spectral_matrix_regs( void )
581 581 {
582 582 /** This function resets the spectral matrices module registers.
583 583 *
584 584 * The registers affected by this function are located at the following offset addresses:
585 585 *
586 586 * - 0x00 config
587 587 * - 0x04 status
588 588 * - 0x08 matrixF0_Address0
589 589 * - 0x10 matrixFO_Address1
590 590 * - 0x14 matrixF1_Address
591 591 * - 0x18 matrixF2_Address
592 592 *
593 593 */
594 594
595 595 spectral_matrix_regs->config = 0x00;
596 596 spectral_matrix_regs->status = 0x00;
597 597
598 598 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
599 599 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
600 600 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
601 601 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
602 602 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
603 603 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
604
605 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
604 606 }
605 607
606 608 void set_time( unsigned char *time, unsigned char * timeInBuffer )
607 609 {
608 610 time[0] = timeInBuffer[0];
609 611 time[1] = timeInBuffer[1];
610 612 time[2] = timeInBuffer[2];
611 613 time[3] = timeInBuffer[3];
612 614 time[4] = timeInBuffer[6];
613 615 time[5] = timeInBuffer[7];
614 616 }
615 617
616 618 unsigned long long int get_acquisition_time( unsigned char *timePtr )
617 619 {
618 620 unsigned long long int acquisitionTimeAslong;
619 621 acquisitionTimeAslong = 0x00;
620 622 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
621 623 + ( (unsigned long long int) timePtr[1] << 32 )
622 624 + ( (unsigned long long int) timePtr[2] << 24 )
623 625 + ( (unsigned long long int) timePtr[3] << 16 )
624 626 + ( (unsigned long long int) timePtr[6] << 8 )
625 627 + ( (unsigned long long int) timePtr[7] );
626 628 return acquisitionTimeAslong;
627 629 }
628 630
629 631 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
630 632 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
631 633 unsigned long long int time )
632 634 {
633 635 unsigned char *timePtr;
634 636 unsigned char *coarseTimePtr;
635 637 unsigned char *fineTimePtr;
636 638 rtems_status_code status_code;
637 639
638 640 timePtr = (unsigned char *) &time;
639 641 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
640 642 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
641 643
642 644 *nb_sm = *nb_sm + 1;
643 645 if (*nb_sm == nb_sm_before_avf)
644 646 {
645 647 node_for_averaging = ringNode;
646 648 coarseTimePtr[0] = timePtr[2];
647 649 coarseTimePtr[1] = timePtr[3];
648 650 coarseTimePtr[2] = timePtr[4];
649 651 coarseTimePtr[3] = timePtr[5];
650 652 fineTimePtr[2] = timePtr[6];
651 653 fineTimePtr[3] = timePtr[7];
652 654 if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
653 655 {
654 656 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
655 657 }
656 658 *nb_sm = 0;
657 659 }
658 660 }
659 661
660 662 unsigned char getSID( rtems_event_set event )
661 663 {
662 664 unsigned char sid;
663 665
664 666 rtems_event_set eventSetBURST;
665 667 rtems_event_set eventSetSBM;
666 668
667 669 //******
668 670 // BURST
669 671 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
670 672 | RTEMS_EVENT_BURST_BP1_F1
671 673 | RTEMS_EVENT_BURST_BP2_F0
672 674 | RTEMS_EVENT_BURST_BP2_F1;
673 675
674 676 //****
675 677 // SBM
676 678 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
677 679 | RTEMS_EVENT_SBM_BP1_F1
678 680 | RTEMS_EVENT_SBM_BP2_F0
679 681 | RTEMS_EVENT_SBM_BP2_F1;
680 682
681 683 if (event & eventSetBURST)
682 684 {
683 685 sid = SID_BURST_BP1_F0;
684 686 }
685 687 else if (event & eventSetSBM)
686 688 {
687 689 sid = SID_SBM1_BP1_F0;
688 690 }
689 691 else
690 692 {
691 693 sid = 0;
692 694 }
693 695
694 696 return sid;
695 697 }
696 698
@@ -1,949 +1,949
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 60 if (status!=RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 63 }
64 64 else
65 65 {
66 66 subtype = TC.serviceSubType;
67 67 switch(subtype)
68 68 {
69 69 case TC_SUBTYPE_RESET:
70 70 result = action_reset( &TC, queue_snd_id, time );
71 71 close_action( &TC, result, queue_snd_id );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_COMM:
75 75 result = action_load_common_par( &TC );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_NORM:
80 80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 81 close_action( &TC, result, queue_snd_id );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_BURST:
85 85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 86 close_action( &TC, result, queue_snd_id );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM1:
90 90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 91 close_action( &TC, result, queue_snd_id );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_LOAD_SBM2:
95 95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_DUMP:
100 100 result = action_dump_par( queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id );
106 106 close_action( &TC, result, queue_snd_id );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_UPDT_INFO:
110 110 result = action_update_info( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_EN_CAL:
115 115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_DIS_CAL:
120 120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 121 close_action( &TC, result, queue_snd_id );
122 122 break;
123 123 //
124 124 case TC_SUBTYPE_UPDT_TIME:
125 125 result = action_update_time( &TC );
126 126 close_action( &TC, result, queue_snd_id );
127 127 break;
128 128 //
129 129 default:
130 130 break;
131 131 }
132 132 }
133 133 }
134 134 }
135 135
136 136 //***********
137 137 // TC ACTIONS
138 138
139 139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 140 {
141 141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 142 *
143 143 * @param TC points to the TeleCommand packet that is being processed
144 144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 145 *
146 146 */
147 147
148 148 printf("this is the end!!!\n");
149 149 exit(0);
150 150 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
151 151 return LFR_DEFAULT;
152 152 }
153 153
154 154 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
155 155 {
156 156 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
157 157 *
158 158 * @param TC points to the TeleCommand packet that is being processed
159 159 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
160 160 *
161 161 */
162 162
163 163 rtems_status_code status;
164 164 unsigned char requestedMode;
165 165 unsigned int *transitionCoarseTime_ptr;
166 166 unsigned int transitionCoarseTime;
167 167 unsigned char * bytePosPtr;
168 168
169 169 bytePosPtr = (unsigned char *) &TC->packetID;
170 170
171 171 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
172 172 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
173 173 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
174 174
175 175 status = check_mode_value( requestedMode );
176 176
177 177 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
178 178 {
179 179 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
180 180 }
181 181 else // the mode value is consistent, check the transition
182 182 {
183 183 status = check_mode_transition(requestedMode);
184 184 if (status != LFR_SUCCESSFUL)
185 185 {
186 186 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
187 187 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
188 188 }
189 189 }
190 190
191 191 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
192 192 {
193 193 status = check_transition_date( transitionCoarseTime );
194 194 if (status != LFR_SUCCESSFUL)
195 195 {
196 196 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
197 197 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
198 198 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
199 199 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
200 200 }
201 201 }
202 202
203 203 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
204 204 {
205 205 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
206 206 status = enter_mode( requestedMode, transitionCoarseTime );
207 207 }
208 208
209 209 return status;
210 210 }
211 211
212 212 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
213 213 {
214 214 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
215 215 *
216 216 * @param TC points to the TeleCommand packet that is being processed
217 217 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
218 218 *
219 219 * @return LFR directive status code:
220 220 * - LFR_DEFAULT
221 221 * - LFR_SUCCESSFUL
222 222 *
223 223 */
224 224
225 225 unsigned int val;
226 226 int result;
227 227 unsigned int status;
228 228 unsigned char mode;
229 229 unsigned char * bytePosPtr;
230 230
231 231 bytePosPtr = (unsigned char *) &TC->packetID;
232 232
233 233 // check LFR mode
234 234 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
235 235 status = check_update_info_hk_lfr_mode( mode );
236 236 if (status == LFR_SUCCESSFUL) // check TDS mode
237 237 {
238 238 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
239 239 status = check_update_info_hk_tds_mode( mode );
240 240 }
241 241 if (status == LFR_SUCCESSFUL) // check THR mode
242 242 {
243 243 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
244 244 status = check_update_info_hk_thr_mode( mode );
245 245 }
246 246 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
247 247 {
248 248 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
249 249 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
250 250 val++;
251 251 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
252 252 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
253 253 }
254 254
255 255 result = status;
256 256
257 257 return result;
258 258 }
259 259
260 260 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
261 261 {
262 262 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
263 263 *
264 264 * @param TC points to the TeleCommand packet that is being processed
265 265 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
266 266 *
267 267 */
268 268
269 269 int result;
270 270 unsigned char lfrMode;
271 271
272 272 result = LFR_DEFAULT;
273 273 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
274 274
275 275 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
276 276 result = LFR_DEFAULT;
277 277
278 278 return result;
279 279 }
280 280
281 281 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
282 282 {
283 283 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
284 284 *
285 285 * @param TC points to the TeleCommand packet that is being processed
286 286 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
287 287 *
288 288 */
289 289
290 290 int result;
291 291 unsigned char lfrMode;
292 292
293 293 result = LFR_DEFAULT;
294 294 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
295 295
296 296 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
297 297 result = LFR_DEFAULT;
298 298
299 299 return result;
300 300 }
301 301
302 302 int action_update_time(ccsdsTelecommandPacket_t *TC)
303 303 {
304 304 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
305 305 *
306 306 * @param TC points to the TeleCommand packet that is being processed
307 307 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
308 308 *
309 309 * @return LFR_SUCCESSFUL
310 310 *
311 311 */
312 312
313 313 unsigned int val;
314 314
315 315 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
316 316 + (TC->dataAndCRC[1] << 16)
317 317 + (TC->dataAndCRC[2] << 8)
318 318 + TC->dataAndCRC[3];
319 319
320 320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 322 val++;
323 323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 325
326 326 return LFR_SUCCESSFUL;
327 327 }
328 328
329 329 //*******************
330 330 // ENTERING THE MODES
331 331 int check_mode_value( unsigned char requestedMode )
332 332 {
333 333 int status;
334 334
335 335 if ( (requestedMode != LFR_MODE_STANDBY)
336 336 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
337 337 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
338 338 {
339 339 status = LFR_DEFAULT;
340 340 }
341 341 else
342 342 {
343 343 status = LFR_SUCCESSFUL;
344 344 }
345 345
346 346 return status;
347 347 }
348 348
349 349 int check_mode_transition( unsigned char requestedMode )
350 350 {
351 351 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
352 352 *
353 353 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
354 354 *
355 355 * @return LFR directive status codes:
356 356 * - LFR_SUCCESSFUL - the transition is authorized
357 357 * - LFR_DEFAULT - the transition is not authorized
358 358 *
359 359 */
360 360
361 361 int status;
362 362
363 363 switch (requestedMode)
364 364 {
365 365 case LFR_MODE_STANDBY:
366 366 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
367 367 status = LFR_DEFAULT;
368 368 }
369 369 else
370 370 {
371 371 status = LFR_SUCCESSFUL;
372 372 }
373 373 break;
374 374 case LFR_MODE_NORMAL:
375 375 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
376 376 status = LFR_DEFAULT;
377 377 }
378 378 else {
379 379 status = LFR_SUCCESSFUL;
380 380 }
381 381 break;
382 382 case LFR_MODE_BURST:
383 383 if ( lfrCurrentMode == LFR_MODE_BURST ) {
384 384 status = LFR_DEFAULT;
385 385 }
386 386 else {
387 387 status = LFR_SUCCESSFUL;
388 388 }
389 389 break;
390 390 case LFR_MODE_SBM1:
391 391 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
392 392 status = LFR_DEFAULT;
393 393 }
394 394 else {
395 395 status = LFR_SUCCESSFUL;
396 396 }
397 397 break;
398 398 case LFR_MODE_SBM2:
399 399 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
400 400 status = LFR_DEFAULT;
401 401 }
402 402 else {
403 403 status = LFR_SUCCESSFUL;
404 404 }
405 405 break;
406 406 default:
407 407 status = LFR_DEFAULT;
408 408 break;
409 409 }
410 410
411 411 return status;
412 412 }
413 413
414 414 int check_transition_date( unsigned int transitionCoarseTime )
415 415 {
416 416 int status;
417 417 unsigned int localCoarseTime;
418 418 unsigned int deltaCoarseTime;
419 419
420 420 status = LFR_SUCCESSFUL;
421 421
422 422 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
423 423 {
424 424 status = LFR_SUCCESSFUL;
425 425 }
426 426 else
427 427 {
428 428 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
429 429
430 430 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
431 431 {
432 432 status = LFR_DEFAULT;
433 433 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
434 434 }
435 435
436 436 if (status == LFR_SUCCESSFUL)
437 437 {
438 438 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
439 439 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
440 440 {
441 441 status = LFR_DEFAULT;
442 442 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
443 443 }
444 444 }
445 445 }
446 446
447 447 return status;
448 448 }
449 449
450 450 int stop_current_mode( void )
451 451 {
452 452 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
453 453 *
454 454 * @return RTEMS directive status codes:
455 455 * - RTEMS_SUCCESSFUL - task restarted successfully
456 456 * - RTEMS_INVALID_ID - task id invalid
457 457 * - RTEMS_ALREADY_SUSPENDED - task already suspended
458 458 *
459 459 */
460 460
461 461 rtems_status_code status;
462 462
463 463 status = RTEMS_SUCCESSFUL;
464 464
465 465 // (1) mask interruptions
466 466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 468
469 469 // (2) clear interruptions
470 470 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
471 471 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
472 472
473 473 // (3) reset waveform picker registers
474 474 reset_wfp_burst_enable(); // reset burst and enable bits
475 475 reset_wfp_status(); // reset all the status bits
476 476
477 477 // (4) reset spectral matrices registers
478 478 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
479 479 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
480 480 reset_extractSWF(); // reset the extractSWF flag to false
481 481
482 482 // <Spectral Matrices simulator>
483 483 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
484 484 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
485 485 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
486 486 // </Spectral Matrices simulator>
487 487
488 488 // suspend several tasks
489 489 if (lfrCurrentMode != LFR_MODE_STANDBY) {
490 490 status = suspend_science_tasks();
491 491 }
492 492
493 493 if (status != RTEMS_SUCCESSFUL)
494 494 {
495 495 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
496 496 }
497 497
498 498 return status;
499 499 }
500 500
501 501 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
502 502 {
503 503 /** This function is launched after a mode transition validation.
504 504 *
505 505 * @param mode is the mode in which LFR will be put.
506 506 *
507 507 * @return RTEMS directive status codes:
508 508 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
509 509 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
510 510 *
511 511 */
512 512
513 513 rtems_status_code status;
514 514
515 515 //**********************
516 516 // STOP THE CURRENT MODE
517 517 status = stop_current_mode();
518 518 if (status != RTEMS_SUCCESSFUL)
519 519 {
520 520 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
521 521 }
522 522
523 523 //*************************
524 524 // ENTER THE REQUESTED MODE
525 525 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
526 526 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
527 527 {
528 528 #ifdef PRINT_TASK_STATISTICS
529 529 rtems_cpu_usage_reset();
530 530 maxCount = 0;
531 531 #endif
532 532 status = restart_science_tasks( mode );
533 launch_spectral_matrix( );
533 534 launch_waveform_picker( mode, transitionCoarseTime );
534 launch_spectral_matrix( );
535 535 // launch_spectral_matrix_simu( );
536 536 }
537 537 else if ( mode == LFR_MODE_STANDBY )
538 538 {
539 539 #ifdef PRINT_TASK_STATISTICS
540 540 rtems_cpu_usage_report();
541 541 #endif
542 542
543 543 #ifdef PRINT_STACK_REPORT
544 544 PRINTF("stack report selected\n")
545 545 rtems_stack_checker_report_usage();
546 546 #endif
547 547 PRINTF1("maxCount = %d\n", maxCount)
548 548 }
549 549 else
550 550 {
551 551 status = RTEMS_UNSATISFIED;
552 552 }
553 553
554 554 if (status != RTEMS_SUCCESSFUL)
555 555 {
556 556 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
557 557 status = RTEMS_UNSATISFIED;
558 558 }
559 559
560 560 return status;
561 561 }
562 562
563 563 int restart_science_tasks(unsigned char lfrRequestedMode )
564 564 {
565 565 /** This function is used to restart all science tasks.
566 566 *
567 567 * @return RTEMS directive status codes:
568 568 * - RTEMS_SUCCESSFUL - task restarted successfully
569 569 * - RTEMS_INVALID_ID - task id invalid
570 570 * - RTEMS_INCORRECT_STATE - task never started
571 571 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
572 572 *
573 573 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
574 574 *
575 575 */
576 576
577 577 rtems_status_code status[10];
578 578 rtems_status_code ret;
579 579
580 580 ret = RTEMS_SUCCESSFUL;
581 581
582 582 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
583 583 if (status[0] != RTEMS_SUCCESSFUL)
584 584 {
585 585 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
586 586 }
587 587
588 588 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
589 589 if (status[1] != RTEMS_SUCCESSFUL)
590 590 {
591 591 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
592 592 }
593 593
594 594 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
595 595 if (status[2] != RTEMS_SUCCESSFUL)
596 596 {
597 597 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
598 598 }
599 599
600 600 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
601 601 if (status[3] != RTEMS_SUCCESSFUL)
602 602 {
603 603 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
604 604 }
605 605
606 606 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
607 607 if (status[4] != RTEMS_SUCCESSFUL)
608 608 {
609 609 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
610 610 }
611 611
612 612 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
613 613 if (status[5] != RTEMS_SUCCESSFUL)
614 614 {
615 615 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
616 616 }
617 617
618 618 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
619 619 if (status[6] != RTEMS_SUCCESSFUL)
620 620 {
621 621 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
622 622 }
623 623
624 624 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
625 625 if (status[7] != RTEMS_SUCCESSFUL)
626 626 {
627 627 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
628 628 }
629 629
630 630 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
631 631 if (status[8] != RTEMS_SUCCESSFUL)
632 632 {
633 633 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
634 634 }
635 635
636 636 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
637 637 if (status[9] != RTEMS_SUCCESSFUL)
638 638 {
639 639 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
640 640 }
641 641
642 642 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
643 643 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
644 644 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
645 645 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
646 646 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
647 647 {
648 648 ret = RTEMS_UNSATISFIED;
649 649 }
650 650
651 651 return ret;
652 652 }
653 653
654 654 int suspend_science_tasks()
655 655 {
656 656 /** This function suspends the science tasks.
657 657 *
658 658 * @return RTEMS directive status codes:
659 659 * - RTEMS_SUCCESSFUL - task restarted successfully
660 660 * - RTEMS_INVALID_ID - task id invalid
661 661 * - RTEMS_ALREADY_SUSPENDED - task already suspended
662 662 *
663 663 */
664 664
665 665 rtems_status_code status;
666 666
667 667 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
668 668 if (status != RTEMS_SUCCESSFUL)
669 669 {
670 670 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
671 671 }
672 672 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
673 673 {
674 674 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
675 675 if (status != RTEMS_SUCCESSFUL)
676 676 {
677 677 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
678 678 }
679 679 }
680 680 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
681 681 {
682 682 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
683 683 if (status != RTEMS_SUCCESSFUL)
684 684 {
685 685 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
686 686 }
687 687 }
688 688 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
689 689 {
690 690 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
691 691 if (status != RTEMS_SUCCESSFUL)
692 692 {
693 693 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
694 694 }
695 695 }
696 696 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
697 697 {
698 698 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
699 699 if (status != RTEMS_SUCCESSFUL)
700 700 {
701 701 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
702 702 }
703 703 }
704 704 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
705 705 {
706 706 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
707 707 if (status != RTEMS_SUCCESSFUL)
708 708 {
709 709 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
710 710 }
711 711 }
712 712 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
713 713 {
714 714 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
715 715 if (status != RTEMS_SUCCESSFUL)
716 716 {
717 717 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
718 718 }
719 719 }
720 720 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
721 721 {
722 722 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
723 723 if (status != RTEMS_SUCCESSFUL)
724 724 {
725 725 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
726 726 }
727 727 }
728 728 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
729 729 {
730 730 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
731 731 if (status != RTEMS_SUCCESSFUL)
732 732 {
733 733 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
734 734 }
735 735 }
736 736 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
737 737 {
738 738 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
739 739 if (status != RTEMS_SUCCESSFUL)
740 740 {
741 741 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
742 742 }
743 743 }
744 744
745 745 return status;
746 746 }
747 747
748 748 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
749 749 {
750 750 WFP_reset_current_ring_nodes();
751 751 reset_waveform_picker_regs();
752 752 set_wfp_burst_enable_register( mode );
753 753
754 754 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
755 755 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
756 756
757 757 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
758 758 if (transitionCoarseTime == 0)
759 759 {
760 760 waveform_picker_regs->start_date = time_management_regs->coarse_time;
761 761 }
762 762 else
763 763 {
764 764 waveform_picker_regs->start_date = transitionCoarseTime;
765 765 }
766 766
767 767 PRINTF1("commutation coarse time = %d\n", transitionCoarseTime)
768 768 }
769 769
770 770 void launch_spectral_matrix( void )
771 771 {
772 772 SM_reset_current_ring_nodes();
773 773 reset_spectral_matrix_regs();
774 774 reset_nb_sm();
775 775
776 776 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
777 777 grgpio_regs->io_port_direction_register =
778 778 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
779 779 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
780 780 set_irq_on_new_ready_matrix( 1 );
781 781 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
782 782 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
783 783 set_run_matrix_spectral( 1 );
784 784 }
785 785
786 786 void launch_spectral_matrix_simu( void )
787 787 {
788 788 SM_reset_current_ring_nodes();
789 789 reset_spectral_matrix_regs();
790 790 reset_nb_sm();
791 791
792 792 // Spectral Matrices simulator
793 793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
794 794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
795 795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
796 796 }
797 797
798 798 void set_irq_on_new_ready_matrix( unsigned char value )
799 799 {
800 800 if (value == 1)
801 801 {
802 802 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
803 803 }
804 804 else
805 805 {
806 806 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
807 807 }
808 808 }
809 809
810 810 void set_run_matrix_spectral( unsigned char value )
811 811 {
812 812 if (value == 1)
813 813 {
814 814 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
815 815 }
816 816 else
817 817 {
818 818 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
819 819 }
820 820 }
821 821
822 822 //****************
823 823 // CLOSING ACTIONS
824 824 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
825 825 {
826 826 /** This function is used to update the HK packets statistics after a successful TC execution.
827 827 *
828 828 * @param TC points to the TC being processed
829 829 * @param time is the time used to date the TC execution
830 830 *
831 831 */
832 832
833 833 unsigned int val;
834 834
835 835 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
836 836 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
837 837 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
838 838 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
839 839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
840 840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
841 841 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
842 842 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
843 843 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
844 844 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
845 845 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
846 846 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
847 847
848 848 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
849 849 val++;
850 850 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
851 851 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
852 852 }
853 853
854 854 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
855 855 {
856 856 /** This function is used to update the HK packets statistics after a TC rejection.
857 857 *
858 858 * @param TC points to the TC being processed
859 859 * @param time is the time used to date the TC rejection
860 860 *
861 861 */
862 862
863 863 unsigned int val;
864 864
865 865 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
866 866 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
867 867 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
868 868 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
869 869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
870 870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
871 871 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
872 872 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
873 873 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
874 874 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
875 875 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
876 876 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
877 877
878 878 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
879 879 val++;
880 880 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
881 881 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
882 882 }
883 883
884 884 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
885 885 {
886 886 /** This function is the last step of the TC execution workflow.
887 887 *
888 888 * @param TC points to the TC being processed
889 889 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
890 890 * @param queue_id is the id of the RTEMS message queue used to send TM packets
891 891 * @param time is the time used to date the TC execution
892 892 *
893 893 */
894 894
895 895 unsigned char requestedMode;
896 896
897 897 if (result == LFR_SUCCESSFUL)
898 898 {
899 899 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
900 900 &
901 901 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
902 902 )
903 903 {
904 904 send_tm_lfr_tc_exe_success( TC, queue_id );
905 905 }
906 906 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
907 907 {
908 908 //**********************************
909 909 // UPDATE THE LFRMODE LOCAL VARIABLE
910 910 requestedMode = TC->dataAndCRC[1];
911 911 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
912 912 updateLFRCurrentMode();
913 913 }
914 914 }
915 915 else if (result == LFR_EXE_ERROR)
916 916 {
917 917 send_tm_lfr_tc_exe_error( TC, queue_id );
918 918 }
919 919 }
920 920
921 921 //***************************
922 922 // Interrupt Service Routines
923 923 rtems_isr commutation_isr1( rtems_vector_number vector )
924 924 {
925 925 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
926 926 printf("In commutation_isr1 *** Error sending event to DUMB\n");
927 927 }
928 928 }
929 929
930 930 rtems_isr commutation_isr2( rtems_vector_number vector )
931 931 {
932 932 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
933 933 printf("In commutation_isr2 *** Error sending event to DUMB\n");
934 934 }
935 935 }
936 936
937 937 //****************
938 938 // OTHER FUNCTIONS
939 939 void updateLFRCurrentMode()
940 940 {
941 941 /** This function updates the value of the global variable lfrCurrentMode.
942 942 *
943 943 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
944 944 *
945 945 */
946 946 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
947 947 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
948 948 }
949 949
@@ -1,1367 +1,1489
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 30 ring_node waveform_ring_f3[NB_RING_NODES_F3];
31 31 ring_node *current_ring_node_f0;
32 32 ring_node *ring_node_to_send_swf_f0;
33 33 ring_node *current_ring_node_f1;
34 34 ring_node *ring_node_to_send_swf_f1;
35 35 ring_node *ring_node_to_send_cwf_f1;
36 36 ring_node *current_ring_node_f2;
37 37 ring_node *ring_node_to_send_swf_f2;
38 38 ring_node *ring_node_to_send_cwf_f2;
39 39 ring_node *current_ring_node_f3;
40 40 ring_node *ring_node_to_send_cwf_f3;
41 41
42 42 bool extractSWF = false;
43 43 bool swf_f0_ready = false;
44 44 bool swf_f1_ready = false;
45 45 bool swf_f2_ready = false;
46 46
47 47 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
48 48
49 49 //*********************
50 50 // Interrupt SubRoutine
51 51
52 52 void reset_extractSWF( void )
53 53 {
54 54 extractSWF = false;
55 55 swf_f0_ready = false;
56 56 swf_f1_ready = false;
57 57 swf_f2_ready = false;
58 58 }
59 59
60 void change_f0_buffer( void )
61 {
62 ring_node_to_send_swf_f0 = current_ring_node_f0;
63 current_ring_node_f0 = current_ring_node_f0->next;
64 if ( (waveform_picker_regs->status & 0x01) == 0x01)
65 {
66 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
67 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
68 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
69 }
70 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
71 {
72 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
73 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
74 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
75 }
76 }
77
78 void change_f1_buffer( ring_node *ring_node_to_send )
79 {
80 ring_node_to_send = current_ring_node_f1;
81 current_ring_node_f1 = current_ring_node_f1->next;
82 if ( (waveform_picker_regs->status & 0x04) == 0x04)
83 {
84 ring_node_to_send->coarseTime = waveform_picker_regs->f1_0_coarse_time;
85 ring_node_to_send->fineTime = waveform_picker_regs->f1_0_fine_time;
86 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
87 }
88 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
89 {
90 ring_node_to_send->coarseTime = waveform_picker_regs->f1_1_coarse_time;
91 ring_node_to_send->fineTime = waveform_picker_regs->f1_1_fine_time;
92 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
93 }
94 }
95
96 void change_f2_buffer( ring_node *ring_node_to_send )
97 {
98 ring_node_to_send = current_ring_node_f2;
99 current_ring_node_f2 = current_ring_node_f2->next;
100 if ( (waveform_picker_regs->status & 0x10) == 0x10)
101 {
102 ring_node_to_send->coarseTime = waveform_picker_regs->f2_0_coarse_time;
103 ring_node_to_send->fineTime = waveform_picker_regs->f2_0_fine_time;
104 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
105 }
106 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
107 {
108 ring_node_to_send->coarseTime = waveform_picker_regs->f2_1_coarse_time;
109 ring_node_to_send->fineTime = waveform_picker_regs->f2_1_fine_time;
110 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
111 }
112 }
113
114 void waveforms_isr_f3( void )
115 {
116 rtems_status_code spare_status;
117
118 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
119 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
120 { // in modes other than STANDBY and BURST, send the CWF_F3 data
121 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
122 // (1) change the receiving buffer for the waveform picker
123 ring_node_to_send_cwf_f3 = current_ring_node_f3;
124 current_ring_node_f3 = current_ring_node_f3->next;
125 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
126 // (2) send an event for the waveforms transmission
127 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
128 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
129 }
130 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
131 waveform_picker_regs->status = waveform_picker_regs->status & 0xffff77bf; // reset f3 bits to 0, [0111 0111 1011 1111]
132 }
133 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
134 // (1) change the receiving buffer for the waveform picker
135 ring_node_to_send_cwf_f3 = current_ring_node_f3;
136 current_ring_node_f3 = current_ring_node_f3->next;
137 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
138 // (2) send an event for the waveforms transmission
139 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
140 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
141 }
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
143 waveform_picker_regs->status = waveform_picker_regs->status & 0xffff777f; // reset f3 bits to 0, [0111 0111 0111 1111]
144 }
145 }
146 }
147
148 void waveforms_isr_normal( void )
149 {
150 rtems_status_code status;
151
152 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
153 || ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
154 || ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
155 {
156 // change F0 ring node
157 change_f0_buffer();
158 // change F1 ring node
159 change_f1_buffer( ring_node_to_send_swf_f1 );
160 // change F2 ring node
161 change_f2_buffer( ring_node_to_send_swf_f2 );
162 //
163 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
164 if ( status != RTEMS_SUCCESSFUL)
165 {
166 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
167 }
168 // update status bits except f3 bits
169 waveform_picker_regs->status = waveform_picker_regs->status & 0xffff00c0; // [1000 1000 1100 0000]
170 }
171 }
172
173 void waveforms_isr_burst( void )
174 {
175 rtems_status_code spare_status;
176
177 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
178 // (1) change the receiving buffer for the waveform picker
179 change_f2_buffer( ring_node_to_send_cwf_f2 );
180 // (2) send an event for the waveforms transmission
181 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
182 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
183 }
184 // update f2 status bits only
185 waveform_picker_regs->status = waveform_picker_regs->status & 0xffffbbcf; // [1011 1011 1100 1111] f2 bit = 0
186 }
187 }
188
189 void waveforms_isr_sbm1( void )
190 {
191 rtems_status_code status;
192 rtems_status_code spare_status;
193
194 //***
195 // F1
196 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
197 // (1) change the receiving buffer for the waveform picker
198 change_f1_buffer( ring_node_to_send_cwf_f1 );
199 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
200 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
201 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
202 }
203
204 //***
205 // F0
206 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] one f0 buffer is full
207 swf_f0_ready = true;
208 change_f0_buffer();
209 }
210
211 //***
212 // F2
213 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
214 swf_f2_ready = true;
215 change_f2_buffer( ring_node_to_send_swf_f2 );
216 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
217 {
218 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
219 }
220 }
221 }
222
223 void waveforms_isr_sbm2( void )
224 {
225 rtems_status_code status;
226
227 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
228 // (1) change the receiving buffer for the waveform picker
229 change_f2_buffer( ring_node_to_send_cwf_f2 );
230 // (2) send an event for the waveforms transmission
231 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
232 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
233 }
234 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
235 swf_f0_ready = true;
236 change_f0_buffer();
237 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
238 }
239 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
240 swf_f1_ready = true;
241 change_f1_buffer( ring_node_to_send_swf_f1 );
242 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
243 }
244 }
245
60 246 rtems_isr waveforms_isr( rtems_vector_number vector )
61 247 {
62 248 /** This is the interrupt sub routine called by the waveform picker core.
63 249 *
64 250 * This ISR launch different actions depending mainly on two pieces of information:
65 251 * 1. the values read in the registers of the waveform picker.
66 252 * 2. the current LFR mode.
67 253 *
68 254 */
69 255
70 rtems_status_code status;
256 // STATUS
257 // new error error buffer full
258 // 15 14 13 12 11 10 9 8
259 // f3 f2 f1 f0 f3 f2 f1 f0
260 //
261 // ready buffer
262 // 7 6 5 4 3 2 1 0
263 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
264
71 265 rtems_status_code spare_status;
72 266
73 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
74 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
75 { // in modes other than STANDBY and BURST, send the CWF_F3 data
76 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
77 // (1) change the receiving buffer for the waveform picker
78 ring_node_to_send_cwf_f3 = current_ring_node_f3;
79 current_ring_node_f3 = current_ring_node_f3->next;
80 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
81 // (2) send an event for the waveforms transmission
82 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
267 waveforms_isr_f3();
268
269 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
270 {
83 271 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
84 272 }
85 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
86 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
87 }
88 }
89 273
90 274 switch(lfrCurrentMode)
91 275 {
92 276 //********
93 277 // STANDBY
94 278 case(LFR_MODE_STANDBY):
95 279 break;
96 280
97 281 //******
98 282 // NORMAL
99 283 case(LFR_MODE_NORMAL):
100 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
101 {
102 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
103 }
104 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
105 {
106 // change F0 ring node
107 ring_node_to_send_swf_f0 = current_ring_node_f0;
108 current_ring_node_f0 = current_ring_node_f0->next;
109 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
110 // change F1 ring node
111 ring_node_to_send_swf_f1 = current_ring_node_f1;
112 current_ring_node_f1 = current_ring_node_f1->next;
113 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
114 // change F2 ring node
115 ring_node_to_send_swf_f2 = current_ring_node_f2;
116 current_ring_node_f2 = current_ring_node_f2->next;
117 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
118 //
119 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
120 {
121 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
122 }
123 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
124 }
284 waveforms_isr_normal();
125 285 break;
126 286
127 287 //******
128 288 // BURST
129 289 case(LFR_MODE_BURST):
130 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
131 // (1) change the receiving buffer for the waveform picker
132 ring_node_to_send_cwf_f2 = current_ring_node_f2;
133 current_ring_node_f2 = current_ring_node_f2->next;
134 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
135 // (2) send an event for the waveforms transmission
136 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
137 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
138 }
139 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
140 }
290 waveforms_isr_burst();
141 291 break;
142 292
143 293 //*****
144 294 // SBM1
145 295 case(LFR_MODE_SBM1):
146 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
147 // (1) change the receiving buffer for the waveform picker
148 ring_node_to_send_cwf_f1 = current_ring_node_f1;
149 current_ring_node_f1 = current_ring_node_f1->next;
150 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
151 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
152 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
153 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
154 }
155 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
156 swf_f0_ready = true;
157 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
158 }
159 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
160 swf_f2_ready = true;
161 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
162 }
296 waveforms_isr_sbm1();
163 297 break;
164 298
165 299 //*****
166 300 // SBM2
167 301 case(LFR_MODE_SBM2):
168 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
169 // (1) change the receiving buffer for the waveform picker
170 ring_node_to_send_cwf_f2 = current_ring_node_f2;
171 current_ring_node_f2 = current_ring_node_f2->next;
172 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
173 // (2) send an event for the waveforms transmission
174 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
175 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
176 }
177 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
178 swf_f0_ready = true;
179 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
180 }
181 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
182 swf_f1_ready = true;
183 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
184 }
302 waveforms_isr_sbm2();
185 303 break;
186 304
187 305 //********
188 306 // DEFAULT
189 307 default:
190 308 break;
191 309 }
192 310 }
193 311
194 312 //************
195 313 // RTEMS TASKS
196 314
197 315 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
198 316 {
199 317 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
200 318 *
201 319 * @param unused is the starting argument of the RTEMS task
202 320 *
203 321 * The following data packets are sent by this task:
204 322 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
205 323 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
206 324 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
207 325 *
208 326 */
209 327
210 328 rtems_event_set event_out;
211 329 rtems_id queue_id;
212 330 rtems_status_code status;
213 331 bool resynchronisationEngaged;
214 332
215 333 resynchronisationEngaged = false;
216 334
217 335 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
218 336 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
219 337 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
220 338
221 339 status = get_message_queue_id_send( &queue_id );
222 340 if (status != RTEMS_SUCCESSFUL)
223 341 {
224 342 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
225 343 }
226 344
227 345 BOOT_PRINTF("in WFRM ***\n")
228 346
229 347 while(1){
230 348 // wait for an RTEMS_EVENT
231 349 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
232 350 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
233 351 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
234 352 if(resynchronisationEngaged == false)
235 353 { // engage resynchronisation
236 354 snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->buffer_address);
237 355 resynchronisationEngaged = true;
238 356 }
239 357 else
240 358 { // reset delta_snapshot to the nominal value
241 359 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
242 360 set_wfp_delta_snapshot();
243 361 resynchronisationEngaged = false;
244 362 }
245 363 //
246 364
247 365 if (event_out == RTEMS_EVENT_MODE_NORMAL)
248 366 {
249 367 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
250 368 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
251 369 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
252 370 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
253 371 }
254 372 if (event_out == RTEMS_EVENT_MODE_SBM1)
255 373 {
256 374 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
257 375 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
258 376 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
259 377 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
260 378 }
261 379 if (event_out == RTEMS_EVENT_MODE_SBM2)
262 380 {
263 381 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
264 382 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
265 383 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
266 384 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
267 385 }
268 386 }
269 387 }
270 388
271 389 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
272 390 {
273 391 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
274 392 *
275 393 * @param unused is the starting argument of the RTEMS task
276 394 *
277 395 * The following data packet is sent by this task:
278 396 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
279 397 *
280 398 */
281 399
282 400 rtems_event_set event_out;
283 401 rtems_id queue_id;
284 402 rtems_status_code status;
285 403
286 404 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
287 405 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
288 406
289 407 status = get_message_queue_id_send( &queue_id );
290 408 if (status != RTEMS_SUCCESSFUL)
291 409 {
292 410 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
293 411 }
294 412
295 413 BOOT_PRINTF("in CWF3 ***\n")
296 414
297 415 while(1){
298 416 // wait for an RTEMS_EVENT
299 417 rtems_event_receive( RTEMS_EVENT_0,
300 418 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
301 419 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
302 420 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
303 421 {
304 422 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
305 423 {
306 424 PRINTF("send CWF_LONG_F3\n")
307 425 send_waveform_CWF(
308 426 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
309 427 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
310 428 }
311 429 else
312 430 {
313 431 PRINTF("send CWF_F3 (light)\n")
314 432 send_waveform_CWF3_light(
315 433 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
316 434 headerCWF_F3_light, queue_id );
317 435 }
318 436
319 437 }
320 438 else
321 439 {
322 440 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
323 441 }
324 442 }
325 443 }
326 444
327 445 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
328 446 {
329 447 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
330 448 *
331 449 * @param unused is the starting argument of the RTEMS task
332 450 *
333 451 * The following data packet is sent by this function:
334 452 * - TM_LFR_SCIENCE_BURST_CWF_F2
335 453 * - TM_LFR_SCIENCE_SBM2_CWF_F2
336 454 *
337 455 */
338 456
339 457 rtems_event_set event_out;
340 458 rtems_id queue_id;
341 459 rtems_status_code status;
342 460
343 461 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
344 462 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
345 463
346 464 status = get_message_queue_id_send( &queue_id );
347 465 if (status != RTEMS_SUCCESSFUL)
348 466 {
349 467 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
350 468 }
351 469
352 470 BOOT_PRINTF("in CWF2 ***\n")
353 471
354 472 while(1){
355 473 // wait for an RTEMS_EVENT
356 474 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
357 475 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
358 476 if (event_out == RTEMS_EVENT_MODE_BURST)
359 477 {
360 478 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
361 479 }
362 480 if (event_out == RTEMS_EVENT_MODE_SBM2)
363 481 {
364 482 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
365 483 // launch snapshot extraction if needed
366 484 if (extractSWF == true)
367 485 {
368 486 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
369 487 // extract the snapshot
370 488 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
371 489 // send the snapshot when built
372 490 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
373 491 extractSWF = false;
374 492 }
375 493 if (swf_f0_ready && swf_f1_ready)
376 494 {
377 495 extractSWF = true;
378 496 swf_f0_ready = false;
379 497 swf_f1_ready = false;
380 498 }
381 499 }
382 500 }
383 501 }
384 502
385 503 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
386 504 {
387 505 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
388 506 *
389 507 * @param unused is the starting argument of the RTEMS task
390 508 *
391 509 * The following data packet is sent by this function:
392 510 * - TM_LFR_SCIENCE_SBM1_CWF_F1
393 511 *
394 512 */
395 513
396 514 rtems_event_set event_out;
397 515 rtems_id queue_id;
398 516 rtems_status_code status;
399 517
400 518 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
401 519
402 520 status = get_message_queue_id_send( &queue_id );
403 521 if (status != RTEMS_SUCCESSFUL)
404 522 {
405 523 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
406 524 }
407 525
408 526 BOOT_PRINTF("in CWF1 ***\n")
409 527
410 528 while(1){
411 529 // wait for an RTEMS_EVENT
412 530 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
413 531 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
414 532 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
415 533 // launch snapshot extraction if needed
416 534 if (extractSWF == true)
417 535 {
418 536 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
419 537 // launch the snapshot extraction
420 538 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
421 539 extractSWF = false;
422 540 }
423 541 if (swf_f0_ready == true)
424 542 {
425 543 extractSWF = true;
426 544 swf_f0_ready = false; // this step shall be executed only one time
427 545 }
428 546 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
429 547 {
430 548 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
431 549 swf_f1_ready = false;
432 550 swf_f2_ready = false;
433 551 }
434 552 }
435 553 }
436 554
437 555 rtems_task swbd_task(rtems_task_argument argument)
438 556 {
439 557 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
440 558 *
441 559 * @param unused is the starting argument of the RTEMS task
442 560 *
443 561 */
444 562
445 563 rtems_event_set event_out;
446 564
447 565 BOOT_PRINTF("in SWBD ***\n")
448 566
449 567 while(1){
450 568 // wait for an RTEMS_EVENT
451 569 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
452 570 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
453 571 if (event_out == RTEMS_EVENT_MODE_SBM1)
454 572 {
455 573 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
456 574 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
457 575 }
458 576 else
459 577 {
460 578 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
461 579 }
462 580 }
463 581 }
464 582
465 583 //******************
466 584 // general functions
467 585
468 586 void WFP_init_rings( void )
469 587 {
470 588 // F0 RING
471 589 init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 );
472 590 // F1 RING
473 591 init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 );
474 592 // F2 RING
475 593 init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 );
476 594 // F3 RING
477 595 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
478 596
479 597 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
480 598 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
481 599 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
482 600 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
483 601 }
484 602
485 603 void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] )
486 604 {
487 605 unsigned char i;
488 606
489 607 waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ];
490 608 waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ];
491 609 waveform_ring[0].buffer_address = (int) &wfrm[0];
492 610
493 611 waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ];
494 612 waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ];
495 613 waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ];
496 614
497 615 for(i=1; i<nbNodes-1; i++)
498 616 {
499 617 waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ];
500 618 waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ];
501 619 waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ];
502 620 }
503 621 }
504 622
505 623 void WFP_reset_current_ring_nodes( void )
506 624 {
507 625 current_ring_node_f0 = waveform_ring_f0;
508 626 ring_node_to_send_swf_f0 = waveform_ring_f0;
509 627
510 628 current_ring_node_f1 = waveform_ring_f1;
511 629 ring_node_to_send_cwf_f1 = waveform_ring_f1;
512 630 ring_node_to_send_swf_f1 = waveform_ring_f1;
513 631
514 632 current_ring_node_f2 = waveform_ring_f2;
515 633 ring_node_to_send_cwf_f2 = waveform_ring_f2;
516 634 ring_node_to_send_swf_f2 = waveform_ring_f2;
517 635
518 636 current_ring_node_f3 = waveform_ring_f3;
519 637 ring_node_to_send_cwf_f3 = waveform_ring_f3;
520 638 }
521 639
522 640 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
523 641 {
524 642 unsigned char i;
525 643 int return_value;
526 644
527 645 return_value = LFR_SUCCESSFUL;
528 646
529 647 for (i=0; i<7; i++)
530 648 {
531 649 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
532 650 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
533 651 headerSWF[ i ].reserved = DEFAULT_RESERVED;
534 652 headerSWF[ i ].userApplication = CCSDS_USER_APP;
535 653 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
536 654 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
537 655 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
538 656 if (i == 6)
539 657 {
540 658 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
541 659 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
542 660 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
543 661 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
544 662 }
545 663 else
546 664 {
547 665 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
548 666 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
549 667 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
550 668 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
551 669 }
552 670 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
553 671 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
554 672 headerSWF[ i ].pktNr = i+1; // PKT_NR
555 673 // DATA FIELD HEADER
556 674 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
557 675 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
558 676 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
559 677 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
560 678 // AUXILIARY DATA HEADER
561 679 headerSWF[ i ].time[0] = 0x00;
562 680 headerSWF[ i ].time[0] = 0x00;
563 681 headerSWF[ i ].time[0] = 0x00;
564 682 headerSWF[ i ].time[0] = 0x00;
565 683 headerSWF[ i ].time[0] = 0x00;
566 684 headerSWF[ i ].time[0] = 0x00;
567 685 headerSWF[ i ].sid = sid;
568 686 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
569 687 }
570 688
571 689 return return_value;
572 690 }
573 691
574 692 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
575 693 {
576 694 unsigned int i;
577 695 int return_value;
578 696
579 697 return_value = LFR_SUCCESSFUL;
580 698
581 699 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
582 700 {
583 701 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
584 702 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
585 703 headerCWF[ i ].reserved = DEFAULT_RESERVED;
586 704 headerCWF[ i ].userApplication = CCSDS_USER_APP;
587 705 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
588 706 {
589 707 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
590 708 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
591 709 }
592 710 else
593 711 {
594 712 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
595 713 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
596 714 }
597 715 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
598 716 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
599 717 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
600 718 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
601 719 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
602 720 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
603 721 // DATA FIELD HEADER
604 722 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
605 723 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
606 724 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
607 725 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
608 726 // AUXILIARY DATA HEADER
609 727 headerCWF[ i ].sid = sid;
610 728 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
611 729 headerCWF[ i ].time[0] = 0x00;
612 730 headerCWF[ i ].time[0] = 0x00;
613 731 headerCWF[ i ].time[0] = 0x00;
614 732 headerCWF[ i ].time[0] = 0x00;
615 733 headerCWF[ i ].time[0] = 0x00;
616 734 headerCWF[ i ].time[0] = 0x00;
617 735 }
618 736
619 737 return return_value;
620 738 }
621 739
622 740 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
623 741 {
624 742 unsigned int i;
625 743 int return_value;
626 744
627 745 return_value = LFR_SUCCESSFUL;
628 746
629 747 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
630 748 {
631 749 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
632 750 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
633 751 headerCWF[ i ].reserved = DEFAULT_RESERVED;
634 752 headerCWF[ i ].userApplication = CCSDS_USER_APP;
635 753
636 754 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
637 755 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
638 756
639 757 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
640 758 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
641 759 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
642 760 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
643 761 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
644 762
645 763 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
646 764 // DATA FIELD HEADER
647 765 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
648 766 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
649 767 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
650 768 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
651 769 // AUXILIARY DATA HEADER
652 770 headerCWF[ i ].sid = SID_NORM_CWF_F3;
653 771 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
654 772 headerCWF[ i ].time[0] = 0x00;
655 773 headerCWF[ i ].time[0] = 0x00;
656 774 headerCWF[ i ].time[0] = 0x00;
657 775 headerCWF[ i ].time[0] = 0x00;
658 776 headerCWF[ i ].time[0] = 0x00;
659 777 headerCWF[ i ].time[0] = 0x00;
660 778 }
661 779
662 780 return return_value;
663 781 }
664 782
665 783 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
666 784 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
667 785 {
668 786 /** This function sends SWF CCSDS packets (F2, F1 or F0).
669 787 *
670 788 * @param waveform points to the buffer containing the data that will be send.
671 789 * @param sid is the source identifier of the data that will be sent.
672 790 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
673 791 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
674 792 * contain information to setup the transmission of the data packets.
675 793 *
676 794 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
677 795 *
678 796 */
679 797
680 798 unsigned int i;
681 799 int ret;
682 800 unsigned int coarseTime;
683 801 unsigned int fineTime;
684 802 rtems_status_code status;
685 803 spw_ioctl_pkt_send spw_ioctl_send_SWF;
686 804
687 805 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
688 806 spw_ioctl_send_SWF.options = 0;
689 807
690 808 ret = LFR_DEFAULT;
691 809
692 810 coarseTime = waveform[0];
693 811 fineTime = waveform[1];
694 812
695 813 for (i=0; i<7; i++) // send waveform
696 814 {
697 815 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
698 816 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
699 817 // BUILD THE DATA
700 818 if (i==6) {
701 819 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
702 820 }
703 821 else {
704 822 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
705 823 }
706 824 // SET PACKET SEQUENCE COUNTER
707 825 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
708 826 // SET PACKET TIME
709 827 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
710 828 //
711 829 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
712 830 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
713 831 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
714 832 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
715 833 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
716 834 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
717 835 // SEND PACKET
718 836 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
719 837 if (status != RTEMS_SUCCESSFUL) {
720 838 printf("%d-%d, ERR %d\n", sid, i, (int) status);
721 839 ret = LFR_DEFAULT;
722 840 }
723 841 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
724 842 }
725 843
726 844 return ret;
727 845 }
728 846
729 847 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
730 848 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
731 849 {
732 850 /** This function sends CWF CCSDS packets (F2, F1 or F0).
733 851 *
734 852 * @param waveform points to the buffer containing the data that will be send.
735 853 * @param sid is the source identifier of the data that will be sent.
736 854 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
737 855 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
738 856 * contain information to setup the transmission of the data packets.
739 857 *
740 858 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
741 859 *
742 860 */
743 861
744 862 unsigned int i;
745 863 int ret;
746 864 unsigned int coarseTime;
747 865 unsigned int fineTime;
748 866 rtems_status_code status;
749 867 spw_ioctl_pkt_send spw_ioctl_send_CWF;
750 868
751 869 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
752 870 spw_ioctl_send_CWF.options = 0;
753 871
754 872 ret = LFR_DEFAULT;
755 873
756 874 coarseTime = waveform[0];
757 875 fineTime = waveform[1];
758 876
759 877 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
760 878 {
761 879 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
762 880 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
763 881 // BUILD THE DATA
764 882 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
765 883 // SET PACKET SEQUENCE COUNTER
766 884 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
767 885 // SET PACKET TIME
768 886 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
769 887 //
770 888 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
771 889 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
772 890 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
773 891 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
774 892 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
775 893 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
776 894 // SEND PACKET
777 895 if (sid == SID_NORM_CWF_LONG_F3)
778 896 {
779 897 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
780 898 if (status != RTEMS_SUCCESSFUL) {
781 899 printf("%d-%d, ERR %d\n", sid, i, (int) status);
782 900 ret = LFR_DEFAULT;
783 901 }
784 902 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
785 903 }
786 904 else
787 905 {
788 906 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
789 907 if (status != RTEMS_SUCCESSFUL) {
790 908 printf("%d-%d, ERR %d\n", sid, i, (int) status);
791 909 ret = LFR_DEFAULT;
792 910 }
793 911 }
794 912 }
795 913
796 914 return ret;
797 915 }
798 916
799 917 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
800 918 {
801 919 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
802 920 *
803 921 * @param waveform points to the buffer containing the data that will be send.
804 922 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
805 923 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
806 924 * contain information to setup the transmission of the data packets.
807 925 *
808 926 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
809 927 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
810 928 *
811 929 */
812 930
813 931 unsigned int i;
814 932 int ret;
815 933 unsigned int coarseTime;
816 934 unsigned int fineTime;
817 935 rtems_status_code status;
818 936 spw_ioctl_pkt_send spw_ioctl_send_CWF;
819 937 char *sample;
820 938
821 939 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
822 940 spw_ioctl_send_CWF.options = 0;
823 941
824 942 ret = LFR_DEFAULT;
825 943
826 944 //**********************
827 945 // BUILD CWF3_light DATA
828 946 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
829 947 {
830 948 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
831 949 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
832 950 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
833 951 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
834 952 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
835 953 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
836 954 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
837 955 }
838 956
839 957 coarseTime = waveform[0];
840 958 fineTime = waveform[1];
841 959
842 960 //*********************
843 961 // SEND CWF3_light DATA
844 962 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
845 963 {
846 964 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];
847 965 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
848 966 // BUILD THE DATA
849 967 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
850 968 // SET PACKET SEQUENCE COUNTER
851 969 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
852 970 // SET PACKET TIME
853 971 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
854 972 //
855 973 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
856 974 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
857 975 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
858 976 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
859 977 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
860 978 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
861 979 // SEND PACKET
862 980 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
863 981 if (status != RTEMS_SUCCESSFUL) {
864 982 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
865 983 ret = LFR_DEFAULT;
866 984 }
867 985 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
868 986 }
869 987
870 988 return ret;
871 989 }
872 990
873 991 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
874 992 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
875 993 {
876 994 unsigned long long int acquisitionTimeAsLong;
877 995 unsigned char localAcquisitionTime[6];
878 996 double deltaT;
879 997
880 998 deltaT = 0.;
881 999
882 1000 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
883 1001 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
884 1002 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
885 1003 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
886 1004 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
887 1005 localAcquisitionTime[5] = (unsigned char) ( fineTime );
888 1006
889 1007 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
890 1008 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
891 1009 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
892 1010 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
893 1011 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
894 1012 + ( (unsigned long long int) localAcquisitionTime[5] );
895 1013
896 1014 switch( sid )
897 1015 {
898 1016 case SID_NORM_SWF_F0:
899 1017 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
900 1018 break;
901 1019
902 1020 case SID_NORM_SWF_F1:
903 1021 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
904 1022 break;
905 1023
906 1024 case SID_NORM_SWF_F2:
907 1025 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
908 1026 break;
909 1027
910 1028 case SID_SBM1_CWF_F1:
911 1029 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
912 1030 break;
913 1031
914 1032 case SID_SBM2_CWF_F2:
915 1033 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
916 1034 break;
917 1035
918 1036 case SID_BURST_CWF_F2:
919 1037 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
920 1038 break;
921 1039
922 1040 case SID_NORM_CWF_F3:
923 1041 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
924 1042 break;
925 1043
926 1044 case SID_NORM_CWF_LONG_F3:
927 1045 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
928 1046 break;
929 1047
930 1048 default:
931 1049 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
932 1050 deltaT = 0.;
933 1051 break;
934 1052 }
935 1053
936 1054 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
937 1055 //
938 1056 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
939 1057 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
940 1058 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
941 1059 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
942 1060 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
943 1061 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
944 1062
945 1063 }
946 1064
947 1065 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
948 1066 {
949 1067 unsigned int i;
950 1068 unsigned long long int centerTime_asLong;
951 1069 unsigned long long int acquisitionTimeF0_asLong;
952 1070 unsigned long long int acquisitionTime_asLong;
953 1071 unsigned long long int bufferAcquisitionTime_asLong;
954 1072 unsigned char *ptr1;
955 1073 unsigned char *ptr2;
956 1074 unsigned char *timeCharPtr;
957 1075 unsigned char nb_ring_nodes;
958 1076 unsigned long long int frequency_asLong;
959 1077 unsigned long long int nbTicksPerSample_asLong;
960 1078 unsigned long long int nbSamplesPart1_asLong;
961 1079 unsigned long long int sampleOffset_asLong;
962 1080
963 1081 unsigned int deltaT_F0;
964 1082 unsigned int deltaT_F1;
965 1083 unsigned long long int deltaT_F2;
966 1084
967 1085 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
968 1086 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
969 1087 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
970 1088 sampleOffset_asLong = 0x00;
971 1089
972 1090 // (1) get the f0 acquisition time
973 1091 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) current_ring_node_f0->buffer_address );
974 1092
975 1093 // (2) compute the central reference time
976 1094 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
977 1095
978 1096 // (3) compute the acquisition time of the current snapshot
979 1097 switch(frequencyChannel)
980 1098 {
981 1099 case 1: // 1 is for F1 = 4096 Hz
982 1100 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
983 1101 nb_ring_nodes = NB_RING_NODES_F1;
984 1102 frequency_asLong = 4096;
985 1103 nbTicksPerSample_asLong = 16; // 65536 / 4096;
986 1104 break;
987 1105 case 2: // 2 is for F2 = 256 Hz
988 1106 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
989 1107 nb_ring_nodes = NB_RING_NODES_F2;
990 1108 frequency_asLong = 256;
991 1109 nbTicksPerSample_asLong = 256; // 65536 / 256;
992 1110 break;
993 1111 default:
994 1112 acquisitionTime_asLong = centerTime_asLong;
995 1113 frequency_asLong = 256;
996 1114 nbTicksPerSample_asLong = 256;
997 1115 break;
998 1116 }
999 1117
1000 1118 //****************************************************************************
1001 1119 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1002 1120 for (i=0; i<nb_ring_nodes; i++)
1003 1121 {
1004 1122 PRINTF1("%d ... ", i)
1005 1123 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->buffer_address );
1006 1124 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1007 1125 {
1008 1126 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1009 1127 break;
1010 1128 }
1011 1129 ring_node_to_send = ring_node_to_send->previous;
1012 1130 }
1013 1131
1014 1132 // (5) compute the number of samples to take in the current buffer
1015 1133 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1016 1134 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1017 1135 PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1018 1136
1019 1137 // (6) compute the final acquisition time
1020 1138 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1021 1139 sampleOffset_asLong * nbTicksPerSample_asLong;
1022 1140
1023 1141 // (7) copy the acquisition time at the beginning of the extrated snapshot
1024 1142 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1025 1143 ptr2 = (unsigned char*) wf_snap_extracted;
1026 1144 ptr2[0] = ptr1[ 0 + 2 ];
1027 1145 ptr2[1] = ptr1[ 1 + 2 ];
1028 1146 ptr2[2] = ptr1[ 2 + 2 ];
1029 1147 ptr2[3] = ptr1[ 3 + 2 ];
1030 1148 ptr2[6] = ptr1[ 4 + 2 ];
1031 1149 ptr2[7] = ptr1[ 5 + 2 ];
1032 1150
1033 1151 // re set the synchronization bit
1034 1152 timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address;
1035 1153 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
1036 1154
1037 1155 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
1038 1156 {
1039 1157 nbSamplesPart1_asLong = 0;
1040 1158 }
1041 1159 // copy the part 1 of the snapshot in the extracted buffer
1042 1160 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1043 1161 {
1044 1162 wf_snap_extracted[i + TIME_OFFSET] =
1045 1163 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1046 1164 }
1047 1165 // copy the part 2 of the snapshot in the extracted buffer
1048 1166 ring_node_to_send = ring_node_to_send->next;
1049 1167 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1050 1168 {
1051 1169 wf_snap_extracted[i + TIME_OFFSET] =
1052 1170 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1053 1171 }
1054 1172 }
1055 1173
1056 1174 void snapshot_resynchronization( unsigned char *timePtr )
1057 1175 {
1058 1176 unsigned long long int acquisitionTime;
1059 1177 unsigned long long int centerTime;
1060 1178 unsigned long long int previousTick;
1061 1179 unsigned long long int nextTick;
1062 1180 unsigned long long int deltaPreviousTick;
1063 1181 unsigned long long int deltaNextTick;
1064 1182 unsigned int deltaTickInF2;
1065 1183 double deltaPrevious;
1066 1184 double deltaNext;
1067 1185
1068 1186 acquisitionTime = get_acquisition_time( timePtr );
1069 1187
1070 1188 // compute center time
1071 1189 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1072 1190 previousTick = centerTime - (centerTime & 0xffff);
1073 1191 nextTick = previousTick + 65536;
1074 1192
1075 1193 deltaPreviousTick = centerTime - previousTick;
1076 1194 deltaNextTick = nextTick - centerTime;
1077 1195
1078 1196 deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
1079 1197 deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
1080 1198
1081 1199 printf("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext);
1082 1200 printf("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick);
1083 1201
1084 1202 // which tick is the closest
1085 1203 if (deltaPreviousTick > deltaNextTick)
1086 1204 {
1087 1205 deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
1088 1206 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
1089 1207 printf("correction of = + %u\n", deltaTickInF2);
1090 1208 }
1091 1209 else
1092 1210 {
1093 1211 deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
1094 1212 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
1095 1213 printf("correction of = - %u\n", deltaTickInF2);
1096 1214 }
1097 1215 }
1098 1216
1099 1217 //**************
1100 1218 // wfp registers
1101 1219 void reset_wfp_burst_enable(void)
1102 1220 {
1103 1221 /** This function resets the waveform picker burst_enable register.
1104 1222 *
1105 1223 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1106 1224 *
1107 1225 */
1108 1226
1109 1227 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1110 1228 }
1111 1229
1112 1230 void reset_wfp_status( void )
1113 1231 {
1114 1232 /** This function resets the waveform picker status register.
1115 1233 *
1116 1234 * All status bits are set to 0 [new_err full_err full].
1117 1235 *
1118 1236 */
1119 1237
1120 1238 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1121 1239 }
1122 1240
1123 1241 void reset_waveform_picker_regs(void)
1124 1242 {
1125 1243 /** This function resets the waveform picker module registers.
1126 1244 *
1127 1245 * The registers affected by this function are located at the following offset addresses:
1128 1246 * - 0x00 data_shaping
1129 1247 * - 0x04 run_burst_enable
1130 1248 * - 0x08 addr_data_f0
1131 1249 * - 0x0C addr_data_f1
1132 1250 * - 0x10 addr_data_f2
1133 1251 * - 0x14 addr_data_f3
1134 1252 * - 0x18 status
1135 1253 * - 0x1C delta_snapshot
1136 1254 * - 0x20 delta_f0
1137 1255 * - 0x24 delta_f0_2
1138 1256 * - 0x28 delta_f1
1139 1257 * - 0x2c delta_f2
1140 1258 * - 0x30 nb_data_by_buffer
1141 1259 * - 0x34 nb_snapshot_param
1142 1260 * - 0x38 start_date
1143 1261 * - 0x3c nb_word_in_buffer
1144 1262 *
1145 1263 */
1146 1264
1147 1265 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1148 1266 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1149 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1150 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1151 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1152 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14
1267 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1268 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1269 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1270 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1271 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1272 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1273 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1274 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1153 1275 reset_wfp_status(); // 0x18
1154 1276 //
1155 1277 set_wfp_delta_snapshot(); // 0x1c
1156 1278 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1157 1279 set_wfp_delta_f1(); // 0x28
1158 1280 set_wfp_delta_f2(); // 0x2c
1159 1281 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1160 1282 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1161 1283 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1162 1284 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1163 1285 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1164 1286 // 2688 = 8 * 336
1165 1287 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1166 1288 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1167 1289 waveform_picker_regs->start_date = 0x00; // 0x38
1168 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1290 waveform_picker_regs->buffer_length = 0x1f8; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1169 1291 }
1170 1292
1171 1293 void set_wfp_data_shaping( void )
1172 1294 {
1173 1295 /** This function sets the data_shaping register of the waveform picker module.
1174 1296 *
1175 1297 * The value is read from one field of the parameter_dump_packet structure:\n
1176 1298 * bw_sp0_sp1_r0_r1
1177 1299 *
1178 1300 */
1179 1301
1180 1302 unsigned char data_shaping;
1181 1303
1182 1304 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1183 1305 // waveform picker : [R1 R0 SP1 SP0 BW]
1184 1306
1185 1307 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1186 1308
1187 1309 waveform_picker_regs->data_shaping =
1188 1310 ( (data_shaping & 0x10) >> 4 ) // BW
1189 1311 + ( (data_shaping & 0x08) >> 2 ) // SP0
1190 1312 + ( (data_shaping & 0x04) ) // SP1
1191 1313 + ( (data_shaping & 0x02) << 2 ) // R0
1192 1314 + ( (data_shaping & 0x01) << 4 ); // R1
1193 1315 }
1194 1316
1195 1317 void set_wfp_burst_enable_register( unsigned char mode )
1196 1318 {
1197 1319 /** This function sets the waveform picker burst_enable register depending on the mode.
1198 1320 *
1199 1321 * @param mode is the LFR mode to launch.
1200 1322 *
1201 1323 * The burst bits shall be before the enable bits.
1202 1324 *
1203 1325 */
1204 1326
1205 1327 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1206 1328 // the burst bits shall be set first, before the enable bits
1207 1329 switch(mode) {
1208 1330 case(LFR_MODE_NORMAL):
1209 1331 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1210 1332 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1211 1333 break;
1212 1334 case(LFR_MODE_BURST):
1213 1335 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1214 1336 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1215 1337 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1216 1338 break;
1217 1339 case(LFR_MODE_SBM1):
1218 1340 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1219 1341 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1220 1342 break;
1221 1343 case(LFR_MODE_SBM2):
1222 1344 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1223 1345 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1224 1346 break;
1225 1347 default:
1226 1348 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1227 1349 break;
1228 1350 }
1229 1351 }
1230 1352
1231 1353 void set_wfp_delta_snapshot( void )
1232 1354 {
1233 1355 /** This function sets the delta_snapshot register of the waveform picker module.
1234 1356 *
1235 1357 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1236 1358 * - sy_lfr_n_swf_p[0]
1237 1359 * - sy_lfr_n_swf_p[1]
1238 1360 *
1239 1361 */
1240 1362
1241 1363 unsigned int delta_snapshot;
1242 1364 unsigned int delta_snapshot_in_T2;
1243 1365
1244 1366 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1245 1367 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1246 1368
1247 1369 delta_snapshot_in_T2 = delta_snapshot * 256;
1248 1370 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1249 1371 }
1250 1372
1251 1373 void set_wfp_delta_f0_f0_2( void )
1252 1374 {
1253 1375 unsigned int delta_snapshot;
1254 1376 unsigned int nb_samples_per_snapshot;
1255 1377 float delta_f0_in_float;
1256 1378
1257 1379 delta_snapshot = waveform_picker_regs->delta_snapshot;
1258 1380 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1259 1381 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1260 1382
1261 1383 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1262 1384 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1263 1385 }
1264 1386
1265 1387 void set_wfp_delta_f1( void )
1266 1388 {
1267 1389 unsigned int delta_snapshot;
1268 1390 unsigned int nb_samples_per_snapshot;
1269 1391 float delta_f1_in_float;
1270 1392
1271 1393 delta_snapshot = waveform_picker_regs->delta_snapshot;
1272 1394 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1273 1395 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1274 1396
1275 1397 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1276 1398 }
1277 1399
1278 1400 void set_wfp_delta_f2()
1279 1401 {
1280 1402 unsigned int delta_snapshot;
1281 1403 unsigned int nb_samples_per_snapshot;
1282 1404
1283 1405 delta_snapshot = waveform_picker_regs->delta_snapshot;
1284 1406 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1285 1407
1286 1408 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1287 1409 }
1288 1410
1289 1411 //*****************
1290 1412 // local parameters
1291 1413
1292 1414 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1293 1415 {
1294 1416 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1295 1417 *
1296 1418 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1297 1419 * @param sid is the source identifier of the packet being updated.
1298 1420 *
1299 1421 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1300 1422 * The sequence counters shall wrap around from 2^14 to zero.
1301 1423 * The sequence counter shall start at zero at startup.
1302 1424 *
1303 1425 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1304 1426 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1305 1427 *
1306 1428 */
1307 1429
1308 1430 unsigned short *sequence_cnt;
1309 1431 unsigned short segmentation_grouping_flag;
1310 1432 unsigned short new_packet_sequence_control;
1311 1433 rtems_mode initial_mode_set;
1312 1434 rtems_mode current_mode_set;
1313 1435 rtems_status_code status;
1314 1436
1315 1437 //******************************************
1316 1438 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1317 1439 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1318 1440
1319 1441 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1320 1442 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1321 1443 || (sid == SID_BURST_CWF_F2)
1322 1444 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1323 1445 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1324 1446 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1325 1447 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1326 1448 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1327 1449 {
1328 1450 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1329 1451 }
1330 1452 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1331 1453 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1332 1454 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1333 1455 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1334 1456 {
1335 1457 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1336 1458 }
1337 1459 else
1338 1460 {
1339 1461 sequence_cnt = (unsigned short *) NULL;
1340 1462 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1341 1463 }
1342 1464
1343 1465 if (sequence_cnt != NULL)
1344 1466 {
1345 1467 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1346 1468 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1347 1469
1348 1470 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1349 1471
1350 1472 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1351 1473 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1352 1474
1353 1475 // increment the sequence counter
1354 1476 if ( *sequence_cnt < SEQ_CNT_MAX)
1355 1477 {
1356 1478 *sequence_cnt = *sequence_cnt + 1;
1357 1479 }
1358 1480 else
1359 1481 {
1360 1482 *sequence_cnt = 0;
1361 1483 }
1362 1484 }
1363 1485
1364 1486 //***********************************
1365 1487 // RESET THE MODE OF THE CALLING TASK
1366 1488 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1367 1489 }
@@ -1,234 +1,234
1 1 #############################################################################
2 2 # Makefile for building: bin/timegen
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Sep 25 13:22:11 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Fri Oct 24 13:36:54 2014
4 4 # Project: timegen-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile timegen-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 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=0 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -g -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -Isrc -Iheader -Iheader/processing -Isrc/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS = -g
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/tc_handler.c \
47 47 src/fsw_misc.c \
48 48 src/fsw_init.c \
49 49 src/fsw_globals.c \
50 50 src/fsw_spacewire.c \
51 51 src/tc_acceptance.c \
52 52 src/LFR_basic-parameters/basic_parameters.c
53 53 OBJECTS = obj/tc_handler.o \
54 54 obj/fsw_misc.o \
55 55 obj/fsw_init.o \
56 56 obj/fsw_globals.o \
57 57 obj/fsw_spacewire.o \
58 58 obj/tc_acceptance.o \
59 59 obj/basic_parameters.o
60 60 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
61 61 /usr/lib64/qt4/mkspecs/common/linux.conf \
62 62 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
63 63 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
64 64 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
65 65 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
66 66 /usr/lib64/qt4/mkspecs/qconfig.pri \
67 67 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
68 68 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
69 69 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
70 70 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
71 71 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
72 72 sparc.pri \
73 73 /usr/lib64/qt4/mkspecs/features/debug.prf \
74 74 /usr/lib64/qt4/mkspecs/features/default_post.prf \
75 75 /usr/lib64/qt4/mkspecs/features/shared.prf \
76 76 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
77 77 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
78 78 /usr/lib64/qt4/mkspecs/features/resources.prf \
79 79 /usr/lib64/qt4/mkspecs/features/uic.prf \
80 80 /usr/lib64/qt4/mkspecs/features/yacc.prf \
81 81 /usr/lib64/qt4/mkspecs/features/lex.prf \
82 82 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
83 83 timegen-qt.pro
84 84 QMAKE_TARGET = timegen
85 85 DESTDIR = bin/
86 86 TARGET = bin/timegen
87 87
88 88 first: all
89 89 ####### Implicit rules
90 90
91 91 .SUFFIXES: .o .c .cpp .cc .cxx .C
92 92
93 93 .cpp.o:
94 94 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
95 95
96 96 .cc.o:
97 97 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
98 98
99 99 .cxx.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .C.o:
103 103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 .c.o:
106 106 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
107 107
108 108 ####### Build rules
109 109
110 110 all: Makefile $(TARGET)
111 111
112 112 $(TARGET): $(OBJECTS)
113 113 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
114 114 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
115 115 { test -n "$(DESTDIR)" && DESTDIR="$(DESTDIR)" || DESTDIR=.; } && test $$(gdb --version | sed -e 's,[^0-9][^0-9]*\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $$DESTDIR" -ex quit '$(TARGET)' && test -f $(TARGET).gdb-index && sparc-rtems-objcopy --add-section '.gdb_index=$(TARGET).gdb-index' --set-section-flags '.gdb_index=readonly' '$(TARGET)' '$(TARGET)' && rm -f $(TARGET).gdb-index || true
116 116
117 117 Makefile: timegen-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
118 118 /usr/lib64/qt4/mkspecs/common/linux.conf \
119 119 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
120 120 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
121 121 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
122 122 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
123 123 /usr/lib64/qt4/mkspecs/qconfig.pri \
124 124 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
125 125 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
126 126 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
127 127 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
128 128 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
129 129 sparc.pri \
130 130 /usr/lib64/qt4/mkspecs/features/debug.prf \
131 131 /usr/lib64/qt4/mkspecs/features/default_post.prf \
132 132 /usr/lib64/qt4/mkspecs/features/shared.prf \
133 133 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
134 134 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
135 135 /usr/lib64/qt4/mkspecs/features/resources.prf \
136 136 /usr/lib64/qt4/mkspecs/features/uic.prf \
137 137 /usr/lib64/qt4/mkspecs/features/yacc.prf \
138 138 /usr/lib64/qt4/mkspecs/features/lex.prf \
139 139 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
140 140 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile timegen-qt.pro
141 141 /usr/lib64/qt4/mkspecs/common/unix.conf:
142 142 /usr/lib64/qt4/mkspecs/common/linux.conf:
143 143 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
144 144 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
145 145 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
146 146 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
147 147 /usr/lib64/qt4/mkspecs/qconfig.pri:
148 148 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
149 149 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
150 150 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
151 151 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
152 152 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
153 153 sparc.pri:
154 154 /usr/lib64/qt4/mkspecs/features/debug.prf:
155 155 /usr/lib64/qt4/mkspecs/features/default_post.prf:
156 156 /usr/lib64/qt4/mkspecs/features/shared.prf:
157 157 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
158 158 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
159 159 /usr/lib64/qt4/mkspecs/features/resources.prf:
160 160 /usr/lib64/qt4/mkspecs/features/uic.prf:
161 161 /usr/lib64/qt4/mkspecs/features/yacc.prf:
162 162 /usr/lib64/qt4/mkspecs/features/lex.prf:
163 163 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
164 164 qmake: FORCE
165 165 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile timegen-qt.pro
166 166
167 167 dist:
168 168 @$(CHK_DIR_EXISTS) obj/timegen1.0.0 || $(MKDIR) obj/timegen1.0.0
169 169 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/timegen1.0.0/ && (cd `dirname obj/timegen1.0.0` && $(TAR) timegen1.0.0.tar timegen1.0.0 && $(COMPRESS) timegen1.0.0.tar) && $(MOVE) `dirname obj/timegen1.0.0`/timegen1.0.0.tar.gz . && $(DEL_FILE) -r obj/timegen1.0.0
170 170
171 171
172 172 clean:compiler_clean
173 173 -$(DEL_FILE) $(OBJECTS)
174 174 -$(DEL_FILE) *~ core *.core
175 175
176 176
177 177 ####### Sub-libraries
178 178
179 179 distclean: clean
180 180 -$(DEL_FILE) $(TARGET)
181 181 -$(DEL_FILE) Makefile
182 182
183 183
184 184 grmon:
185 185 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
186 186
187 187 check: first
188 188
189 189 compiler_rcc_make_all:
190 190 compiler_rcc_clean:
191 191 compiler_uic_make_all:
192 192 compiler_uic_clean:
193 193 compiler_image_collection_make_all: qmake_image_collection.cpp
194 194 compiler_image_collection_clean:
195 195 -$(DEL_FILE) qmake_image_collection.cpp
196 196 compiler_yacc_decl_make_all:
197 197 compiler_yacc_decl_clean:
198 198 compiler_yacc_impl_make_all:
199 199 compiler_yacc_impl_clean:
200 200 compiler_lex_make_all:
201 201 compiler_lex_clean:
202 202 compiler_clean:
203 203
204 204 ####### Compile
205 205
206 206 obj/tc_handler.o: src/tc_handler.c
207 207 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o src/tc_handler.c
208 208
209 209 obj/fsw_misc.o: src/fsw_misc.c
210 210 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o src/fsw_misc.c
211 211
212 212 obj/fsw_init.o: src/fsw_init.c src/fsw_config.c
213 213 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o src/fsw_init.c
214 214
215 215 obj/fsw_globals.o: src/fsw_globals.c
216 216 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o src/fsw_globals.c
217 217
218 218 obj/fsw_spacewire.o: src/fsw_spacewire.c
219 219 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o src/fsw_spacewire.c
220 220
221 221 obj/tc_acceptance.o: src/tc_acceptance.c
222 222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o src/tc_acceptance.c
223 223
224 224 obj/basic_parameters.o: src/LFR_basic-parameters/basic_parameters.c
225 225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o src/LFR_basic-parameters/basic_parameters.c
226 226
227 227 ####### Install
228 228
229 229 install: FORCE
230 230
231 231 uninstall: FORCE
232 232
233 233 FORCE:
234 234
1 NO CONTENT: modified file, binary diff hidden
@@ -1,81 +1,81
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
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=0 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=0 # internal
14 DEFINES += SW_VERSION_N4=1 # 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 = timegen
49 49
50 50 INCLUDEPATH += \
51 51 ./src \
52 52 ./header \
53 53 ./header/processing \
54 54 ./src/LFR_basic-parameters
55 55
56 56 SOURCES += \
57 57 ./src/tc_handler.c \
58 58 ./src/fsw_misc.c \
59 59 ./src/fsw_init.c \
60 60 ./src/fsw_globals.c \
61 61 ./src/fsw_spacewire.c \
62 62 ./src/tc_acceptance.c \
63 63 ./src/LFR_basic-parameters/basic_parameters.c
64 64
65 65 HEADERS += \
66 66 ./header/tc_handler.h \
67 67 ./header/grlib_regs.h \
68 68 ./header/fsw_params.h \
69 69 ./header/fsw_misc.h \
70 70 ./header/fsw_init.h \
71 71 ./header/ccsds_types.h \
72 72 ./header/fsw_spacewire.h \
73 73 ./header/tc_acceptance.h \
74 74 ./header/fsw_params_nb_bytes.h \
75 75 ./header/fsw_params_processing.h \
76 76 ./header/fsw_params_wf_handler.h \
77 77 ./header/lfr_cpu_usage_report.h \
78 78 ./src/LFR_basic-parameters/basic_parameters.h \
79 79 ./src/LFR_basic-parameters/basic_parameters_params.h \
80 80 ../header/TC_types.h
81 81
General Comments 0
You need to be logged in to leave comments. Login now