@@ -0,0 +1,19 | |||
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
|
3 | ||
|
4 | #include "tc_handler.h" | |
|
5 | ||
|
6 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
|
7 | int action_load_normal_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
8 | int action_load_burst_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
9 | int action_load_sbm1_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
10 | int action_load_sbm2_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
11 | int action_dump_par(rtems_id queue_id ); | |
|
12 | ||
|
13 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
14 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
15 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
16 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
17 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
|
18 | ||
|
19 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -0,0 +1,377 | |||
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
|
2 | * | |
|
3 | * @file | |
|
4 | * @author P. LEROY | |
|
5 | * | |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
|
12 | * | |
|
13 | */ | |
|
14 | ||
|
15 | #include "tc_load_dump_parameters.h" | |
|
16 | ||
|
17 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
|
18 | { | |
|
19 | /** This function updates the LFR registers with the incoming common parameters. | |
|
20 | * | |
|
21 | * @param TC points to the TeleCommand packet that is being processed | |
|
22 | * | |
|
23 | * | |
|
24 | */ | |
|
25 | parameter_dump_packet.unused0 = TC->dataAndCRC[0]; | |
|
26 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1]; | |
|
27 | set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1); | |
|
28 | return LFR_SUCCESSFUL; | |
|
29 | } | |
|
30 | ||
|
31 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
32 | { | |
|
33 | /** This function updates the LFR registers with the incoming normal parameters. | |
|
34 | * | |
|
35 | * @param TC points to the TeleCommand packet that is being processed | |
|
36 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
37 | * | |
|
38 | */ | |
|
39 | int result; | |
|
40 | int flag; | |
|
41 | ||
|
42 | flag = LFR_SUCCESSFUL; | |
|
43 | result = LFR_SUCCESSFUL; | |
|
44 | ||
|
45 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
|
46 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
47 | flag = LFR_DEFAULT; | |
|
48 | } | |
|
49 | ||
|
50 | //*************** | |
|
51 | // sy_lfr_n_swf_l | |
|
52 | if (flag == LFR_SUCCESSFUL) | |
|
53 | { | |
|
54 | result = set_sy_lfr_n_swf_l( TC, queue_id ); | |
|
55 | if (result != LFR_SUCCESSFUL) | |
|
56 | { | |
|
57 | flag = LFR_DEFAULT; | |
|
58 | } | |
|
59 | } | |
|
60 | ||
|
61 | //*************** | |
|
62 | // sy_lfr_n_swf_p | |
|
63 | if (flag == LFR_SUCCESSFUL) | |
|
64 | { | |
|
65 | result = set_sy_lfr_n_swf_p( TC, queue_id ); | |
|
66 | if (result != LFR_SUCCESSFUL) | |
|
67 | { | |
|
68 | flag = LFR_DEFAULT; | |
|
69 | } | |
|
70 | } | |
|
71 | ||
|
72 | //*************** | |
|
73 | // sy_lfr_n_asm_p | |
|
74 | if (flag == LFR_SUCCESSFUL) | |
|
75 | { | |
|
76 | result = set_sy_lfr_n_asm_p( TC, queue_id ); | |
|
77 | if (result != LFR_SUCCESSFUL) | |
|
78 | { | |
|
79 | flag = LFR_DEFAULT; | |
|
80 | } | |
|
81 | } | |
|
82 | ||
|
83 | //*************** | |
|
84 | // sy_lfr_n_bp_p0 | |
|
85 | if (flag == LFR_SUCCESSFUL) | |
|
86 | { | |
|
87 | result = set_sy_lfr_n_bp_p0( TC, queue_id ); | |
|
88 | if (result != LFR_SUCCESSFUL) | |
|
89 | { | |
|
90 | flag = LFR_DEFAULT; | |
|
91 | } | |
|
92 | } | |
|
93 | ||
|
94 | //*************** | |
|
95 | // sy_lfr_n_bp_p1 | |
|
96 | if (flag == LFR_SUCCESSFUL) | |
|
97 | { | |
|
98 | result = set_sy_lfr_n_bp_p1( TC, queue_id ); | |
|
99 | if (result != LFR_SUCCESSFUL) | |
|
100 | { | |
|
101 | flag = LFR_DEFAULT; | |
|
102 | } | |
|
103 | } | |
|
104 | ||
|
105 | return result; | |
|
106 | } | |
|
107 | ||
|
108 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
109 | { | |
|
110 | /** This function updates the LFR registers with the incoming burst parameters. | |
|
111 | * | |
|
112 | * @param TC points to the TeleCommand packet that is being processed | |
|
113 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
114 | * | |
|
115 | */ | |
|
116 | int result; | |
|
117 | unsigned char lfrMode; | |
|
118 | ||
|
119 | result = LFR_DEFAULT; | |
|
120 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
121 | ||
|
122 | if ( lfrMode == LFR_MODE_BURST ) { | |
|
123 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
124 | result = LFR_DEFAULT; | |
|
125 | } | |
|
126 | else { | |
|
127 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0]; | |
|
128 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1]; | |
|
129 | ||
|
130 | result = LFR_SUCCESSFUL; | |
|
131 | } | |
|
132 | ||
|
133 | return result; | |
|
134 | } | |
|
135 | ||
|
136 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
137 | { | |
|
138 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
|
139 | * | |
|
140 | * @param TC points to the TeleCommand packet that is being processed | |
|
141 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
142 | * | |
|
143 | */ | |
|
144 | int result; | |
|
145 | unsigned char lfrMode; | |
|
146 | ||
|
147 | result = LFR_DEFAULT; | |
|
148 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
149 | ||
|
150 | if ( lfrMode == LFR_MODE_SBM1 ) { | |
|
151 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
152 | result = LFR_DEFAULT; | |
|
153 | } | |
|
154 | else { | |
|
155 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0]; | |
|
156 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1]; | |
|
157 | ||
|
158 | result = LFR_SUCCESSFUL; | |
|
159 | } | |
|
160 | ||
|
161 | return result; | |
|
162 | } | |
|
163 | ||
|
164 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
165 | { | |
|
166 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
|
167 | * | |
|
168 | * @param TC points to the TeleCommand packet that is being processed | |
|
169 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
170 | * | |
|
171 | */ | |
|
172 | ||
|
173 | int result; | |
|
174 | unsigned char lfrMode; | |
|
175 | ||
|
176 | result = LFR_DEFAULT; | |
|
177 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
178 | ||
|
179 | if ( lfrMode == LFR_MODE_SBM2 ) { | |
|
180 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
181 | result = LFR_DEFAULT; | |
|
182 | } | |
|
183 | else { | |
|
184 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0]; | |
|
185 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1]; | |
|
186 | ||
|
187 | result = LFR_SUCCESSFUL; | |
|
188 | } | |
|
189 | ||
|
190 | return result; | |
|
191 | } | |
|
192 | ||
|
193 | int action_dump_par( rtems_id queue_id ) | |
|
194 | { | |
|
195 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
|
196 | * | |
|
197 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
|
198 | * | |
|
199 | * @return RTEMS directive status codes: | |
|
200 | * - RTEMS_SUCCESSFUL - message sent successfully | |
|
201 | * - RTEMS_INVALID_ID - invalid queue id | |
|
202 | * - RTEMS_INVALID_SIZE - invalid message size | |
|
203 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
|
204 | * - RTEMS_UNSATISFIED - out of message buffers | |
|
205 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
|
206 | * | |
|
207 | */ | |
|
208 | ||
|
209 | int status; | |
|
210 | ||
|
211 | // SEND DATA | |
|
212 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
|
213 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
|
214 | if (status != RTEMS_SUCCESSFUL) { | |
|
215 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
|
216 | } | |
|
217 | ||
|
218 | return status; | |
|
219 | } | |
|
220 | ||
|
221 | //*********************** | |
|
222 | // NORMAL MODE PARAMETERS | |
|
223 | ||
|
224 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
|
225 | { | |
|
226 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
|
227 | * | |
|
228 | * @param TC points to the TeleCommand packet that is being processed | |
|
229 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
230 | * | |
|
231 | */ | |
|
232 | ||
|
233 | unsigned int tmp; | |
|
234 | int result; | |
|
235 | unsigned char msb; | |
|
236 | unsigned char lsb; | |
|
237 | ||
|
238 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ]; | |
|
239 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ]; | |
|
240 | ||
|
241 | tmp = ( unsigned int ) floor( | |
|
242 | ( ( msb*256 ) + lsb ) / 16 | |
|
243 | ) * 16; | |
|
244 | ||
|
245 | if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16 | |
|
246 | { // 2048 is the maximum limit due to thesize of the buffers | |
|
247 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb ); | |
|
248 | result = WRONG_APP_DATA; | |
|
249 | } | |
|
250 | else if (tmp != 2048) | |
|
251 | { | |
|
252 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); | |
|
253 | result = FUNCT_NOT_IMPL; | |
|
254 | } | |
|
255 | else | |
|
256 | { | |
|
257 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8); | |
|
258 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp ); | |
|
259 | result = LFR_SUCCESSFUL; | |
|
260 | } | |
|
261 | ||
|
262 | return result; | |
|
263 | } | |
|
264 | ||
|
265 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
|
266 | { | |
|
267 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
|
268 | * | |
|
269 | * @param TC points to the TeleCommand packet that is being processed | |
|
270 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
271 | * | |
|
272 | */ | |
|
273 | ||
|
274 | unsigned int tmp; | |
|
275 | int result; | |
|
276 | unsigned char msb; | |
|
277 | unsigned char lsb; | |
|
278 | ||
|
279 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ]; | |
|
280 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ]; | |
|
281 | ||
|
282 | tmp = ( unsigned int ) floor( | |
|
283 | ( ( msb*256 ) + lsb ) / 8 | |
|
284 | ) * 8; | |
|
285 | ||
|
286 | if ( (tmp < 16) || (tmp > 65528) ) | |
|
287 | { | |
|
288 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb ); | |
|
289 | result = WRONG_APP_DATA; | |
|
290 | } | |
|
291 | else | |
|
292 | { | |
|
293 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8); | |
|
294 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp ); | |
|
295 | result = LFR_SUCCESSFUL; | |
|
296 | } | |
|
297 | ||
|
298 | return result; | |
|
299 | } | |
|
300 | ||
|
301 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
|
302 | { | |
|
303 | /** This function sets the time between two full spectral matrices transmission, in s (sy_lfr_n_asm_p). | |
|
304 | * | |
|
305 | * @param TC points to the TeleCommand packet that is being processed | |
|
306 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
307 | * | |
|
308 | */ | |
|
309 | ||
|
310 | int result; | |
|
311 | unsigned char msb; | |
|
312 | unsigned char lsb; | |
|
313 | ||
|
314 | msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ]; | |
|
315 | lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ]; | |
|
316 | ||
|
317 | parameter_dump_packet.sy_lfr_n_asm_p[0] = msb; | |
|
318 | parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb; | |
|
319 | result = LFR_SUCCESSFUL; | |
|
320 | ||
|
321 | return result; | |
|
322 | } | |
|
323 | ||
|
324 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
|
325 | { | |
|
326 | /** This function sets the time between two basic parameter sets, in s (sy_lfr_n_bp_p0). | |
|
327 | * | |
|
328 | * @param TC points to the TeleCommand packet that is being processed | |
|
329 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
330 | * | |
|
331 | */ | |
|
332 | ||
|
333 | int status; | |
|
334 | ||
|
335 | status = LFR_SUCCESSFUL; | |
|
336 | ||
|
337 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ]; | |
|
338 | ||
|
339 | return status; | |
|
340 | } | |
|
341 | ||
|
342 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
343 | { | |
|
344 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
|
345 | * | |
|
346 | * @param TC points to the TeleCommand packet that is being processed | |
|
347 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
|
348 | * | |
|
349 | */ | |
|
350 | ||
|
351 | int status; | |
|
352 | ||
|
353 | status = LFR_SUCCESSFUL; | |
|
354 | ||
|
355 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ]; | |
|
356 | ||
|
357 | return status; | |
|
358 | } | |
|
359 | ||
|
360 | //********************** | |
|
361 | // BURST MODE PARAMETERS | |
|
362 | ||
|
363 | //********************* | |
|
364 | // SBM1 MODE PARAMETERS | |
|
365 | ||
|
366 | //********************* | |
|
367 | // SBM2 MODE PARAMETERS | |
|
368 | ||
|
369 | ||
|
370 | ||
|
371 | ||
|
372 | ||
|
373 | ||
|
374 | ||
|
375 | ||
|
376 | ||
|
377 |
@@ -1,233 +1,243 | |||
|
1 | 1 | ############################################################################# |
|
2 | 2 | # Makefile for building: bin/fsw |
|
3 |
# Generated by qmake (2.01a) (Qt 4.8.5) on: |
|
|
3 | # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 17 10:12:11 2013 | |
|
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=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=15 -DPRINT_MESSAGES_ON_CONSOLE |
|
14 | 14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
15 | 15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
16 | 16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header |
|
17 | 17 | LINK = sparc-rtems-g++ |
|
18 | 18 | LFLAGS = |
|
19 | 19 | LIBS = $(SUBLIBS) |
|
20 | 20 | AR = sparc-rtems-ar rcs |
|
21 | 21 | RANLIB = |
|
22 | 22 | QMAKE = /usr/bin/qmake-qt4 |
|
23 | 23 | TAR = tar -cf |
|
24 | 24 | COMPRESS = gzip -9f |
|
25 | 25 | COPY = cp -f |
|
26 | 26 | SED = sed |
|
27 | 27 | COPY_FILE = $(COPY) |
|
28 | 28 | COPY_DIR = $(COPY) -r |
|
29 | 29 | STRIP = sparc-rtems-strip |
|
30 | 30 | INSTALL_FILE = install -m 644 -p |
|
31 | 31 | INSTALL_DIR = $(COPY_DIR) |
|
32 | 32 | INSTALL_PROGRAM = install -m 755 -p |
|
33 | 33 | DEL_FILE = rm -f |
|
34 | 34 | SYMLINK = ln -f -s |
|
35 | 35 | DEL_DIR = rmdir |
|
36 | 36 | MOVE = mv -f |
|
37 | 37 | CHK_DIR_EXISTS= test -d |
|
38 | 38 | MKDIR = mkdir -p |
|
39 | 39 | |
|
40 | 40 | ####### Output directory |
|
41 | 41 | |
|
42 | 42 | OBJECTS_DIR = obj/ |
|
43 | 43 | |
|
44 | 44 | ####### Files |
|
45 | 45 | |
|
46 | 46 | SOURCES = ../src/wf_handler.c \ |
|
47 | 47 | ../src/tc_handler.c \ |
|
48 | 48 | ../src/fsw_processing.c \ |
|
49 | 49 | ../src/fsw_misc.c \ |
|
50 | 50 | ../src/fsw_init.c \ |
|
51 | 51 | ../src/fsw_globals.c \ |
|
52 | ../src/fsw_spacewire.c | |
|
52 | ../src/fsw_spacewire.c \ | |
|
53 | ../src/tc_load_dump_parameters.c \ | |
|
54 | ../src/tm_lfr_tc_exe.c | |
|
53 | 55 | OBJECTS = obj/wf_handler.o \ |
|
54 | 56 | obj/tc_handler.o \ |
|
55 | 57 | obj/fsw_processing.o \ |
|
56 | 58 | obj/fsw_misc.o \ |
|
57 | 59 | obj/fsw_init.o \ |
|
58 | 60 | obj/fsw_globals.o \ |
|
59 | obj/fsw_spacewire.o | |
|
61 | obj/fsw_spacewire.o \ | |
|
62 | obj/tc_load_dump_parameters.o \ | |
|
63 | obj/tm_lfr_tc_exe.o | |
|
60 | 64 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
61 | 65 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
62 | 66 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
63 | 67 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
64 | 68 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
65 | 69 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
66 | 70 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
67 | 71 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
68 | 72 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
69 | 73 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
70 | 74 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
71 | 75 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
72 | 76 | sparc.pri \ |
|
73 | 77 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
74 | 78 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
75 | 79 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
76 | 80 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
77 | 81 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
78 | 82 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
79 | 83 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
80 | 84 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
81 | 85 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
82 | 86 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
83 | 87 | fsw-qt.pro |
|
84 | 88 | QMAKE_TARGET = fsw |
|
85 | 89 | DESTDIR = bin/ |
|
86 | 90 | TARGET = bin/fsw |
|
87 | 91 | |
|
88 | 92 | first: all |
|
89 | 93 | ####### Implicit rules |
|
90 | 94 | |
|
91 | 95 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
92 | 96 | |
|
93 | 97 | .cpp.o: |
|
94 | 98 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
95 | 99 | |
|
96 | 100 | .cc.o: |
|
97 | 101 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
98 | 102 | |
|
99 | 103 | .cxx.o: |
|
100 | 104 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
101 | 105 | |
|
102 | 106 | .C.o: |
|
103 | 107 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
104 | 108 | |
|
105 | 109 | .c.o: |
|
106 | 110 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
107 | 111 | |
|
108 | 112 | ####### Build rules |
|
109 | 113 | |
|
110 | 114 | all: Makefile $(TARGET) |
|
111 | 115 | |
|
112 | 116 | $(TARGET): $(OBJECTS) |
|
113 | 117 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
114 | 118 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
115 | 119 | |
|
116 | 120 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
117 | 121 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
118 | 122 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
119 | 123 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
120 | 124 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
121 | 125 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
122 | 126 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
123 | 127 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
124 | 128 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
125 | 129 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
126 | 130 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
127 | 131 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
128 | 132 | sparc.pri \ |
|
129 | 133 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
130 | 134 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
131 | 135 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
132 | 136 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
133 | 137 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
134 | 138 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
135 | 139 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
136 | 140 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
137 | 141 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
138 | 142 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
139 | 143 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
140 | 144 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
141 | 145 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
142 | 146 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
143 | 147 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
144 | 148 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
145 | 149 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
146 | 150 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
147 | 151 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
148 | 152 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
149 | 153 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
150 | 154 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
151 | 155 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
152 | 156 | sparc.pri: |
|
153 | 157 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
154 | 158 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
155 | 159 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
156 | 160 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
157 | 161 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
158 | 162 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
159 | 163 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
160 | 164 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
161 | 165 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
162 | 166 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
163 | 167 | qmake: FORCE |
|
164 | 168 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
165 | 169 | |
|
166 | 170 | dist: |
|
167 | 171 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 |
|
168 | 172 | $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0 |
|
169 | 173 | |
|
170 | 174 | |
|
171 | 175 | clean:compiler_clean |
|
172 | 176 | -$(DEL_FILE) $(OBJECTS) |
|
173 | 177 | -$(DEL_FILE) *~ core *.core |
|
174 | 178 | |
|
175 | 179 | |
|
176 | 180 | ####### Sub-libraries |
|
177 | 181 | |
|
178 | 182 | distclean: clean |
|
179 | 183 | -$(DEL_FILE) $(TARGET) |
|
180 | 184 | -$(DEL_FILE) Makefile |
|
181 | 185 | |
|
182 | 186 | |
|
183 | 187 | grmon: |
|
184 | 188 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
185 | 189 | |
|
186 | 190 | check: first |
|
187 | 191 | |
|
188 | 192 | compiler_rcc_make_all: |
|
189 | 193 | compiler_rcc_clean: |
|
190 | 194 | compiler_uic_make_all: |
|
191 | 195 | compiler_uic_clean: |
|
192 | 196 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
193 | 197 | compiler_image_collection_clean: |
|
194 | 198 | -$(DEL_FILE) qmake_image_collection.cpp |
|
195 | 199 | compiler_yacc_decl_make_all: |
|
196 | 200 | compiler_yacc_decl_clean: |
|
197 | 201 | compiler_yacc_impl_make_all: |
|
198 | 202 | compiler_yacc_impl_clean: |
|
199 | 203 | compiler_lex_make_all: |
|
200 | 204 | compiler_lex_clean: |
|
201 | 205 | compiler_clean: |
|
202 | 206 | |
|
203 | 207 | ####### Compile |
|
204 | 208 | |
|
205 | 209 | obj/wf_handler.o: ../src/wf_handler.c |
|
206 | 210 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c |
|
207 | 211 | |
|
208 | 212 | obj/tc_handler.o: ../src/tc_handler.c |
|
209 | 213 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c |
|
210 | 214 | |
|
211 | 215 | obj/fsw_processing.o: ../src/fsw_processing.c |
|
212 | 216 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c |
|
213 | 217 | |
|
214 | 218 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
215 | 219 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
216 | 220 | |
|
217 | obj/fsw_init.o: ../src/fsw_init.c | |
|
221 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c | |
|
218 | 222 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c |
|
219 | 223 | |
|
220 | 224 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
221 | 225 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
222 | 226 | |
|
223 | 227 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c |
|
224 | 228 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c |
|
225 | 229 | |
|
230 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c | |
|
231 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c | |
|
232 | ||
|
233 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c | |
|
234 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c | |
|
235 | ||
|
226 | 236 | ####### Install |
|
227 | 237 | |
|
228 | 238 | install: FORCE |
|
229 | 239 | |
|
230 | 240 | uninstall: FORCE |
|
231 | 241 | |
|
232 | 242 | FORCE: |
|
233 | 243 |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -1,63 +1,71 | |||
|
1 | 1 | TEMPLATE = app |
|
2 | 2 | # CONFIG += console v8 sim |
|
3 | 3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa |
|
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=-0-15 |
|
11 | 11 | DEFINES += SW_VERSION_N1=0 |
|
12 | 12 | DEFINES += SW_VERSION_N2=0 |
|
13 | 13 | DEFINES += SW_VERSION_N3=0 |
|
14 | 14 | DEFINES += SW_VERSION_N4=15 |
|
15 | 15 | |
|
16 | 16 | contains( CONFIG, verbose ) { |
|
17 | 17 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | contains( CONFIG, cpu_usage_report ) { |
|
21 | 21 | DEFINES += PRINT_TASK_STATISTICS |
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 24 | contains( CONFIG, stack_report ) { |
|
25 | 25 | DEFINES += PRINT_STACK_REPORT |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | contains( CONFIG, boot_messages ) { |
|
29 | 29 | DEFINES += BOOT_MESSAGES |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | #doxygen.target = doxygen | |
|
33 | #doxygen.commands = doxygen ../doc/Doxyfile | |
|
34 | #QMAKE_EXTRA_TARGETS += doxygen | |
|
35 | ||
|
32 | 36 | TARGET = fsw |
|
33 | 37 | contains( CONFIG, gsa ) { |
|
34 | 38 | DEFINES += GSA |
|
35 | 39 | TARGET = fsw-gsa |
|
36 | 40 | } |
|
37 | 41 | |
|
38 | 42 | INCLUDEPATH += \ |
|
39 | 43 | ../src \ |
|
40 | 44 | ../header |
|
41 | 45 | |
|
42 | 46 | SOURCES += \ |
|
43 | 47 | ../src/wf_handler.c \ |
|
44 | 48 | ../src/tc_handler.c \ |
|
45 | 49 | ../src/fsw_processing.c \ |
|
46 | 50 | ../src/fsw_misc.c \ |
|
47 | 51 | ../src/fsw_init.c \ |
|
48 | 52 | ../src/fsw_globals.c \ |
|
49 | ../src/fsw_spacewire.c | |
|
53 | ../src/fsw_spacewire.c \ | |
|
54 | ../src/tc_load_dump_parameters.c \ | |
|
55 | ../src/tm_lfr_tc_exe.c | |
|
50 | 56 | |
|
51 | 57 | HEADERS += \ |
|
52 | 58 | ../header/wf_handler.h \ |
|
53 | 59 | ../header/tc_handler.h \ |
|
54 | 60 | ../header/grlib_regs.h \ |
|
55 | 61 | ../header/fsw_processing.h \ |
|
56 | 62 | ../header/fsw_params.h \ |
|
57 | 63 | ../header/fsw_misc.h \ |
|
58 | 64 | ../header/fsw_init.h \ |
|
59 | 65 | ../header/ccsds_types.h \ |
|
60 | 66 | ../header/fsw_params_processing.h \ |
|
61 | 67 | ../header/fsw_spacewire.h \ |
|
62 | ../header/tm_byte_positions.h | |
|
68 | ../header/tm_byte_positions.h \ | |
|
69 | ../header/tc_load_dump_parameters.h \ | |
|
70 | ../header/tm_lfr_tc_exe | |
|
63 | 71 |
@@ -1,257 +1,305 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 2.8.0, 2013-10-1 |
|
|
3 | <!-- Written by QtCreator 2.8.0, 2013-10-17T08:46:24. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
7 | 7 | <value type="int">0</value> |
|
8 | 8 | </data> |
|
9 | 9 | <data> |
|
10 | 10 | <variable>ProjectExplorer.Project.EditorSettings</variable> |
|
11 | 11 | <valuemap type="QVariantMap"> |
|
12 | 12 | <value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|
13 | 13 | <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|
14 | 14 | <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|
15 | 15 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|
16 | 16 | <value type="QString" key="language">Cpp</value> |
|
17 | 17 | <valuemap type="QVariantMap" key="value"> |
|
18 | 18 | <value type="QString" key="CurrentPreferences">CppGlobal</value> |
|
19 | 19 | </valuemap> |
|
20 | 20 | </valuemap> |
|
21 | 21 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|
22 | 22 | <value type="QString" key="language">QmlJS</value> |
|
23 | 23 | <valuemap type="QVariantMap" key="value"> |
|
24 | 24 | <value type="QString" key="CurrentPreferences">QmlJSGlobal</value> |
|
25 | 25 | </valuemap> |
|
26 | 26 | </valuemap> |
|
27 | 27 | <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|
28 | 28 | <value type="QByteArray" key="EditorConfiguration.Codec">System</value> |
|
29 | 29 | <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|
30 | 30 | <value type="int" key="EditorConfiguration.IndentSize">4</value> |
|
31 | 31 | <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
|
32 | 32 | <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|
33 | 33 | <value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|
34 | 34 | <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|
35 | 35 | <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|
36 | 36 | <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|
37 | 37 | <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|
38 | 38 | <value type="int" key="EditorConfiguration.TabSize">8</value> |
|
39 | 39 | <value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|
40 | 40 | <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|
41 | 41 | <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|
42 | 42 | <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|
43 | 43 | <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|
44 | 44 | <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|
45 | 45 | </valuemap> |
|
46 | 46 | </data> |
|
47 | 47 | <data> |
|
48 | 48 | <variable>ProjectExplorer.Project.PluginSettings</variable> |
|
49 | 49 | <valuemap type="QVariantMap"/> |
|
50 | 50 | </data> |
|
51 | 51 | <data> |
|
52 | 52 | <variable>ProjectExplorer.Project.Target.0</variable> |
|
53 | 53 | <valuemap type="QVariantMap"> |
|
54 | 54 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
55 | 55 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
56 | 56 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
57 | 57 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
58 | 58 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
59 |
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration"> |
|
|
59 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value> | |
|
60 | 60 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
61 | 61 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
62 | 62 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
63 | 63 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
64 | 64 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
65 | 65 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
66 | 66 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
67 | 67 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
68 | 68 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
|
69 | 69 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
70 | 70 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
71 | 71 | </valuemap> |
|
72 | 72 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
73 | 73 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
74 | 74 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
75 | 75 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
76 | 76 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
77 | 77 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
78 | 78 | <value type="QString">-w</value> |
|
79 | 79 | <value type="QString">-r</value> |
|
80 | 80 | </valuelist> |
|
81 | 81 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
82 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value> | |
|
82 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value> | |
|
83 | 83 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
84 | 84 | </valuemap> |
|
85 | 85 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
86 | 86 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
87 | 87 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
88 | 88 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
89 | 89 | </valuemap> |
|
90 | 90 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
91 | 91 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
92 | 92 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
93 | 93 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
94 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
95 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
96 | 96 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
97 | 97 | <value type="QString">-w</value> |
|
98 | 98 | <value type="QString">-r</value> |
|
99 | 99 | </valuelist> |
|
100 | 100 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
101 | 101 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value> |
|
102 | 102 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
103 | 103 | </valuemap> |
|
104 | 104 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
105 | 105 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
106 | 106 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
107 | 107 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
108 | 108 | </valuemap> |
|
109 | 109 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
110 | 110 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
111 | 111 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
112 | 112 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value> |
|
113 | 113 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
114 | 114 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
115 | 115 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
116 | 116 | <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value> |
|
117 | 117 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value> |
|
118 | 118 | </valuemap> |
|
119 | 119 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> |
|
120 | 120 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
121 | 121 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
122 | 122 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
123 | 123 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
124 | 124 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
125 | 125 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
126 | 126 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
127 | 127 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
|
128 | 128 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
129 | 129 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
130 | 130 | </valuemap> |
|
131 | 131 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
132 | 132 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
133 | 133 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
134 | 134 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
135 | 135 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
136 | 136 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
137 | 137 | <value type="QString">-w</value> |
|
138 | 138 | <value type="QString">-r</value> |
|
139 | 139 | </valuelist> |
|
140 | 140 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
141 | 141 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value> |
|
142 | 142 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
143 | 143 | </valuemap> |
|
144 | 144 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
145 | 145 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
146 | 146 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
147 | 147 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
148 | 148 | </valuemap> |
|
149 | 149 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
150 | 150 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
151 | 151 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
152 | 152 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
153 | 153 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
154 | 154 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
155 | 155 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
156 | 156 | <value type="QString">-w</value> |
|
157 | 157 | <value type="QString">-r</value> |
|
158 | 158 | </valuelist> |
|
159 | 159 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
160 | 160 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value> |
|
161 | 161 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
162 | 162 | </valuemap> |
|
163 | 163 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
164 | 164 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
165 | 165 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
166 | 166 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
167 | 167 | </valuemap> |
|
168 | 168 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
169 | 169 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
170 | 170 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
171 | 171 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value> |
|
172 | 172 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
173 | 173 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
174 | 174 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> |
|
175 | 175 | <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value> |
|
176 | 176 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value> |
|
177 | 177 | </valuemap> |
|
178 | 178 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value> |
|
179 | 179 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
180 | 180 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
181 | 181 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
182 | 182 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
183 | 183 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
184 | 184 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
185 | 185 | </valuemap> |
|
186 | 186 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
187 | 187 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value> |
|
188 | 188 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
189 | 189 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
190 | 190 | </valuemap> |
|
191 | 191 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
192 | 192 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
193 | 193 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
194 | 194 | <value type="bool" key="Analyzer.Project.UseGlobal">true</value> |
|
195 | 195 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
196 | 196 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
197 | 197 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
198 | 198 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
199 | 199 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
200 | 200 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
201 | 201 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
202 | 202 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
203 | 203 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
204 | 204 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
205 | 205 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
206 | 206 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
207 | 207 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
208 | 208 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
209 | 209 | <value type="int">0</value> |
|
210 | 210 | <value type="int">1</value> |
|
211 | 211 | <value type="int">2</value> |
|
212 | 212 | <value type="int">3</value> |
|
213 | 213 | <value type="int">4</value> |
|
214 | 214 | <value type="int">5</value> |
|
215 | 215 | <value type="int">6</value> |
|
216 | 216 | <value type="int">7</value> |
|
217 | 217 | <value type="int">8</value> |
|
218 | 218 | <value type="int">9</value> |
|
219 | 219 | <value type="int">10</value> |
|
220 | 220 | <value type="int">11</value> |
|
221 | 221 | <value type="int">12</value> |
|
222 | 222 | <value type="int">13</value> |
|
223 | 223 | <value type="int">14</value> |
|
224 | 224 | </valuelist> |
|
225 | 225 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
226 | 226 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
227 | 227 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
228 | 228 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
229 | 229 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
230 | 230 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
231 | 231 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
232 | 232 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
233 | 233 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
234 | 234 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
235 | 235 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
236 | 236 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
237 | 237 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
238 | 238 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
239 | 239 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
240 | 240 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value> |
|
241 | 241 | </valuemap> |
|
242 |
<value type="int" key="ProjectExplorer.Target.RunConfiguration |
|
|
242 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1"> | |
|
243 | <value type="bool" key="Analyzer.Project.UseGlobal">true</value> | |
|
244 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> | |
|
245 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> | |
|
246 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> | |
|
247 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> | |
|
248 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> | |
|
249 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> | |
|
250 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> | |
|
251 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> | |
|
252 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> | |
|
253 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> | |
|
254 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> | |
|
255 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> | |
|
256 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> | |
|
257 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> | |
|
258 | <value type="int">0</value> | |
|
259 | <value type="int">1</value> | |
|
260 | <value type="int">2</value> | |
|
261 | <value type="int">3</value> | |
|
262 | <value type="int">4</value> | |
|
263 | <value type="int">5</value> | |
|
264 | <value type="int">6</value> | |
|
265 | <value type="int">7</value> | |
|
266 | <value type="int">8</value> | |
|
267 | <value type="int">9</value> | |
|
268 | <value type="int">10</value> | |
|
269 | <value type="int">11</value> | |
|
270 | <value type="int">12</value> | |
|
271 | <value type="int">13</value> | |
|
272 | <value type="int">14</value> | |
|
273 | </valuelist> | |
|
274 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> | |
|
275 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> | |
|
276 | <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value> | |
|
277 | <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value> | |
|
278 | <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value> | |
|
279 | <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value> | |
|
280 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value> | |
|
281 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | |
|
282 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value> | |
|
283 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> | |
|
284 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> | |
|
285 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> | |
|
286 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> | |
|
287 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> | |
|
288 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> | |
|
289 | </valuemap> | |
|
290 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value> | |
|
243 | 291 | </valuemap> |
|
244 | 292 | </data> |
|
245 | 293 | <data> |
|
246 | 294 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
247 | 295 | <value type="int">1</value> |
|
248 | 296 | </data> |
|
249 | 297 | <data> |
|
250 | 298 | <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> |
|
251 | 299 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> |
|
252 | 300 | </data> |
|
253 | 301 | <data> |
|
254 | 302 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
|
255 | 303 | <value type="int">14</value> |
|
256 | 304 | </data> |
|
257 | 305 | </qtcreator> |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -1,635 +1,627 | |||
|
1 | 1 | #ifndef CCSDS_H_INCLUDED |
|
2 | 2 | #define CCSDS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #define CCSDS_PROTOCOLE_EXTRA_BYTES 4 |
|
5 | 5 | #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4 |
|
6 | 6 | #define CCSDS_TM_PKT_MAX_SIZE 4412 |
|
7 | 7 | #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4 |
|
8 | 8 | #define CCSDS_TC_PKT_MAX_SIZE 256 |
|
9 | 9 | #define CCSDS_TC_PKT_MIN_SIZE 16 |
|
10 | 10 | #define CCSDS_TC_TM_PACKET_OFFSET 7 |
|
11 | 11 | #define CCSDS_PROCESS_ID 76 |
|
12 | 12 | #define CCSDS_PACKET_CATEGORY 12 |
|
13 | 13 | #define CCSDS_NODE_ADDRESS 0xfe |
|
14 | 14 | #define CCSDS_USER_APP 0x00 |
|
15 | 15 | |
|
16 | 16 | #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10 |
|
17 | 17 | #define DEFAULT_RESERVED 0x00 |
|
18 | 18 | #define DEFAULT_HKBIA 0x1e // 0001 1110 |
|
19 | 19 | |
|
20 | 20 | // PACKET ID |
|
21 | 21 | #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1 |
|
22 | 22 | #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4 |
|
23 | 23 | #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9 |
|
24 | 24 | #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12 |
|
25 | 25 | #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12 |
|
26 | 26 | #define TM_PACKET_PID_DEFAULT 76 |
|
27 | 27 | #define TM_PACKET_PID_BURST_SBM1_SBM2 79 |
|
28 | 28 | #define TM_PACKET_CAT_TC_EXE 1 |
|
29 | 29 | #define TM_PACKET_CAT_HK 4 |
|
30 | 30 | #define TM_PACKET_CAT_PARAMETER_DUMP 9 |
|
31 | 31 | #define TM_PACKET_CAT_SCIENCE 12 |
|
32 | 32 | |
|
33 | 33 | // PACKET SEQUENCE CONTROL |
|
34 | 34 | #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000] |
|
35 | 35 | #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000] |
|
36 | 36 | #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000] |
|
37 | 37 | #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000] |
|
38 | 38 | #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000] |
|
39 | 39 | |
|
40 | 40 | // DESTINATION ID |
|
41 | 41 | #define TM_DESTINATION_ID_GROUND 0 |
|
42 | 42 | #define TM_DESTINATION_ID_MISSION_TIMELINE 110 |
|
43 | 43 | #define TM_DESTINATION_ID_TC_SEQUENCES 111 |
|
44 | 44 | #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112 |
|
45 | 45 | #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113 |
|
46 | 46 | #define TM_DESTINATION_ID_DIRECT_CMD 120 |
|
47 | 47 | #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121 |
|
48 | 48 | #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122 |
|
49 | 49 | #define TM_DESTINATION_ID_OBCP 15 |
|
50 | 50 | #define TM_DESTINATION_ID_SYSTEM_CONTROL 14 |
|
51 | 51 | #define TM_DESTINATION_ID_AOCS 11 |
|
52 | 52 | |
|
53 | 53 | #define CCSDS_DESTINATION_ID 0x01 |
|
54 | 54 | #define CCSDS_PROTOCOLE_ID 0x02 |
|
55 | 55 | #define CCSDS_RESERVED 0x00 |
|
56 | 56 | #define CCSDS_USER_APP 0x00 |
|
57 | 57 | |
|
58 | 58 | #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24 |
|
59 | 59 | #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32 |
|
60 | 60 | #define SIZE_HK_PARAMETERS 112 |
|
61 | 61 | |
|
62 | 62 | // TC TYPES |
|
63 | 63 | #define TC_TYPE_GEN 181 |
|
64 | 64 | #define TC_TYPE_TIME 9 |
|
65 | 65 | |
|
66 | 66 | // TC SUBTYPES |
|
67 | 67 | #define TC_SUBTYPE_RESET 1 |
|
68 | 68 | #define TC_SUBTYPE_LOAD_COMM 11 |
|
69 | 69 | #define TC_SUBTYPE_LOAD_NORM 13 |
|
70 | 70 | #define TC_SUBTYPE_LOAD_BURST 19 |
|
71 | 71 | #define TC_SUBTYPE_LOAD_SBM1 25 |
|
72 | 72 | #define TC_SUBTYPE_LOAD_SBM2 27 |
|
73 | 73 | #define TC_SUBTYPE_DUMP 31 |
|
74 | 74 | #define TC_SUBTYPE_ENTER 41 |
|
75 | 75 | #define TC_SUBTYPE_UPDT_INFO 51 |
|
76 | 76 | #define TC_SUBTYPE_EN_CAL 61 |
|
77 | 77 | #define TC_SUBTYPE_DIS_CAL 63 |
|
78 | 78 | #define TC_SUBTYPE_UPDT_TIME 129 |
|
79 | 79 | |
|
80 | 80 | // TC LEN |
|
81 | 81 | #define TC_LEN_RESET 12 |
|
82 | 82 | #define TC_LEN_LOAD_COMM 14 |
|
83 | 83 | #define TC_LEN_LOAD_NORM 20 |
|
84 | 84 | #define TC_LEN_LOAD_BURST 14 |
|
85 | 85 | #define TC_LEN_LOAD_SBM1 14 |
|
86 | 86 | #define TC_LEN_LOAD_SBM2 14 |
|
87 | 87 | #define TC_LEN_DUMP 12 |
|
88 | 88 | #define TC_LEN_ENTER 20 |
|
89 | 89 | #define TC_LEN_UPDT_INFO 48 |
|
90 | 90 | #define TC_LEN_EN_CAL 12 |
|
91 | 91 | #define TC_LEN_DIS_CAL 12 |
|
92 | 92 | #define TC_LEN_UPDT_TIME 18 |
|
93 | 93 | |
|
94 | 94 | // TM TYPES |
|
95 | 95 | #define TM_TYPE_TC_EXE 1 |
|
96 | 96 | #define TM_TYPE_HK 3 |
|
97 | 97 | #define TM_TYPE_PARAMETER_DUMP 3 |
|
98 | 98 | #define TM_TYPE_LFR_SCIENCE 21 |
|
99 | 99 | |
|
100 | 100 | // TM SUBTYPES |
|
101 | 101 | #define TM_SUBTYPE_EXE_OK 7 |
|
102 | 102 | #define TM_SUBTYPE_EXE_NOK 8 |
|
103 | 103 | #define TM_SUBTYPE_HK 25 |
|
104 | 104 | #define TM_SUBTYPE_PARAMETER_DUMP 25 |
|
105 | 105 | #define TM_SUBTYPE_SCIENCE 3 |
|
106 | 106 | #define TM_SUBTYPE_LFR_SCIENCE 3 |
|
107 | 107 | |
|
108 | 108 | // FAILURE CODES |
|
109 | #define ILLEGAL_APID 0 | |
|
110 | #define WRONG_LEN_PACKET 1 | |
|
111 | #define INCOR_CHECKSUM 2 | |
|
112 | #define ILL_TYPE 3 | |
|
113 | #define ILL_SUBTYPE 4 | |
|
114 | #define WRONG_APP_DATA 5 | |
|
109 | #define ILLEGAL_APID 0 | |
|
110 | #define WRONG_LEN_PACKET 1 | |
|
111 | #define INCOR_CHECKSUM 2 | |
|
112 | #define ILL_TYPE 3 | |
|
113 | #define ILL_SUBTYPE 4 | |
|
114 | #define WRONG_APP_DATA 5 // 0x00 0x05 | |
|
115 | 115 | // |
|
116 | #define WRONG_CMD_CODE 6 | |
|
117 | #define CCSDS_TM_VALID 7 | |
|
118 | #define FAILURE_CODE_INCONSISTENT 5 // 0x00 0x05 | |
|
119 |
#define FAIL |
|
|
120 |
#define |
|
|
121 | #define FAILURE_CODE_ERROR 42003 // 0xa4 0x13 | |
|
122 | #define FAILURE_CODE_CORRUPTED 42005 // 0xa4 0x15 | |
|
116 | #define CCSDS_TM_VALID 7 | |
|
117 | #define TC_NOT_EXE 42000 // 0xa4 0x10 | |
|
118 | #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12 | |
|
119 | #define FAIL_DETECTED 42003 // 0xa4 0x13 | |
|
120 | #define CORRUPTED 42005 // 0xa4 0x15 | |
|
123 | 121 | |
|
124 | 122 | // TM SID |
|
125 | #define SID_DEFAULT 0 | |
|
126 | #define SID_EXE_INC 5 | |
|
127 | #define SID_NOT_EXE 42000 // 0xa4 0x10 | |
|
128 | #define SID_NOT_IMP 42002 // 0xa4 0x12 | |
|
129 | #define SID_EXE_ERR 42003 // 0xa4 0x13 | |
|
130 | #define SID_EXE_CORR 42005 // 0xa4 0x15 | |
|
131 | 123 | #define SID_HK 1 |
|
132 | 124 | #define SID_PARAMETER_DUMP 10 |
|
133 | 125 | |
|
134 | 126 | #define SID_NORM_SWF_F0 3 |
|
135 | 127 | #define SID_NORM_SWF_F1 4 |
|
136 | 128 | #define SID_NORM_SWF_F2 5 |
|
137 | 129 | #define SID_NORM_CWF_F3 1 |
|
138 | 130 | #define SID_BURST_CWF_F2 2 |
|
139 | 131 | #define SID_SBM1_CWF_F1 24 |
|
140 | 132 | #define SID_SBM2_CWF_F2 25 |
|
141 | 133 | #define SID_NORM_ASM_F0 11 |
|
142 | 134 | #define SID_NORM_ASM_F1 12 |
|
143 | 135 | #define SID_NORM_ASM_F2 13 |
|
144 | 136 | #define SID_NORM_BP1_F0 14 |
|
145 | 137 | #define SID_NORM_BP1_F1 15 |
|
146 | 138 | #define SID_NORM_BP1_F2 16 |
|
147 | 139 | #define SID_NORM_BP2_F0 19 |
|
148 | 140 | #define SID_NORM_BP2_F1 20 |
|
149 | 141 | #define SID_NORM_BP2_F2 21 |
|
150 | 142 | #define SID_BURST_BP1_F0 17 |
|
151 | 143 | #define SID_BURST_BP2_F0 22 |
|
152 | 144 | #define SID_BURST_BP1_F1 18 |
|
153 | 145 | #define SID_BURST_BP2_F1 23 |
|
154 | 146 | #define SID_SBM1_BP1_F0 28 |
|
155 | 147 | #define SID_SBM1_BP2_F0 31 |
|
156 | 148 | #define SID_SBM2_BP1_F0 29 |
|
157 | 149 | #define SID_SBM2_BP2_F0 32 |
|
158 | 150 | #define SID_SBM2_BP1_F1 30 |
|
159 | 151 | #define SID_SBM2_BP2_F1 33 |
|
160 | 152 | |
|
161 | 153 | // LENGTH (BYTES) |
|
162 | 154 | #define LENGTH_TM_LFR_TC_EXE_MAX 32 |
|
163 | 155 | #define LENGTH_TM_LFR_HK 126 |
|
164 | 156 | |
|
165 | 157 | // HEADER_LENGTH |
|
166 | 158 | #define TM_HEADER_LEN 16 |
|
167 | 159 | #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28 |
|
168 | 160 | // PACKET_LENGTH |
|
169 | 161 | #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET) |
|
170 | 162 | #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET) |
|
171 | 163 | #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET) |
|
172 | 164 | #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET) |
|
173 | 165 | #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET) |
|
174 | 166 | #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET) |
|
175 | 167 | #define PACKET_LENGTH_HK (126 - CCSDS_TC_TM_PACKET_OFFSET) |
|
176 | 168 | #define PACKET_LENGTH_PARAMETER_DUMP (34 - CCSDS_TC_TM_PACKET_OFFSET) |
|
177 | 169 | #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM (TOTAL_SIZE_SM + HEADER_LENGTH_TM_LFR_SCIENCE_ASM - CCSDS_TC_TM_PACKET_OFFSET) |
|
178 | 170 | |
|
179 | 171 | #define SPARE1_PUSVERSION_SPARE2 0x10 |
|
180 | 172 | |
|
181 | 173 | #define LEN_TM_LFR_HK 130 // 126 + 4 |
|
182 | 174 | #define LEN_TM_LFR_TC_EXE_NOT_IMP 28 // 24 + 4 |
|
183 | 175 | |
|
184 | 176 | #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1 |
|
185 | 177 | #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1 |
|
186 | 178 | #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1 |
|
187 | 179 | #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1 |
|
188 | 180 | #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1 |
|
189 | 181 | #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1 |
|
190 | 182 | #define DEFAULT_PKTCNT 0x07 |
|
191 | 183 | #define BLK_NR_340 0x0154 |
|
192 | 184 | #define BLK_NR_8 0x0008 |
|
193 | 185 | |
|
194 | 186 | enum TM_TYPE{ |
|
195 | 187 | TM_LFR_TC_EXE_OK, |
|
196 | 188 | TM_LFR_TC_EXE_ERR, |
|
197 | 189 | TM_LFR_HK, |
|
198 | 190 | TM_LFR_SCI, |
|
199 | 191 | TM_LFR_SCI_SBM, |
|
200 | 192 | TM_LFR_PAR_DUMP |
|
201 | 193 | }; |
|
202 | 194 | |
|
203 | 195 | struct TMHeader_str |
|
204 | 196 | { |
|
205 | 197 | volatile unsigned char targetLogicalAddress; |
|
206 | 198 | volatile unsigned char protocolIdentifier; |
|
207 | 199 | volatile unsigned char reserved; |
|
208 | 200 | volatile unsigned char userApplication; |
|
209 | 201 | volatile unsigned char packetID[2]; |
|
210 | 202 | volatile unsigned char packetSequenceControl[2]; |
|
211 | 203 | volatile unsigned char packetLength[2]; |
|
212 | 204 | // DATA FIELD HEADER |
|
213 | 205 | volatile unsigned char spare1_pusVersion_spare2; |
|
214 | 206 | volatile unsigned char serviceType; |
|
215 | 207 | volatile unsigned char serviceSubType; |
|
216 | 208 | volatile unsigned char destinationID; |
|
217 | 209 | volatile unsigned char time[6]; |
|
218 | 210 | }; |
|
219 | 211 | typedef struct TMHeader_str TMHeader_t; |
|
220 | 212 | |
|
221 | 213 | struct Packet_TM_LFR_TC_EXE_str |
|
222 | 214 | { |
|
223 | 215 | volatile unsigned char targetLogicalAddress; |
|
224 | 216 | volatile unsigned char protocolIdentifier; |
|
225 | 217 | volatile unsigned char reserved; |
|
226 | 218 | volatile unsigned char userApplication; |
|
227 | 219 | volatile unsigned char packetID[2]; |
|
228 | 220 | volatile unsigned char packetSequenceControl[2]; |
|
229 | 221 | volatile unsigned char packetLength[2]; |
|
230 | 222 | // DATA FIELD HEADER |
|
231 | 223 | volatile unsigned char spare1_pusVersion_spare2; |
|
232 | 224 | volatile unsigned char serviceType; |
|
233 | 225 | volatile unsigned char serviceSubType; |
|
234 | 226 | volatile unsigned char destinationID; |
|
235 | 227 | volatile unsigned char time[6]; |
|
236 | 228 | volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1]; |
|
237 | 229 | }; |
|
238 | 230 | typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t; |
|
239 | 231 | |
|
240 | 232 | struct Packet_TM_LFR_TC_EXE_SUCCESS_str |
|
241 | 233 | { |
|
242 | 234 | volatile unsigned char targetLogicalAddress; |
|
243 | 235 | volatile unsigned char protocolIdentifier; |
|
244 | 236 | volatile unsigned char reserved; |
|
245 | 237 | volatile unsigned char userApplication; |
|
246 | 238 | // PACKET HEADER |
|
247 | 239 | volatile unsigned char packetID[2]; |
|
248 | 240 | volatile unsigned char packetSequenceControl[2]; |
|
249 | 241 | volatile unsigned char packetLength[2]; |
|
250 | 242 | // DATA FIELD HEADER |
|
251 | 243 | volatile unsigned char spare1_pusVersion_spare2; |
|
252 | 244 | volatile unsigned char serviceType; |
|
253 | 245 | volatile unsigned char serviceSubType; |
|
254 | 246 | volatile unsigned char destinationID; |
|
255 | 247 | volatile unsigned char time[6]; |
|
256 | 248 | // |
|
257 | 249 | volatile unsigned char telecommand_pkt_id[2]; |
|
258 | 250 | volatile unsigned char pkt_seq_control[2]; |
|
259 | 251 | }; |
|
260 | 252 | typedef struct Packet_TM_LFR_TC_EXE_SUCCESS_str Packet_TM_LFR_TC_EXE_SUCCESS_t; |
|
261 | 253 | |
|
262 | 254 | struct Packet_TM_LFR_TC_EXE_INCONSISTENT_str |
|
263 | 255 | { |
|
264 | 256 | volatile unsigned char targetLogicalAddress; |
|
265 | 257 | volatile unsigned char protocolIdentifier; |
|
266 | 258 | volatile unsigned char reserved; |
|
267 | 259 | volatile unsigned char userApplication; |
|
268 | 260 | // PACKET HEADER |
|
269 | 261 | volatile unsigned char packetID[2]; |
|
270 | 262 | volatile unsigned char packetSequenceControl[2]; |
|
271 | 263 | volatile unsigned char packetLength[2]; |
|
272 | 264 | // DATA FIELD HEADER |
|
273 | 265 | volatile unsigned char spare1_pusVersion_spare2; |
|
274 | 266 | volatile unsigned char serviceType; |
|
275 | 267 | volatile unsigned char serviceSubType; |
|
276 | 268 | volatile unsigned char destinationID; |
|
277 | 269 | volatile unsigned char time[6]; |
|
278 | 270 | // |
|
279 | 271 | volatile unsigned char tc_failure_code[2]; |
|
280 | 272 | volatile unsigned char telecommand_pkt_id[2]; |
|
281 | 273 | volatile unsigned char pkt_seq_control[2]; |
|
282 | 274 | volatile unsigned char tc_service; |
|
283 | 275 | volatile unsigned char tc_subtype; |
|
284 | 276 | volatile unsigned char byte_position; |
|
285 | 277 | volatile unsigned char rcv_value; |
|
286 | 278 | }; |
|
287 | 279 | typedef struct Packet_TM_LFR_TC_EXE_INCONSISTENT_str Packet_TM_LFR_TC_EXE_INCONSISTENT_t; |
|
288 | 280 | |
|
289 | 281 | struct Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_str |
|
290 | 282 | { |
|
291 | 283 | volatile unsigned char targetLogicalAddress; |
|
292 | 284 | volatile unsigned char protocolIdentifier; |
|
293 | 285 | volatile unsigned char reserved; |
|
294 | 286 | volatile unsigned char userApplication; |
|
295 | 287 | // PACKET HEADER |
|
296 | 288 | volatile unsigned char packetID[2]; |
|
297 | 289 | volatile unsigned char packetSequenceControl[2]; |
|
298 | 290 | volatile unsigned char packetLength[2]; |
|
299 | 291 | // DATA FIELD HEADER |
|
300 | 292 | volatile unsigned char spare1_pusVersion_spare2; |
|
301 | 293 | volatile unsigned char serviceType; |
|
302 | 294 | volatile unsigned char serviceSubType; |
|
303 | 295 | volatile unsigned char destinationID; |
|
304 | 296 | volatile unsigned char time[6]; |
|
305 | 297 | // |
|
306 | 298 | volatile unsigned char tc_failure_code[2]; |
|
307 | 299 | volatile unsigned char telecommand_pkt_id[2]; |
|
308 | 300 | volatile unsigned char pkt_seq_control[2]; |
|
309 | 301 | volatile unsigned char tc_service; |
|
310 | 302 | volatile unsigned char tc_subtype; |
|
311 | 303 | volatile unsigned char lfr_status_word[2]; |
|
312 | 304 | }; |
|
313 | 305 | typedef struct Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_str Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t; |
|
314 | 306 | |
|
315 | 307 | struct Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_str |
|
316 | 308 | { |
|
317 | 309 | volatile unsigned char targetLogicalAddress; |
|
318 | 310 | volatile unsigned char protocolIdentifier; |
|
319 | 311 | volatile unsigned char reserved; |
|
320 | 312 | volatile unsigned char userApplication; |
|
321 | 313 | // PACKET HEADER |
|
322 | 314 | volatile unsigned char packetID[2]; |
|
323 | 315 | volatile unsigned char packetSequenceControl[2]; |
|
324 | 316 | volatile unsigned char packetLength[2]; |
|
325 | 317 | // DATA FIELD HEADER |
|
326 | 318 | volatile unsigned char spare1_pusVersion_spare2; |
|
327 | 319 | volatile unsigned char serviceType; |
|
328 | 320 | volatile unsigned char serviceSubType; |
|
329 | 321 | volatile unsigned char destinationID; |
|
330 | 322 | volatile unsigned char time[6]; |
|
331 | 323 | // |
|
332 | 324 | volatile unsigned char tc_failure_code[2]; |
|
333 | 325 | volatile unsigned char telecommand_pkt_id[2]; |
|
334 | 326 | volatile unsigned char pkt_seq_control[2]; |
|
335 | 327 | volatile unsigned char tc_service; |
|
336 | 328 | volatile unsigned char tc_subtype; |
|
337 | 329 | }; |
|
338 | 330 | typedef struct Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_str Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t; |
|
339 | 331 | |
|
340 | 332 | struct Packet_TM_LFR_TC_EXE_ERROR_str |
|
341 | 333 | { |
|
342 | 334 | volatile unsigned char targetLogicalAddress; |
|
343 | 335 | volatile unsigned char protocolIdentifier; |
|
344 | 336 | volatile unsigned char reserved; |
|
345 | 337 | volatile unsigned char userApplication; |
|
346 | 338 | // PACKET HEADER |
|
347 | 339 | volatile unsigned char packetID[2]; |
|
348 | 340 | volatile unsigned char packetSequenceControl[2]; |
|
349 | 341 | volatile unsigned char packetLength[2]; |
|
350 | 342 | // DATA FIELD HEADER |
|
351 | 343 | volatile unsigned char spare1_pusVersion_spare2; |
|
352 | 344 | volatile unsigned char serviceType; |
|
353 | 345 | volatile unsigned char serviceSubType; |
|
354 | 346 | volatile unsigned char destinationID; |
|
355 | 347 | volatile unsigned char time[6]; |
|
356 | 348 | // |
|
357 | 349 | volatile unsigned char tc_failure_code[2]; |
|
358 | 350 | volatile unsigned char telecommand_pkt_id[2]; |
|
359 | 351 | volatile unsigned char pkt_seq_control[2]; |
|
360 | 352 | volatile unsigned char tc_service; |
|
361 | 353 | volatile unsigned char tc_subtype; |
|
362 | 354 | }; |
|
363 | 355 | typedef struct Packet_TM_LFR_TC_EXE_ERROR_str Packet_TM_LFR_TC_EXE_ERROR_t; |
|
364 | 356 | |
|
365 | 357 | struct Packet_TM_LFR_TC_EXE_CORRUPTED_str |
|
366 | 358 | { |
|
367 | 359 | volatile unsigned char targetLogicalAddress; |
|
368 | 360 | volatile unsigned char protocolIdentifier; |
|
369 | 361 | volatile unsigned char reserved; |
|
370 | 362 | volatile unsigned char userApplication; |
|
371 | 363 | // PACKET HEADER |
|
372 | 364 | volatile unsigned char packetID[2]; |
|
373 | 365 | volatile unsigned char packetSequenceControl[2]; |
|
374 | 366 | volatile unsigned char packetLength[2]; |
|
375 | 367 | // DATA FIELD HEADER |
|
376 | 368 | volatile unsigned char spare1_pusVersion_spare2; |
|
377 | 369 | volatile unsigned char serviceType; |
|
378 | 370 | volatile unsigned char serviceSubType; |
|
379 | 371 | volatile unsigned char destinationID; |
|
380 | 372 | volatile unsigned char time[6]; |
|
381 | 373 | // |
|
382 | 374 | volatile unsigned char tc_failure_code[2]; |
|
383 | 375 | volatile unsigned char telecommand_pkt_id[2]; |
|
384 | 376 | volatile unsigned char pkt_seq_control[2]; |
|
385 | 377 | volatile unsigned char tc_service; |
|
386 | 378 | volatile unsigned char tc_subtype; |
|
387 | 379 | volatile unsigned char pkt_len_rcv_value[2]; |
|
388 | 380 | volatile unsigned char pkt_datafieldsize_cnt[2]; |
|
389 | 381 | volatile unsigned char rcv_crc[2]; |
|
390 | 382 | volatile unsigned char computed_crc[2]; |
|
391 | 383 | }; |
|
392 | 384 | typedef struct Packet_TM_LFR_TC_EXE_CORRUPTED_str Packet_TM_LFR_TC_EXE_CORRUPTED_t; |
|
393 | 385 | |
|
394 | 386 | struct Header_TM_LFR_SCIENCE_SWF_str |
|
395 | 387 | { |
|
396 | 388 | volatile unsigned char targetLogicalAddress; |
|
397 | 389 | volatile unsigned char protocolIdentifier; |
|
398 | 390 | volatile unsigned char reserved; |
|
399 | 391 | volatile unsigned char userApplication; |
|
400 | 392 | volatile unsigned char packetID[2]; |
|
401 | 393 | volatile unsigned char packetSequenceControl[2]; |
|
402 | 394 | volatile unsigned char packetLength[2]; |
|
403 | 395 | // DATA FIELD HEADER |
|
404 | 396 | volatile unsigned char spare1_pusVersion_spare2; |
|
405 | 397 | volatile unsigned char serviceType; |
|
406 | 398 | volatile unsigned char serviceSubType; |
|
407 | 399 | volatile unsigned char destinationID; |
|
408 | 400 | volatile unsigned char time[6]; |
|
409 | 401 | // AUXILIARY HEADER |
|
410 | 402 | volatile unsigned char sid; |
|
411 | 403 | volatile unsigned char hkBIA; |
|
412 | 404 | volatile unsigned char pktCnt; |
|
413 | 405 | volatile unsigned char pktNr; |
|
414 | 406 | volatile unsigned char acquisitionTime[6]; |
|
415 | 407 | volatile unsigned char blkNr[2]; |
|
416 | 408 | }; |
|
417 | 409 | typedef struct Header_TM_LFR_SCIENCE_SWF_str Header_TM_LFR_SCIENCE_SWF_t; |
|
418 | 410 | |
|
419 | 411 | struct Header_TM_LFR_SCIENCE_CWF_str |
|
420 | 412 | { |
|
421 | 413 | volatile unsigned char targetLogicalAddress; |
|
422 | 414 | volatile unsigned char protocolIdentifier; |
|
423 | 415 | volatile unsigned char reserved; |
|
424 | 416 | volatile unsigned char userApplication; |
|
425 | 417 | volatile unsigned char packetID[2]; |
|
426 | 418 | volatile unsigned char packetSequenceControl[2]; |
|
427 | 419 | volatile unsigned char packetLength[2]; |
|
428 | 420 | // DATA FIELD HEADER |
|
429 | 421 | volatile unsigned char spare1_pusVersion_spare2; |
|
430 | 422 | volatile unsigned char serviceType; |
|
431 | 423 | volatile unsigned char serviceSubType; |
|
432 | 424 | volatile unsigned char destinationID; |
|
433 | 425 | volatile unsigned char time[6]; |
|
434 | 426 | // AUXILIARY DATA HEADER |
|
435 | 427 | volatile unsigned char sid; |
|
436 | 428 | volatile unsigned char hkBIA; |
|
437 | 429 | volatile unsigned char acquisitionTime[6]; |
|
438 | 430 | volatile unsigned char blkNr[2]; |
|
439 | 431 | }; |
|
440 | 432 | typedef struct Header_TM_LFR_SCIENCE_CWF_str Header_TM_LFR_SCIENCE_CWF_t; |
|
441 | 433 | |
|
442 | 434 | struct Header_TM_LFR_SCIENCE_ASM_str |
|
443 | 435 | { |
|
444 | 436 | volatile unsigned char targetLogicalAddress; |
|
445 | 437 | volatile unsigned char protocolIdentifier; |
|
446 | 438 | volatile unsigned char reserved; |
|
447 | 439 | volatile unsigned char userApplication; |
|
448 | 440 | volatile unsigned char packetID[2]; |
|
449 | 441 | volatile unsigned char packetSequenceControl[2]; |
|
450 | 442 | volatile unsigned char packetLength[2]; |
|
451 | 443 | // DATA FIELD HEADER |
|
452 | 444 | volatile unsigned char spare1_pusVersion_spare2; |
|
453 | 445 | volatile unsigned char serviceType; |
|
454 | 446 | volatile unsigned char serviceSubType; |
|
455 | 447 | volatile unsigned char destinationID; |
|
456 | 448 | volatile unsigned char time[6]; |
|
457 | 449 | // AUXILIARY HEADER |
|
458 | 450 | volatile unsigned char sid; |
|
459 | 451 | volatile unsigned char biaStatusInfo; |
|
460 | 452 | volatile unsigned char cntASM; |
|
461 | 453 | volatile unsigned char nrASM; |
|
462 | 454 | volatile unsigned char acquisitionTime[6]; |
|
463 | 455 | volatile unsigned char blkNr[2]; |
|
464 | 456 | }; |
|
465 | 457 | typedef struct Header_TM_LFR_SCIENCE_ASM_str Header_TM_LFR_SCIENCE_ASM_t; |
|
466 | 458 | |
|
467 | 459 | struct ccsdsTelecommandPacket_str |
|
468 | 460 | { |
|
469 | 461 | //unsigned char targetLogicalAddress; // removed by the grspw module |
|
470 | 462 | volatile unsigned char protocolIdentifier; |
|
471 | 463 | volatile unsigned char reserved; |
|
472 | 464 | volatile unsigned char userApplication; |
|
473 | 465 | volatile unsigned char packetID[2]; |
|
474 | 466 | volatile unsigned char packetSequenceControl[2]; |
|
475 | 467 | volatile unsigned char packetLength[2]; |
|
476 | 468 | // DATA FIELD HEADER |
|
477 | 469 | volatile unsigned char headerFlag_pusVersion_Ack; |
|
478 | 470 | volatile unsigned char serviceType; |
|
479 | 471 | volatile unsigned char serviceSubType; |
|
480 | 472 | volatile unsigned char sourceID; |
|
481 | 473 | volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10]; |
|
482 | 474 | }; |
|
483 | 475 | typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t; |
|
484 | 476 | |
|
485 | 477 | struct Packet_TM_LFR_HK_str |
|
486 | 478 | { |
|
487 | 479 | volatile unsigned char targetLogicalAddress; |
|
488 | 480 | volatile unsigned char protocolIdentifier; |
|
489 | 481 | volatile unsigned char reserved; |
|
490 | 482 | volatile unsigned char userApplication; |
|
491 | 483 | volatile unsigned char packetID[2]; |
|
492 | 484 | volatile unsigned char packetSequenceControl[2]; |
|
493 | 485 | volatile unsigned char packetLength[2]; |
|
494 | 486 | volatile unsigned char spare1_pusVersion_spare2; |
|
495 | 487 | volatile unsigned char serviceType; |
|
496 | 488 | volatile unsigned char serviceSubType; |
|
497 | 489 | volatile unsigned char destinationID; |
|
498 | 490 | volatile unsigned char time[6]; |
|
499 | 491 | volatile unsigned char sid; |
|
500 | 492 | |
|
501 | 493 | //************** |
|
502 | 494 | // HK PARAMETERS |
|
503 | 495 | unsigned char lfr_status_word[2]; |
|
504 | 496 | unsigned char lfr_sw_version[4]; |
|
505 | 497 | // tc statistics |
|
506 | 498 | unsigned char hk_lfr_update_info_tc_cnt[2]; |
|
507 | 499 | unsigned char hk_lfr_update_time_tc_cnt[2]; |
|
508 | 500 | unsigned char hk_dpu_exe_tc_lfr_cnt[2]; |
|
509 | 501 | unsigned char hk_dpu_rej_tc_lfr_cnt[2]; |
|
510 | 502 | unsigned char hk_lfr_last_exe_tc_id[2]; |
|
511 | 503 | unsigned char hk_lfr_last_exe_tc_type[2]; |
|
512 | 504 | unsigned char hk_lfr_last_exe_tc_subtype[2]; |
|
513 | 505 | unsigned char hk_lfr_last_exe_tc_time[6]; |
|
514 | 506 | unsigned char hk_lfr_last_rej_tc_id[2]; |
|
515 | 507 | unsigned char hk_lfr_last_rej_tc_type[2]; |
|
516 | 508 | unsigned char hk_lfr_last_rej_tc_subtype[2]; |
|
517 | 509 | unsigned char hk_lfr_last_rej_tc_time[6]; |
|
518 | 510 | // anomaly statistics |
|
519 | 511 | unsigned char hk_lfr_le_cnt[2]; |
|
520 | 512 | unsigned char hk_lfr_me_cnt[2]; |
|
521 | 513 | unsigned char hk_lfr_he_cnt[2]; |
|
522 | 514 | unsigned char hk_lfr_last_er_rid[2]; |
|
523 | 515 | unsigned char hk_lfr_last_er_code; |
|
524 | 516 | unsigned char hk_lfr_last_er_time[6]; |
|
525 | 517 | // vhdl_blk_status |
|
526 | 518 | unsigned char hk_lfr_vhdl_aa_sm; |
|
527 | 519 | unsigned char hk_lfr_vhdl_fft_sr; |
|
528 | 520 | unsigned char hk_lfr_vhdl_cic_hk; |
|
529 | 521 | unsigned char hk_lfr_vhdl_iir_cal; |
|
530 | 522 | // spacewire_if_statistics |
|
531 | 523 | unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2]; |
|
532 | 524 | unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2]; |
|
533 | 525 | unsigned char hk_lfr_dpu_spw_tick_out_cnt; |
|
534 | 526 | unsigned char hk_lfr_dpu_spw_last_timc; |
|
535 | 527 | // ahb error statistics |
|
536 | 528 | unsigned int hk_lfr_last_fail_addr; |
|
537 | 529 | // temperatures |
|
538 | 530 | unsigned char hk_lfr_temp_scm[2]; |
|
539 | 531 | unsigned char hk_lfr_temp_pcb[2]; |
|
540 | 532 | unsigned char hk_lfr_temp_fpga[2]; |
|
541 | 533 | // error counters |
|
542 | 534 | unsigned char hk_lfr_dpu_spw_parity; |
|
543 | 535 | unsigned char hk_lfr_dpu_spw_disconnect; |
|
544 | 536 | unsigned char hk_lfr_dpu_spw_escape; |
|
545 | 537 | unsigned char hk_lfr_dpu_spw_credit; |
|
546 | 538 | unsigned char hk_lfr_dpu_spw_write_sync; |
|
547 | 539 | unsigned char hk_lfr_dpu_spw_rx_ahb; |
|
548 | 540 | unsigned char hk_lfr_dpu_spw_tx_ahb; |
|
549 | 541 | unsigned char hk_lfr_dpu_spw_header_crc; |
|
550 | 542 | unsigned char hk_lfr_dpu_spw_data_crc; |
|
551 | 543 | unsigned char hk_lfr_dpu_spw_early_eop; |
|
552 | 544 | unsigned char hk_lfr_dpu_spw_invalid_addr; |
|
553 | 545 | unsigned char hk_lfr_dpu_spw_eep; |
|
554 | 546 | unsigned char hk_lfr_dpu_spw_rx_too_big; |
|
555 | 547 | // timecode |
|
556 | 548 | unsigned char hk_lfr_timecode_erroneous; |
|
557 | 549 | unsigned char hk_lfr_timecode_missing; |
|
558 | 550 | unsigned char hk_lfr_timecode_invalid; |
|
559 | 551 | // time |
|
560 | 552 | unsigned char hk_lfr_time_timecode_it; |
|
561 | 553 | unsigned char hk_lfr_time_not_synchro; |
|
562 | 554 | unsigned char hk_lfr_time_timecode_ctr; |
|
563 | 555 | // hk_lfr_buffer_dpu_ |
|
564 | 556 | unsigned char hk_lfr_buffer_dpu_tc_fifo; |
|
565 | 557 | unsigned char hk_lfr_buffer_dpu_tm_fifo; |
|
566 | 558 | // hk_lfr_ahb_ |
|
567 | 559 | unsigned char hk_lfr_ahb_correctable; |
|
568 | 560 | unsigned char hk_lfr_ahb_uncorrectable; |
|
569 | 561 | unsigned char hk_lfr_ahb_fails_trans; |
|
570 | 562 | // hk_lfr_adc_ |
|
571 | 563 | unsigned char hk_lfr_adc_failure; |
|
572 | 564 | unsigned char hk_lfr_adc_timeout; |
|
573 | 565 | unsigned char hk_lfr_toomany_err; |
|
574 | 566 | // hk_lfr_cpu_ |
|
575 | 567 | unsigned char hk_lfr_cpu_write_err; |
|
576 | 568 | unsigned char hk_lfr_cpu_ins_access_err; |
|
577 | 569 | unsigned char hk_lfr_cpu_illegal_ins; |
|
578 | 570 | unsigned char hk_lfr_cpu_privilegied_ins; |
|
579 | 571 | unsigned char hk_lfr_cpu_register_hw; |
|
580 | 572 | unsigned char hk_lfr_cpu_not_aligned; |
|
581 | 573 | unsigned char hk_lfr_cpu_data_exception; |
|
582 | 574 | unsigned char hk_lfr_cpu_div_exception; |
|
583 | 575 | unsigned char hk_lfr_cpu_arith_overflow; |
|
584 | 576 | }; |
|
585 | 577 | typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t; |
|
586 | 578 | |
|
587 | 579 | struct Packet_TM_LFR_PARAMETER_DUMP_str |
|
588 | 580 | { |
|
589 | 581 | volatile unsigned char targetLogicalAddress; |
|
590 | 582 | volatile unsigned char protocolIdentifier; |
|
591 | 583 | volatile unsigned char reserved; |
|
592 | 584 | volatile unsigned char userApplication; |
|
593 | 585 | volatile unsigned char packetID[2]; |
|
594 | 586 | volatile unsigned char packetSequenceControl[2]; |
|
595 | 587 | volatile unsigned char packetLength[2]; |
|
596 | 588 | // DATA FIELD HEADER |
|
597 | 589 | volatile unsigned char spare1_pusVersion_spare2; |
|
598 | 590 | volatile unsigned char serviceType; |
|
599 | 591 | volatile unsigned char serviceSubType; |
|
600 | 592 | volatile unsigned char destinationID; |
|
601 | 593 | volatile unsigned char time[6]; |
|
602 | 594 | volatile unsigned char sid; |
|
603 | 595 | |
|
604 | 596 | //****************** |
|
605 | 597 | // COMMON PARAMETERS |
|
606 | 598 | volatile unsigned char unused0; |
|
607 | 599 | volatile unsigned char bw_sp0_sp1_r0_r1; |
|
608 | 600 | |
|
609 | 601 | //****************** |
|
610 | 602 | // NORMAL PARAMETERS |
|
611 | 603 | volatile unsigned char sy_lfr_n_swf_l[2]; |
|
612 | 604 | volatile unsigned char sy_lfr_n_swf_p[2]; |
|
613 | 605 | volatile unsigned char sy_lfr_n_asm_p[2]; |
|
614 | 606 | volatile unsigned char sy_lfr_n_bp_p0; |
|
615 | 607 | volatile unsigned char sy_lfr_n_bp_p1; |
|
616 | 608 | |
|
617 | 609 | //***************** |
|
618 | 610 | // BURST PARAMETERS |
|
619 | 611 | volatile unsigned char sy_lfr_b_bp_p0; |
|
620 | 612 | volatile unsigned char sy_lfr_b_bp_p1; |
|
621 | 613 | |
|
622 | 614 | //**************** |
|
623 | 615 | // SBM1 PARAMETERS |
|
624 | 616 | volatile unsigned char sy_lfr_s1_bp_p0; |
|
625 | 617 | volatile unsigned char sy_lfr_s1_bp_p1; |
|
626 | 618 | |
|
627 | 619 | //**************** |
|
628 | 620 | // SBM2 PARAMETERS |
|
629 | 621 | volatile unsigned char sy_lfr_s2_bp_p0; |
|
630 | 622 | volatile unsigned char sy_lfr_s2_bp_p1; |
|
631 | 623 | }; |
|
632 | 624 | typedef struct Packet_TM_LFR_PARAMETER_DUMP_str Packet_TM_LFR_PARAMETER_DUMP_t; |
|
633 | 625 | |
|
634 | 626 | |
|
635 | 627 | #endif // CCSDS_H_INCLUDED |
@@ -1,60 +1,58 | |||
|
1 | 1 | #ifndef FSW_RTEMS_H_INCLUDED |
|
2 | 2 | #define FSW_RTEMS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <errno.h> |
|
5 | 5 | #include <fcntl.h> |
|
6 | 6 | #include <stdio.h> |
|
7 | 7 | #include <stdlib.h> |
|
8 | #include <unistd.h> // for the read call | |
|
9 | #include <sys/ioctl.h> // for the ioctl call | |
|
8 | 10 | |
|
11 | #include <rtems.h> | |
|
9 | 12 | #include <grspw.h> |
|
10 | 13 | #include <apbuart.h> |
|
14 | #include <leon.h> | |
|
11 | 15 | |
|
12 | 16 | #include "fsw_params.h" |
|
13 | 17 | #include "fsw_misc.h" |
|
14 | #include "tm_byte_positions.h" | |
|
15 | 18 | #include "fsw_processing.h" |
|
16 | 19 | #include "tc_handler.h" |
|
17 | 20 | #include "wf_handler.h" |
|
18 | #include "grlib_regs.h" | |
|
19 | #include "ccsds_types.h" | |
|
20 | 21 | |
|
21 | 22 | #include "fsw_spacewire.h" |
|
22 | 23 | |
|
23 | 24 | extern rtems_name misc_name[5]; |
|
24 | 25 | extern rtems_id misc_id[5]; |
|
25 | 26 | extern rtems_name Task_name[20]; /* array of task names */ |
|
26 | 27 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
27 | 28 | extern unsigned int maxCount; |
|
28 | 29 | extern int fdSPW; // grspw file descriptor |
|
29 | 30 | extern int fdUART; // uart file descriptor |
|
30 | 31 | extern unsigned char lfrCurrentMode; |
|
31 | 32 | |
|
32 | 33 | // MODE PARAMETERS |
|
33 | 34 | extern struct param_local_str param_local; |
|
34 | 35 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
35 | 36 | extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID]; |
|
36 | 37 | |
|
37 | 38 | // RTEMS TASKS |
|
38 |
rtems_task Init( rtems_task_argument argument); |
|
|
39 | rtems_task recv_task(rtems_task_argument argument); | |
|
40 | rtems_task stat_task(rtems_task_argument argument); | |
|
41 | rtems_task wfrm_task(rtems_task_argument argument); | |
|
39 | rtems_task Init( rtems_task_argument argument); | |
|
42 | 40 | |
|
43 | 41 | // OTHER functions |
|
44 | 42 | int create_names( void ); |
|
45 | 43 | int create_all_tasks( void ); |
|
46 | 44 | int start_all_tasks( void ); |
|
47 | 45 | rtems_status_code create_message_queues( void ); |
|
48 | 46 | // |
|
49 | 47 | void init_parameter_dump( void ); |
|
50 | 48 | void init_local_mode_parameters( void ); |
|
51 | 49 | void init_housekeeping_parameters( void ); |
|
52 | 50 | |
|
53 | 51 | extern int rtems_cpu_usage_report( void ); |
|
54 | 52 | extern int rtems_cpu_usage_reset( void ); |
|
55 | 53 | extern void rtems_stack_checker_report_usage( void ); |
|
56 | 54 | |
|
57 | 55 | extern int sched_yield( void ); |
|
58 | 56 | extern int errno; |
|
59 | 57 | |
|
60 | 58 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -1,36 +1,28 | |||
|
1 | 1 | #ifndef FSW_MISC_H_INCLUDED |
|
2 | 2 | #define FSW_MISC_H_INCLUDED |
|
3 | 3 | |
|
4 | #include <rtems.h> | |
|
5 | #include <stdio.h> | |
|
6 | ||
|
7 | #include <grspw.h> | |
|
8 | ||
|
9 | 4 | #include "fsw_init.h" |
|
10 | #include "fsw_params.h" | |
|
11 | #include "grlib_regs.h" | |
|
12 | #include "ccsds_types.h" | |
|
13 | 5 | |
|
14 | 6 | rtems_name HK_name; // name of the HK rate monotonic |
|
15 | 7 | rtems_id HK_id; // id of the HK rate monotonic period |
|
16 | 8 | extern Packet_TM_LFR_HK_t housekeeping_packet; |
|
17 | 9 | |
|
18 | 10 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
19 | 11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
20 | 12 | int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
21 | 13 | int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
22 | 14 | int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider); |
|
23 | 15 | void update_spacewire_statistics(); |
|
24 | 16 | |
|
25 | 17 | // SERIAL LINK |
|
26 | 18 | int send_console_outputs_on_apbuart_port( void ); |
|
27 |
|
|
|
19 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); | |
|
28 | 20 | |
|
29 | 21 | // RTEMS TASKS |
|
30 | 22 | rtems_task stat_task(rtems_task_argument argument); |
|
31 | 23 | rtems_task hous_task(rtems_task_argument argument); |
|
32 | 24 | rtems_task send_task(rtems_task_argument argument); |
|
33 | 25 | |
|
34 | 26 | rtems_id get_pkts_queue_id( void ); |
|
35 | 27 | |
|
36 | 28 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,223 +1,225 | |||
|
1 | 1 | #ifndef FSW_RTEMS_CONFIG_H_INCLUDED |
|
2 | 2 | #define FSW_RTEMS_CONFIG_H_INCLUDED |
|
3 | 3 | |
|
4 | #include "grlib_regs.h" | |
|
4 | 5 | #include "fsw_params_processing.h" |
|
6 | #include "tm_byte_positions.h" | |
|
5 | 7 | #include "ccsds_types.h" |
|
6 | 8 | |
|
7 | 9 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
8 | 10 | #define UART_DEVICE_NAME "/dev/console" |
|
9 | 11 | |
|
10 | 12 | //************************ |
|
11 | 13 | // flight software version |
|
12 | 14 | // this parameters is handled by the Qt project options |
|
13 | 15 | |
|
14 | 16 | //********** |
|
15 | 17 | // LFR MODES |
|
16 | 18 | #define LFR_MODE_STANDBY 0 |
|
17 | 19 | #define LFR_MODE_NORMAL 1 |
|
18 | 20 | #define LFR_MODE_BURST 2 |
|
19 | 21 | #define LFR_MODE_SBM1 3 |
|
20 | 22 | #define LFR_MODE_SBM2 4 |
|
21 | 23 | #define LFR_MODE_NORMAL_CWF_F3 5 |
|
22 | 24 | |
|
23 | 25 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
24 | 26 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
25 | 27 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
26 | 28 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
27 | 29 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
28 | 30 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
29 | 31 | |
|
30 | 32 | //**************************** |
|
31 | 33 | // LFR DEFAULT MODE PARAMETERS |
|
32 | 34 | // COMMON |
|
33 | 35 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
34 | 36 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
35 | 37 | // NORM |
|
36 | 38 | #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample |
|
37 | 39 | #define DEFAULT_SY_LFR_N_SWF_P 16 // sec |
|
38 | 40 | #define DEFAULT_SY_LFR_N_ASM_P 16 // sec |
|
39 | 41 | #define DEFAULT_SY_LFR_N_BP_P0 4 // sec |
|
40 | 42 | #define DEFAULT_SY_LFR_N_BP_P1 20 // sec |
|
41 | 43 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
42 | 44 | // BURST |
|
43 | 45 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
44 | 46 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
45 | 47 | // SBM1 |
|
46 | 48 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
47 | 49 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
48 | 50 | // SBM2 |
|
49 | 51 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
50 | 52 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
51 | 53 | // ADDITIONAL PARAMETERS |
|
52 | 54 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
53 | 55 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
54 | 56 | // |
|
55 | 57 | //**************************** |
|
56 | 58 | |
|
57 | 59 | //***************************** |
|
58 | 60 | // APB REGISTERS BASE ADDRESSES |
|
59 | 61 | #define REGS_ADDR_APBUART 0x80000100 |
|
60 | 62 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
61 | 63 | #define REGS_ADDR_GRSPW 0x80000500 |
|
62 | 64 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
63 | 65 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
64 | 66 | |
|
65 | 67 | #ifdef GSA |
|
66 | 68 | #else |
|
67 | 69 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 |
|
68 | 70 | #endif |
|
69 | 71 | |
|
70 | 72 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
71 | 73 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
72 | 74 | |
|
73 | 75 | //********** |
|
74 | 76 | // IRQ LINES |
|
75 | 77 | #define IRQ_SM 9 |
|
76 | 78 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
77 | 79 | #define IRQ_WF 10 |
|
78 | 80 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels |
|
79 | 81 | #define IRQ_TIME1 12 |
|
80 | 82 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels |
|
81 | 83 | #define IRQ_TIME2 13 |
|
82 | 84 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels |
|
83 | 85 | #define IRQ_WAVEFORM_PICKER 14 |
|
84 | 86 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
85 | 87 | #define IRQ_SPECTRAL_MATRIX 6 |
|
86 | 88 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
87 | 89 | |
|
88 | 90 | //***** |
|
89 | 91 | // TIME |
|
90 | 92 | #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms |
|
91 | 93 | #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s |
|
92 | 94 | #define TIMER_SM_SIMULATOR 1 |
|
93 | 95 | #define TIMER_WF_SIMULATOR 2 |
|
94 | 96 | #define HK_PERIOD 100 // 100 * 10ms => 1sec |
|
95 | 97 | |
|
96 | 98 | //********** |
|
97 | 99 | // LPP CODES |
|
98 | 100 | #define LFR_SUCCESSFUL 0 |
|
99 | 101 | #define LFR_DEFAULT 1 |
|
100 | 102 | |
|
101 | 103 | //****** |
|
102 | 104 | // RTEMS |
|
103 | 105 | #define TASKID_RECV 1 |
|
104 | 106 | #define TASKID_ACTN 2 |
|
105 | 107 | #define TASKID_SPIQ 3 |
|
106 | 108 | #define TASKID_SMIQ 4 |
|
107 | 109 | #define TASKID_STAT 5 |
|
108 | 110 | #define TASKID_AVF0 6 |
|
109 | 111 | #define TASKID_BPF0 7 |
|
110 | 112 | #define TASKID_WFRM 8 |
|
111 | 113 | #define TASKID_DUMB 9 |
|
112 | 114 | #define TASKID_HOUS 10 |
|
113 | 115 | #define TASKID_MATR 11 |
|
114 | 116 | #define TASKID_CWF3 12 |
|
115 | 117 | #define TASKID_CWF2 13 |
|
116 | 118 | #define TASKID_CWF1 14 |
|
117 | 119 | #define TASKID_SEND 15 |
|
118 | 120 | |
|
119 | 121 | #define TASK_PRIORITY_SPIQ 5 |
|
120 | 122 | #define TASK_PRIORITY_SMIQ 10 |
|
121 | 123 | // |
|
122 | 124 | #define TASK_PRIORITY_RECV 20 |
|
123 | 125 | #define TASK_PRIORITY_ACTN 30 |
|
124 | 126 | // |
|
125 | 127 | #define TASK_PRIORITY_HOUS 40 |
|
126 | 128 | #define TASK_PRIORITY_CWF1 40 |
|
127 | 129 | #define TASK_PRIORITY_CWF2 40 |
|
128 | 130 | #define TASK_PRIORITY_WFRM 40 |
|
129 | 131 | #define TASK_PRIORITY_CWF3 40 |
|
130 | 132 | // |
|
131 | 133 | #define TASK_PRIORITY_SEND 40 |
|
132 | 134 | // |
|
133 | 135 | #define TASK_PRIORITY_AVF0 60 |
|
134 | 136 | #define TASK_PRIORITY_BPF0 60 |
|
135 | 137 | #define TASK_PRIORITY_MATR 100 |
|
136 | 138 | #define TASK_PRIORITY_STAT 200 |
|
137 | 139 | #define TASK_PRIORITY_DUMB 200 |
|
138 | 140 | |
|
139 | 141 | #define ACTION_MSG_QUEUE_COUNT 10 |
|
140 | 142 | #define ACTION_MSG_PKTS_COUNT 50 |
|
141 |
#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_ |
|
|
143 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |
|
142 | 144 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
143 | 145 | |
|
144 | 146 | #define QUEUE_QUEU 0 |
|
145 | 147 | #define QUEUE_PKTS 1 |
|
146 | 148 | |
|
147 | 149 | //******* |
|
148 | 150 | // MACROS |
|
149 | 151 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
150 | 152 | #define PRINTF(x) printf(x); |
|
151 | 153 | #define PRINTF1(x,y) printf(x,y); |
|
152 | 154 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
153 | 155 | #else |
|
154 | 156 | #define PRINTF(x) ; |
|
155 | 157 | #define PRINTF1(x,y) ; |
|
156 | 158 | #define PRINTF2(x,y,z) ; |
|
157 | 159 | #endif |
|
158 | 160 | |
|
159 | 161 | #ifdef BOOT_MESSAGES |
|
160 | 162 | #define BOOT_PRINTF(x) printf(x); |
|
161 | 163 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
162 | 164 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
163 | 165 | #else |
|
164 | 166 | #define BOOT_PRINTF(x) ; |
|
165 | 167 | #define BOOT_PRINTF1(x,y) ; |
|
166 | 168 | #define BOOT_PRINTF2(x,y,z) ; |
|
167 | 169 | #endif |
|
168 | 170 | |
|
169 | 171 | #ifdef DEBUG_MESSAGES |
|
170 | 172 | #define DEBUG_PRINTF(x) printf(x); |
|
171 | 173 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
172 | 174 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
173 | 175 | #else |
|
174 | 176 | #define DEBUG_PRINTF(x) ; |
|
175 | 177 | #define DEBUG_PRINTF1(x,y) ; |
|
176 | 178 | #define DEBUG_PRINTF2(x,y,z) ; |
|
177 | 179 | #endif |
|
178 | 180 | |
|
179 | 181 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
180 | 182 | |
|
181 | 183 | #define NB_SAMPLES_PER_SNAPSHOT 2048 |
|
182 | 184 | #define TIME_OFFSET 2 |
|
183 | 185 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
184 | 186 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
185 | 187 | #define NB_WORDS_SWF_BLK 3 |
|
186 | 188 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
187 | 189 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 |
|
188 | 190 | |
|
189 | 191 | //****************** |
|
190 | 192 | // SEQUENCE COUNTERS |
|
191 | 193 | #define SEQ_CNT_NB_PID 2 |
|
192 | 194 | #define SEQ_CNT_NB_CAT 4 |
|
193 | 195 | #define SEQ_CNT_NB_DEST_ID 11 |
|
194 | 196 | // pid |
|
195 | 197 | #define SEQ_CNT_PID_76 0 |
|
196 | 198 | #define SEQ_CNT_PID_79 1 |
|
197 | 199 | //cat |
|
198 | 200 | #define SEQ_CNT_CAT_1 0 |
|
199 | 201 | #define SEQ_CNT_CAT_4 1 |
|
200 | 202 | #define SEQ_CNT_CAT_9 2 |
|
201 | 203 | #define SEQ_CNT_CAT_12 3 |
|
202 | 204 | // destination id |
|
203 | 205 | #define SEQ_CNT_DST_ID_GROUND 0 |
|
204 | 206 | #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1 |
|
205 | 207 | #define SEQ_CNT_DST_ID_TC_SEQUENCES 2 |
|
206 | 208 | #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3 |
|
207 | 209 | #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4 |
|
208 | 210 | #define SEQ_CNT_DST_ID_DIRECT_CMD 5 |
|
209 | 211 | #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6 |
|
210 | 212 | #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7 |
|
211 | 213 | #define SEQ_CNT_DST_ID_OBCP 8 |
|
212 | 214 | #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9 |
|
213 | 215 | #define SEQ_CNT_DST_ID_AOCS 10 |
|
214 | 216 | |
|
215 | 217 | struct param_local_str{ |
|
216 | 218 | unsigned int local_sbm1_nb_cwf_sent; |
|
217 | 219 | unsigned int local_sbm1_nb_cwf_max; |
|
218 | 220 | unsigned int local_sbm2_nb_cwf_sent; |
|
219 | 221 | unsigned int local_sbm2_nb_cwf_max; |
|
220 | 222 | unsigned int local_nb_interrupt_f0_MAX; |
|
221 | 223 | }; |
|
222 | 224 | |
|
223 | 225 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -1,68 +1,55 | |||
|
1 | 1 | #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED |
|
2 | 2 | #define FSW_RTEMS_PROCESSING_H_INCLUDED |
|
3 | 3 | |
|
4 |
#include |
|
|
5 | #include <grspw.h> | |
|
6 | #include <leon.h> | |
|
7 | ||
|
8 | #include <fsw_init.h> | |
|
9 | #include <fsw_params.h> | |
|
10 | #include <grlib_regs.h> | |
|
11 | #include <ccsds_types.h> | |
|
12 | ||
|
13 | #include <stdio.h> | |
|
14 | #include <stdlib.h> | |
|
4 | #include "fsw_init.h" | |
|
15 | 5 | |
|
16 | 6 | extern volatile int spec_mat_f0_0[ ]; |
|
17 | 7 | extern volatile int spec_mat_f0_1[ ]; |
|
18 | 8 | extern volatile int spec_mat_f0_a[ ]; |
|
19 | 9 | extern volatile int spec_mat_f0_b[ ]; |
|
20 | 10 | extern volatile int spec_mat_f0_c[ ]; |
|
21 | 11 | extern volatile int spec_mat_f0_d[ ]; |
|
22 | 12 | extern volatile int spec_mat_f0_e[ ]; |
|
23 | 13 | extern volatile int spec_mat_f0_f[ ]; |
|
24 | 14 | extern volatile int spec_mat_f0_g[ ]; |
|
25 | 15 | extern volatile int spec_mat_f0_h[ ]; |
|
26 | 16 | |
|
27 | 17 | extern volatile int spec_mat_f1[ ]; |
|
28 | 18 | extern volatile int spec_mat_f2[ ]; |
|
29 | 19 | |
|
30 | 20 | extern volatile int spec_mat_f1_bis[ ]; |
|
31 | 21 | extern volatile int spec_mat_f2_bis[ ]; |
|
32 | 22 | extern volatile int spec_mat_f0_0_bis[ ]; |
|
33 | 23 | extern volatile int spec_mat_f0_1_bis[ ]; |
|
34 | 24 | |
|
35 | 25 | // parameters |
|
36 | 26 | extern struct param_local_str param_local; |
|
37 | 27 | |
|
38 | 28 | // registers |
|
39 | 29 | extern time_management_regs_t *time_management_regs; |
|
40 | 30 | extern spectral_matrix_regs_t *spectral_matrix_regs; |
|
41 | 31 | |
|
42 | 32 | // ISR |
|
43 | 33 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
44 | 34 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); |
|
45 | 35 | |
|
46 | 36 | // RTEMS TASKS |
|
47 | 37 | rtems_task spw_bppr_task(rtems_task_argument argument); |
|
48 | 38 | rtems_task avf0_task(rtems_task_argument argument); |
|
49 | 39 | rtems_task bpf0_task(rtems_task_argument argument); |
|
50 | 40 | rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator |
|
51 | 41 | rtems_task matr_task(rtems_task_argument argument); |
|
52 | 42 | |
|
53 | rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument); | |
|
54 | ||
|
55 | void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat); | |
|
56 | 43 | void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat); |
|
57 | 44 | void matrix_reset(volatile float *averaged_spec_mat); |
|
58 | 45 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1); |
|
59 | 46 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat); |
|
60 | 47 | // |
|
61 | 48 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header); |
|
62 | 49 | void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
63 | 50 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); |
|
64 | 51 | void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix); |
|
65 | void fill_averaged_spectral_matrix(); | |
|
52 | void fill_averaged_spectral_matrix( void ); | |
|
66 | 53 | void reset_spectral_matrix_regs(); |
|
67 | 54 | |
|
68 | 55 | #endif // FSW_RTEMS_PROCESSING_H_INCLUDED |
@@ -1,32 +1,22 | |||
|
1 | 1 | #ifndef FSW_SPACEWIRE_H_INCLUDED |
|
2 | 2 | #define FSW_SPACEWIRE_H_INCLUDED |
|
3 | 3 | |
|
4 |
#include |
|
|
5 | ||
|
6 | #include <grspw.h> | |
|
7 | ||
|
8 | #include <stdio.h> | |
|
9 | #include <stdlib.h> | |
|
10 | #include <fcntl.h> | |
|
11 | ||
|
12 | #include "fsw_params.h" | |
|
13 | #include "ccsds_types.h" | |
|
14 | #include "fsw_misc.h" | |
|
4 | #include "fsw_init.h" | |
|
15 | 5 | |
|
16 | 6 | extern spw_stats spacewire_stats; |
|
17 | 7 | extern spw_stats spacewire_stats_backup; |
|
18 | 8 | |
|
19 | 9 | // RTEMS TASK |
|
20 | 10 | rtems_task spiq_task(rtems_task_argument argument); |
|
21 | 11 | |
|
22 | 12 | int spacewire_configure_link( void ); |
|
23 | 13 | int spacewire_wait_for_link(void); |
|
24 | 14 | void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force |
|
25 | 15 | void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable |
|
26 | void spacewire_compute_stats_offsets(); | |
|
16 | void spacewire_compute_stats_offsets(void); | |
|
27 | 17 | |
|
28 | 18 | void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc); |
|
29 | 19 | |
|
30 | 20 | void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc); |
|
31 | 21 | |
|
32 | 22 | #endif // FSW_SPACEWIRE_H_INCLUDED |
@@ -1,86 +1,71 | |||
|
1 | 1 | #ifndef TC_HANDLER_H_INCLUDED |
|
2 | 2 | #define TC_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | #include <rtems.h> | |
|
5 | #include <bsp.h> // for the LEON_Unmask_interrupt function | |
|
6 | #include <stdio.h> | |
|
7 | #include <unistd.h> // for the read call | |
|
8 | #include <sys/ioctl.h> // for the ioctl call | |
|
9 | #include <ccsds_types.h> | |
|
10 | #include <grspw.h> | |
|
11 | ||
|
12 | 4 | #include "fsw_init.h" |
|
13 | #include "fsw_misc.h" | |
|
5 | #include "tc_load_dump_parameters.h" | |
|
6 | #include "tm_lfr_tc_exe.h" | |
|
14 | 7 | |
|
15 | 8 | // MODE PARAMETERS |
|
16 | 9 | extern struct param_sbm1_str param_sbm1; |
|
17 | 10 | extern struct param_sbm2_str param_sbm2; |
|
18 | 11 | extern time_management_regs_t *time_management_regs; |
|
19 | 12 | extern waveform_picker_regs_t *waveform_picker_regs; |
|
20 | 13 | extern gptimer_regs_t *gptimer_regs; |
|
21 | 14 | |
|
22 | 15 | //**** |
|
23 | 16 | // ISR |
|
24 | 17 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
25 | 18 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
26 | 19 | |
|
27 | 20 | //********************** |
|
28 | 21 | // GENERAL USE FUNCTIONS |
|
29 | 22 | unsigned int Crc_opt( unsigned char D, unsigned int Chk); |
|
30 | 23 | void initLookUpTableForCRC( void ); |
|
31 | 24 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); |
|
32 | 25 | void updateLFRCurrentMode(); |
|
33 | 26 | |
|
34 | 27 | //********************* |
|
35 | 28 | // ACCEPTANCE FUNCTIONS |
|
36 |
int |
|
|
37 |
|
|
|
29 | int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_queu_id, rtems_id queue_pkts_id); | |
|
30 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV); | |
|
31 | int tc_check_type( unsigned char packetType ); | |
|
32 | int tc_check_subtype( unsigned char packetType ); | |
|
33 | int tc_check_length( unsigned char packetType, unsigned int length ); | |
|
34 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length ); | |
|
38 | 35 | |
|
39 | 36 | //*********** |
|
40 | 37 | // RTEMS TASK |
|
41 | 38 | rtems_task recv_task( rtems_task_argument unused ); |
|
42 | 39 | rtems_task actn_task( rtems_task_argument unused ); |
|
43 | 40 | rtems_task dumb_task( rtems_task_argument unused ); |
|
44 | 41 | |
|
45 | 42 | //*********** |
|
46 | 43 | // TC ACTIONS |
|
47 | 44 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
48 | int action_load_common_par(ccsdsTelecommandPacket_t *TC); | |
|
49 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
50 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
51 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
52 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
53 | int action_dump_par(ccsdsTelecommandPacket_t *TC); | |
|
54 | 45 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
55 | 46 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
56 | 47 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
57 | 48 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
58 | 49 | int action_update_time(ccsdsTelecommandPacket_t *TC); |
|
59 | 50 | |
|
60 | 51 | // mode transition |
|
61 | 52 | int transition_validation(unsigned char requestedMode); |
|
62 | 53 | int stop_current_mode(); |
|
63 | 54 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC); |
|
64 | 55 | int enter_standby_mode(); |
|
65 | 56 | int enter_normal_mode(); |
|
66 | 57 | int enter_burst_mode(); |
|
67 | 58 | int enter_sbm1_mode(); |
|
68 | 59 | int enter_sbm2_mode(); |
|
69 | 60 | int restart_science_tasks(); |
|
70 | 61 | int suspend_science_tasks(); |
|
71 | 62 | |
|
72 | 63 | // other functions |
|
73 | 64 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC); |
|
74 | 65 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC); |
|
75 | 66 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id); |
|
76 | // | |
|
77 | int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
78 | int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char byte_position, unsigned char rcv_value); | |
|
79 | int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
80 | int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
81 | int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
82 | 67 | |
|
83 | 68 | #endif // TC_HANDLER_H_INCLUDED |
|
84 | 69 | |
|
85 | 70 | |
|
86 | 71 |
@@ -1,6 +1,22 | |||
|
1 | 1 | #ifndef TM_BYTE_POSITIONS_H |
|
2 | 2 | #define TM_BYTE_POSITIONS_H |
|
3 | 3 | |
|
4 | 4 | #define BYTE_POS_CP_LFR_MODE 11 |
|
5 | 5 | |
|
6 | // TC_LFR_LOAD_COMMON_PAR | |
|
7 | ||
|
8 | // TC_LFR_LOAD_NORMAL_PAR | |
|
9 | #define BYTE_POS_SY_LFR_N_SWF_L 0 | |
|
10 | #define BYTE_POS_SY_LFR_N_SWF_P 2 | |
|
11 | #define BYTE_POS_SY_LFR_N_ASM_P 4 | |
|
12 | #define BYTE_POS_SY_LFR_N_BP_P0 6 | |
|
13 | #define BYTE_POS_SY_LFR_N_BP_P1 7 | |
|
14 | ||
|
15 | // TC_LFR_LOAD_BURST_PAR | |
|
16 | ||
|
17 | // TC_LFR_LOAD_SBM1_PAR | |
|
18 | ||
|
19 | // TC_LFR_LOAD_SBM2_PAR | |
|
20 | ||
|
21 | ||
|
6 | 22 | #endif // TM_BYTE_POSITIONS_H |
@@ -1,74 +1,65 | |||
|
1 | 1 | #ifndef WF_HANDLER_H_INCLUDED |
|
2 | 2 | #define WF_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 |
#include |
|
|
5 | #include <grspw.h> | |
|
4 | #include "fsw_init.h" | |
|
6 | 5 | |
|
7 | #include <stdio.h> | |
|
8 | 6 | #include <math.h> |
|
9 | 7 | |
|
10 | #include "fsw_params.h" | |
|
11 | #include "grlib_regs.h" | |
|
12 | #include "ccsds_types.h" | |
|
13 | #include "fsw_init.h" | |
|
14 | ||
|
15 | 8 | #define pi 3.1415 |
|
16 | 9 | |
|
17 | //#include <sys/ioctl.h> | |
|
18 | ||
|
19 | 10 | extern int fdSPW; |
|
20 | 11 | extern volatile int wf_snap_f0[ ]; |
|
21 | 12 | // |
|
22 | 13 | extern volatile int wf_snap_f1[ ]; |
|
23 | 14 | extern volatile int wf_snap_f1_bis[ ]; |
|
24 | 15 | extern volatile int wf_snap_f1_norm[ ]; |
|
25 | 16 | // |
|
26 | 17 | extern volatile int wf_snap_f2[ ]; |
|
27 | 18 | extern volatile int wf_snap_f2_bis[ ]; |
|
28 | 19 | extern volatile int wf_snap_f2_norm[ ]; |
|
29 | 20 | // |
|
30 | 21 | extern volatile int wf_cont_f3[ ]; |
|
31 | 22 | extern volatile int wf_cont_f3_bis[ ]; |
|
32 | 23 | extern char wf_cont_f3_light[ ]; |
|
33 | 24 | extern waveform_picker_regs_t *waveform_picker_regs; |
|
34 | 25 | |
|
35 | 26 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
36 | 27 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ); |
|
37 | 28 | rtems_task wfrm_task( rtems_task_argument argument ); |
|
38 | 29 | rtems_task cwf3_task( rtems_task_argument argument ); |
|
39 | 30 | rtems_task cwf2_task( rtems_task_argument argument ); |
|
40 | 31 | rtems_task cwf1_task( rtems_task_argument argument ); |
|
41 | 32 | |
|
42 | 33 | //****************** |
|
43 | 34 | // general functions |
|
44 | 35 | void init_waveforms( void ); |
|
45 | 36 | // |
|
46 | 37 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); |
|
47 | 38 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
48 | 39 | int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
49 | 40 | // |
|
50 | 41 | void reset_waveforms( void ); |
|
51 | 42 | |
|
52 | 43 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ); |
|
53 | 44 | int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
54 | 45 | int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
55 | 46 | int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
56 | 47 | |
|
57 | 48 | //************** |
|
58 | 49 | // wfp registers |
|
59 | 50 | void set_wfp_data_shaping(); |
|
60 | 51 | char set_wfp_delta_snapshot(); |
|
61 | 52 | void set_wfp_burst_enable_register( unsigned char mode); |
|
62 | 53 | void reset_wfp_burst_enable(); |
|
63 | 54 | void reset_wfp_status(); |
|
64 | 55 | void reset_waveform_picker_regs(); |
|
65 | 56 | |
|
66 | 57 | //***************** |
|
67 | 58 | // local parameters |
|
68 | 59 | void set_local_sbm1_nb_cwf_max(); |
|
69 | 60 | void set_local_sbm2_nb_cwf_max(); |
|
70 | 61 | void set_local_nb_interrupt_f0_MAX(); |
|
71 | 62 | void reset_local_sbm1_nb_cwf_sent(); |
|
72 | 63 | void reset_local_sbm2_nb_cwf_sent(); |
|
73 | 64 | |
|
74 | 65 | #endif // WF_HANDLER_H_INCLUDED |
@@ -1,73 +1,73 | |||
|
1 | 1 | //#include <fsw_processing.h> |
|
2 | 2 | #include <rtems.h> |
|
3 | 3 | #include <grspw.h> |
|
4 |
#include |
|
|
5 |
#include |
|
|
6 |
#include |
|
|
4 | #include "ccsds_types.h" | |
|
5 | #include "grlib_regs.h" | |
|
6 | #include "fsw_params.h" | |
|
7 | 7 | |
|
8 | 8 | // RTEMS GLOBAL VARIABLES |
|
9 | 9 | rtems_name misc_name[5]; |
|
10 | 10 | rtems_id misc_id[5]; |
|
11 | 11 | rtems_name Task_name[20]; /* array of task names */ |
|
12 | 12 | rtems_id Task_id[20]; /* array of task ids */ |
|
13 | 13 | unsigned int maxCount; |
|
14 | 14 | int fdSPW = 0; |
|
15 | 15 | int fdUART = 0; |
|
16 | 16 | unsigned char lfrCurrentMode; |
|
17 | 17 | |
|
18 | 18 | // APB CONFIGURATION REGISTERS |
|
19 | 19 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
20 | 20 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
21 | 21 | #ifdef GSA |
|
22 | 22 | #else |
|
23 | 23 | waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
24 | 24 | #endif |
|
25 | 25 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
26 | 26 | |
|
27 | 27 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes |
|
28 | 28 | volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
29 | 29 | // |
|
30 | 30 | volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
31 | 31 | volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
32 | 32 | volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
33 | 33 | // |
|
34 | 34 | volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
35 | 35 | volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
36 | 36 | volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
37 | 37 | // |
|
38 | 38 | volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
39 | 39 | volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ]; |
|
40 | 40 | char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ]; |
|
41 | 41 | |
|
42 | 42 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
43 | 43 | volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
44 | 44 | volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
45 | 45 | volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
46 | 46 | volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
47 | 47 | volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
48 | 48 | volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
49 | 49 | volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
50 | 50 | volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
51 | 51 | volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
52 | 52 | volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
53 | 53 | volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
54 | 54 | volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
55 | 55 | // |
|
56 | 56 | volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
57 | 57 | volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
58 | 58 | // |
|
59 | 59 | volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
60 | 60 | volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ]; |
|
61 | 61 | |
|
62 | 62 | // MODE PARAMETERS |
|
63 | 63 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
64 | 64 | struct param_local_str param_local; |
|
65 | 65 | |
|
66 | 66 | // HK PACKETS |
|
67 | 67 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
68 | 68 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
69 | 69 | unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID]; |
|
70 | 70 | spw_stats spacewire_stats; |
|
71 | 71 | spw_stats spacewire_stats_backup; |
|
72 | 72 | |
|
73 | 73 |
@@ -1,456 +1,573 | |||
|
1 | 1 | //************************* |
|
2 | 2 | // GPL reminder to be added |
|
3 | 3 | //************************* |
|
4 | 4 | |
|
5 | 5 | #include <rtems.h> |
|
6 | 6 | |
|
7 | 7 | /* configuration information */ |
|
8 | 8 | |
|
9 | 9 | #define CONFIGURE_INIT |
|
10 | 10 | |
|
11 | 11 | #include <bsp.h> /* for device driver prototypes */ |
|
12 | 12 | |
|
13 | 13 | /* configuration information */ |
|
14 | 14 | |
|
15 | 15 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
16 | 16 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
17 | 17 | |
|
18 | 18 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
19 | 19 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
20 | 20 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
21 | 21 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
22 | 22 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
23 | 23 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
24 | 24 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
25 | 25 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
26 | 26 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
27 | 27 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 |
|
28 | 28 | #ifdef PRINT_STACK_REPORT |
|
29 | 29 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
30 | 30 | #endif |
|
31 | 31 | |
|
32 | 32 | #include <rtems/confdefs.h> |
|
33 | 33 | |
|
34 | 34 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
35 | 35 | #ifdef RTEMS_DRVMGR_STARTUP |
|
36 | 36 | #ifdef LEON3 |
|
37 | 37 | /* Add Timer and UART Driver */ |
|
38 | 38 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
39 | 39 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
40 | 40 | #endif |
|
41 | 41 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
42 | 42 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
43 | 43 | #endif |
|
44 | 44 | #endif |
|
45 | 45 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
46 | 46 | #include <drvmgr/drvmgr_confdefs.h> |
|
47 | 47 | #endif |
|
48 | 48 | |
|
49 |
#include |
|
|
50 |
#include |
|
|
49 | #include "fsw_init.h" | |
|
50 | #include "fsw_config.c" | |
|
51 | 51 | |
|
52 | 52 | rtems_task Init( rtems_task_argument ignored ) |
|
53 | 53 | { |
|
54 | 54 | rtems_status_code status; |
|
55 | 55 | rtems_isr_entry old_isr_handler; |
|
56 | 56 | |
|
57 | 57 | BOOT_PRINTF("\n\n\n\n\n") |
|
58 | 58 | BOOT_PRINTF("***************************\n") |
|
59 | 59 | BOOT_PRINTF("** START Flight Software **\n") |
|
60 | 60 | BOOT_PRINTF("***************************\n") |
|
61 | 61 | BOOT_PRINTF("\n\n") |
|
62 | 62 | |
|
63 | 63 | //send_console_outputs_on_apbuart_port(); |
|
64 | 64 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
65 | 65 | |
|
66 | initLookUpTableForCRC(); // in tc_handler.h | |
|
67 | 66 | init_parameter_dump(); |
|
68 | 67 | init_local_mode_parameters(); |
|
69 | 68 | init_housekeeping_parameters(); |
|
70 | 69 | |
|
71 | 70 | create_names(); // create all names |
|
72 | 71 | |
|
73 | 72 | create_message_queues(); |
|
74 | 73 | |
|
75 |
create_all_tasks(); |
|
|
74 | status = create_all_tasks(); // create all tasks | |
|
75 | if (status != RTEMS_SUCCESSFUL) | |
|
76 | { | |
|
77 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) | |
|
78 | } | |
|
76 | 79 | |
|
77 |
start_all_tasks(); |
|
|
80 | status = start_all_tasks(); // start all tasks | |
|
81 | if (status != RTEMS_SUCCESSFUL) | |
|
82 | { | |
|
83 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
|
84 | } | |
|
78 | 85 | |
|
79 |
stop_current_mode(); |
|
|
86 | status = stop_current_mode(); // go in STANDBY mode | |
|
87 | if (status != RTEMS_SUCCESSFUL) | |
|
88 | { | |
|
89 | PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status) | |
|
90 | } | |
|
80 | 91 | |
|
81 | 92 | grspw_timecode_callback = &timecode_irq_handler; |
|
82 | 93 | |
|
83 | 94 | spacewire_configure_link(); |
|
84 | 95 | |
|
85 | 96 | #ifdef GSA |
|
86 | 97 | // mask IRQ lines |
|
87 | 98 | LEON_Mask_interrupt( IRQ_SM ); |
|
88 | 99 | LEON_Mask_interrupt( IRQ_WF ); |
|
89 | 100 | // Spectral Matrices simulator |
|
90 | 101 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
91 | 102 | IRQ_SPARC_SM, spectral_matrices_isr ); |
|
92 | 103 | // WaveForms |
|
93 | 104 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, |
|
94 | 105 | IRQ_SPARC_WF, waveforms_simulator_isr ); |
|
95 | 106 | #else |
|
96 | 107 | // mask IRQ lines |
|
97 | 108 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
98 | 109 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
99 | 110 | // reset configuration registers |
|
100 | 111 | reset_waveform_picker_regs(); |
|
101 | 112 | reset_spectral_matrix_regs(); |
|
102 | 113 | // configure IRQ handling for the waveform picker unit |
|
103 | 114 | status = rtems_interrupt_catch( waveforms_isr, |
|
104 | 115 | IRQ_SPARC_WAVEFORM_PICKER, |
|
105 | 116 | &old_isr_handler) ; |
|
106 | 117 | // configure IRQ handling for the spectral matrix unit |
|
107 | 118 | // status = rtems_interrupt_catch( spectral_matrices_isr, |
|
108 | 119 | // IRQ_SPARC_SPECTRAL_MATRIX, |
|
109 | 120 | // &old_isr_handler) ; |
|
110 | 121 | // Spectral Matrices simulator |
|
111 | 122 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
112 | 123 | IRQ_SPARC_SM, spectral_matrices_isr_simu ); |
|
113 | 124 | #endif |
|
114 | 125 | |
|
115 | 126 | BOOT_PRINTF("delete INIT\n") |
|
116 | 127 | |
|
117 | 128 | status = rtems_task_delete(RTEMS_SELF); |
|
118 | 129 | |
|
119 | 130 | } |
|
120 | 131 | |
|
121 | 132 | void init_parameter_dump( void ) |
|
122 | 133 | { |
|
123 | 134 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
124 | 135 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
125 | 136 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
126 | 137 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
127 | 138 | parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); |
|
128 | 139 | parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; |
|
129 | 140 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
130 | 141 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
131 | 142 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
132 | 143 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
133 | 144 | // DATA FIELD HEADER |
|
134 | 145 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
135 | 146 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
136 | 147 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
137 | 148 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
138 | 149 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
139 | 150 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
140 | 151 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
141 | 152 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
142 | 153 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
143 | 154 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
144 | 155 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
145 | 156 | |
|
146 | 157 | //****************** |
|
147 | 158 | // COMMON PARAMETERS |
|
148 | 159 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; |
|
149 | 160 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; |
|
150 | 161 | |
|
151 | 162 | //****************** |
|
152 | 163 | // NORMAL PARAMETERS |
|
153 | 164 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8); |
|
154 | 165 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L ); |
|
155 | 166 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8); |
|
156 | 167 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P ); |
|
157 | 168 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8); |
|
158 | 169 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P ); |
|
159 | 170 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0; |
|
160 | 171 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1; |
|
161 | 172 | |
|
162 | 173 | //***************** |
|
163 | 174 | // BURST PARAMETERS |
|
164 | 175 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
165 | 176 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
166 | 177 | |
|
167 | 178 | //**************** |
|
168 | 179 | // SBM1 PARAMETERS |
|
169 | 180 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
170 | 181 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
171 | 182 | |
|
172 | 183 | //**************** |
|
173 | 184 | // SBM2 PARAMETERS |
|
174 | 185 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
175 | 186 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
176 | 187 | } |
|
177 | 188 | |
|
178 | 189 | void init_local_mode_parameters( void ) |
|
179 | 190 | { |
|
180 | 191 | // LOCAL PARAMETERS |
|
181 | 192 | set_local_sbm1_nb_cwf_max(); |
|
182 | 193 | set_local_sbm2_nb_cwf_max(); |
|
183 | 194 | set_local_nb_interrupt_f0_MAX(); |
|
184 | 195 | |
|
185 | 196 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
186 | 197 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
187 | 198 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
188 | 199 | |
|
189 | 200 | reset_local_sbm1_nb_cwf_sent(); |
|
190 | 201 | reset_local_sbm2_nb_cwf_sent(); |
|
191 | 202 | } |
|
192 | 203 | |
|
193 | 204 | void init_housekeeping_parameters( void ) |
|
194 | 205 | { |
|
195 | 206 | unsigned int i = 0; |
|
196 | 207 | unsigned int j = 0; |
|
197 | 208 | unsigned int k = 0; |
|
198 | 209 | char *parameters; |
|
199 | 210 | |
|
200 | 211 | parameters = (char*) &housekeeping_packet.lfr_status_word; |
|
201 | 212 | for(i = 0; i< SIZE_HK_PARAMETERS; i++) |
|
202 | 213 | { |
|
203 | 214 | parameters[i] = 0x00; |
|
204 | 215 | } |
|
205 | 216 | // init status word |
|
206 | 217 | housekeeping_packet.lfr_status_word[0] = 0x00; |
|
207 | 218 | housekeeping_packet.lfr_status_word[1] = 0x00; |
|
208 | 219 | // init software version |
|
209 | 220 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
210 | 221 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
211 | 222 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
212 | 223 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
213 | 224 | // init sequence counters |
|
214 | 225 | for (i = 0; i<SEQ_CNT_NB_PID; i++) |
|
215 | 226 | { |
|
216 | 227 | for(j = 0; j<SEQ_CNT_NB_CAT; j++) |
|
217 | 228 | { |
|
218 | 229 | for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++) |
|
219 | 230 | { |
|
220 | 231 | sequenceCounters[i][j][k] = 0x00; |
|
221 | 232 | } |
|
222 | 233 | } |
|
223 | 234 | } |
|
224 | 235 | updateLFRCurrentMode(); |
|
225 | 236 | } |
|
226 | 237 | |
|
227 | int create_names( void ) | |
|
238 | int create_names( void ) // create all names for tasks and queues | |
|
228 | 239 | { |
|
240 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
|
241 | * | |
|
242 | * @return RTEMS directive status codes: | |
|
243 | * - RTEMS_SUCCESSFUL - message sent successfully | |
|
244 | * | |
|
245 | */ | |
|
246 | ||
|
229 | 247 | // task names |
|
230 | 248 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
231 | 249 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
232 | 250 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
233 | 251 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
234 | 252 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
235 | 253 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
236 | 254 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); |
|
237 | 255 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
238 | 256 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
239 | 257 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
240 | 258 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); |
|
241 | 259 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
242 | 260 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
243 | 261 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
244 | 262 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
245 | 263 | |
|
246 | 264 | // rate monotonic period name |
|
247 | 265 | HK_name = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
248 | 266 | |
|
249 | 267 | misc_name[QUEUE_QUEU] = rtems_build_name( 'Q', 'U', 'E', 'U' ); |
|
250 | 268 | misc_name[QUEUE_PKTS] = rtems_build_name( 'P', 'K', 'T', 'S' ); |
|
251 | 269 | |
|
252 | return 0; | |
|
270 | return RTEMS_SUCCESSFUL; | |
|
253 | 271 | } |
|
254 | 272 | |
|
255 | int create_all_tasks( void ) | |
|
273 | int create_all_tasks( void ) // create all tasks which run in the software | |
|
256 | 274 | { |
|
275 | /** This function creates all RTEMS tasks used in the software. | |
|
276 | * | |
|
277 | * @return RTEMS directive status codes: | |
|
278 | * - RTEMS_SUCCESSFUL - task created successfully | |
|
279 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
|
280 | * - RTEMS_INVALID_NAME - invalid task name | |
|
281 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
|
282 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
|
283 | * - RTEMS_TOO_MANY - too many tasks created | |
|
284 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
|
285 | * - RTEMS_TOO_MANY - too many global objects | |
|
286 | * | |
|
287 | */ | |
|
288 | ||
|
257 | 289 | rtems_status_code status; |
|
258 | 290 | |
|
259 | 291 | // RECV |
|
260 | 292 | status = rtems_task_create( |
|
261 | 293 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
262 | 294 | RTEMS_DEFAULT_MODES, |
|
263 | 295 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
264 | 296 | ); |
|
265 | // ACTN | |
|
266 | status = rtems_task_create( | |
|
267 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
|
268 | RTEMS_DEFAULT_MODES, | |
|
269 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
|
270 | ); | |
|
271 | // SPIQ | |
|
272 | status = rtems_task_create( | |
|
273 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
|
274 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
275 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
|
276 | ); | |
|
277 | // SMIQ | |
|
278 | status = rtems_task_create( | |
|
279 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, | |
|
280 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
281 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] | |
|
282 | ); | |
|
283 | // STAT | |
|
284 | status = rtems_task_create( | |
|
285 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
|
286 | RTEMS_DEFAULT_MODES, | |
|
287 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
|
288 | ); | |
|
289 | // AVF0 | |
|
290 | status = rtems_task_create( | |
|
291 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
|
292 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
293 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
|
294 | ); | |
|
295 | // BPF0 | |
|
296 | status = rtems_task_create( | |
|
297 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, | |
|
298 | RTEMS_DEFAULT_MODES, | |
|
299 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] | |
|
300 | ); | |
|
301 | // WFRM | |
|
302 | status = rtems_task_create( | |
|
303 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
|
304 | RTEMS_DEFAULT_MODES, | |
|
305 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
|
306 | ); | |
|
307 | // DUMB | |
|
308 | status = rtems_task_create( | |
|
309 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
|
310 | RTEMS_DEFAULT_MODES, | |
|
311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
|
312 | ); | |
|
313 | // HOUS | |
|
314 | status = rtems_task_create( | |
|
315 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
|
316 | RTEMS_DEFAULT_MODES, | |
|
317 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] | |
|
318 | ); | |
|
319 | // MATR | |
|
320 | status = rtems_task_create( | |
|
321 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, | |
|
322 | RTEMS_DEFAULT_MODES, | |
|
323 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] | |
|
324 | ); | |
|
325 | // CWF3 | |
|
326 | status = rtems_task_create( | |
|
327 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
|
328 | RTEMS_DEFAULT_MODES, | |
|
329 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] | |
|
330 | ); | |
|
331 | // CWF2 | |
|
332 | status = rtems_task_create( | |
|
333 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
|
334 | RTEMS_DEFAULT_MODES, | |
|
335 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] | |
|
336 | ); | |
|
337 | // CWF1 | |
|
338 | status = rtems_task_create( | |
|
339 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
|
340 | RTEMS_DEFAULT_MODES, | |
|
341 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] | |
|
342 | ); | |
|
343 | // SEND | |
|
344 | status = rtems_task_create( | |
|
345 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, | |
|
346 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
347 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] | |
|
348 | ); | |
|
349 | 297 | |
|
350 | return 0; | |
|
298 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
|
299 | { | |
|
300 | status = rtems_task_create( | |
|
301 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
|
302 | RTEMS_DEFAULT_MODES, | |
|
303 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
|
304 | ); | |
|
305 | } | |
|
306 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
|
307 | { | |
|
308 | status = rtems_task_create( | |
|
309 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
|
310 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
|
312 | ); | |
|
313 | } | |
|
314 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
|
315 | { | |
|
316 | status = rtems_task_create( | |
|
317 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, | |
|
318 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
319 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] | |
|
320 | ); | |
|
321 | } | |
|
322 | if (status == RTEMS_SUCCESSFUL) // STAT | |
|
323 | { | |
|
324 | status = rtems_task_create( | |
|
325 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
|
326 | RTEMS_DEFAULT_MODES, | |
|
327 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
|
328 | ); | |
|
329 | } | |
|
330 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
|
331 | { | |
|
332 | status = rtems_task_create( | |
|
333 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
|
334 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
335 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
|
336 | ); | |
|
337 | } | |
|
338 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
|
339 | { | |
|
340 | status = rtems_task_create( | |
|
341 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, | |
|
342 | RTEMS_DEFAULT_MODES, | |
|
343 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] | |
|
344 | ); | |
|
345 | } | |
|
346 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
|
347 | { | |
|
348 | status = rtems_task_create( | |
|
349 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
|
350 | RTEMS_DEFAULT_MODES, | |
|
351 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
|
352 | ); | |
|
353 | } | |
|
354 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
|
355 | { | |
|
356 | status = rtems_task_create( | |
|
357 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
|
358 | RTEMS_DEFAULT_MODES, | |
|
359 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
|
360 | ); | |
|
361 | } | |
|
362 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
|
363 | { | |
|
364 | status = rtems_task_create( | |
|
365 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
|
366 | RTEMS_DEFAULT_MODES, | |
|
367 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] | |
|
368 | ); | |
|
369 | } | |
|
370 | if (status == RTEMS_SUCCESSFUL) // MATR | |
|
371 | { | |
|
372 | status = rtems_task_create( | |
|
373 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, | |
|
374 | RTEMS_DEFAULT_MODES, | |
|
375 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] | |
|
376 | ); | |
|
377 | } | |
|
378 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
|
379 | { | |
|
380 | status = rtems_task_create( | |
|
381 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
|
382 | RTEMS_DEFAULT_MODES, | |
|
383 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] | |
|
384 | ); | |
|
385 | } | |
|
386 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
|
387 | { | |
|
388 | status = rtems_task_create( | |
|
389 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
|
390 | RTEMS_DEFAULT_MODES, | |
|
391 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] | |
|
392 | ); | |
|
393 | } | |
|
394 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
|
395 | { | |
|
396 | status = rtems_task_create( | |
|
397 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
|
398 | RTEMS_DEFAULT_MODES, | |
|
399 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] | |
|
400 | ); | |
|
401 | } | |
|
402 | if (status == RTEMS_SUCCESSFUL) // SEND | |
|
403 | { | |
|
404 | status = rtems_task_create( | |
|
405 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, | |
|
406 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
|
407 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] | |
|
408 | ); | |
|
409 | } | |
|
410 | ||
|
411 | return status; | |
|
351 | 412 | } |
|
352 | 413 | |
|
353 | 414 | int start_all_tasks( void ) |
|
354 | 415 | { |
|
416 | /** This function starts all RTEMS tasks used in the software. | |
|
417 | * | |
|
418 | * @return RTEMS directive status codes: | |
|
419 | * - RTEMS_SUCCESSFUL - ask started successfully | |
|
420 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
|
421 | * - RTEMS_INVALID_ID - invalid task id | |
|
422 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
|
423 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
|
424 | * | |
|
425 | */ | |
|
426 | // starts all the tasks fot eh flight software | |
|
427 | ||
|
355 | 428 | rtems_status_code status; |
|
356 | 429 | |
|
357 | 430 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
358 | 431 | if (status!=RTEMS_SUCCESSFUL) { |
|
359 | 432 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
360 | 433 | } |
|
361 | 434 | |
|
362 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); | |
|
363 | if (status!=RTEMS_SUCCESSFUL) { | |
|
364 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") | |
|
435 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
|
436 | { | |
|
437 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); | |
|
438 | if (status!=RTEMS_SUCCESSFUL) { | |
|
439 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") | |
|
440 | } | |
|
365 | 441 | } |
|
366 | 442 | |
|
367 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
|
368 | if (status!=RTEMS_SUCCESSFUL) { | |
|
369 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
|
443 | if (status == RTEMS_SUCCESSFUL) // RECV | |
|
444 | { | |
|
445 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
|
446 | if (status!=RTEMS_SUCCESSFUL) { | |
|
447 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
|
448 | } | |
|
370 | 449 | } |
|
371 | 450 | |
|
372 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
|
373 | if (status!=RTEMS_SUCCESSFUL) { | |
|
374 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
|
451 | if (status == RTEMS_SUCCESSFUL) // SEND | |
|
452 | { | |
|
453 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
|
454 | if (status!=RTEMS_SUCCESSFUL) { | |
|
455 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
|
456 | } | |
|
375 | 457 | } |
|
376 | 458 | |
|
377 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
|
378 | if (status!=RTEMS_SUCCESSFUL) { | |
|
379 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
|
459 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
|
460 | { | |
|
461 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
|
462 | if (status!=RTEMS_SUCCESSFUL) { | |
|
463 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
|
464 | } | |
|
380 | 465 | } |
|
381 | 466 | |
|
382 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
|
383 | if (status!=RTEMS_SUCCESSFUL) { | |
|
384 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
|
467 | if (status == RTEMS_SUCCESSFUL) // STAT | |
|
468 | { | |
|
469 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
|
470 | if (status!=RTEMS_SUCCESSFUL) { | |
|
471 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
|
472 | } | |
|
385 | 473 | } |
|
386 | 474 | |
|
387 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); | |
|
388 | if (status!=RTEMS_SUCCESSFUL) { | |
|
389 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
|
475 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
|
476 | { | |
|
477 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); | |
|
478 | if (status!=RTEMS_SUCCESSFUL) { | |
|
479 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
|
480 | } | |
|
390 | 481 | } |
|
391 | 482 | |
|
392 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); | |
|
393 | if (status!=RTEMS_SUCCESSFUL) { | |
|
394 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") | |
|
483 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
|
484 | { | |
|
485 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); | |
|
486 | if (status!=RTEMS_SUCCESSFUL) { | |
|
487 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") | |
|
488 | } | |
|
395 | 489 | } |
|
396 | 490 | |
|
397 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
|
398 | if (status!=RTEMS_SUCCESSFUL) { | |
|
399 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
|
491 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
|
492 | { | |
|
493 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
|
494 | if (status!=RTEMS_SUCCESSFUL) { | |
|
495 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
|
496 | } | |
|
400 | 497 | } |
|
401 | 498 | |
|
402 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
|
403 | if (status!=RTEMS_SUCCESSFUL) { | |
|
404 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
|
499 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
|
500 | { | |
|
501 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
|
502 | if (status!=RTEMS_SUCCESSFUL) { | |
|
503 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
|
504 | } | |
|
405 | 505 | } |
|
406 | 506 | |
|
407 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
|
408 | if (status!=RTEMS_SUCCESSFUL) { | |
|
409 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
|
410 | } | |
|
411 | ||
|
412 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); | |
|
413 | if (status!=RTEMS_SUCCESSFUL) { | |
|
414 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") | |
|
507 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
|
508 | { | |
|
509 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
|
510 | if (status!=RTEMS_SUCCESSFUL) { | |
|
511 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
|
512 | } | |
|
415 | 513 | } |
|
416 | 514 | |
|
417 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
|
418 | if (status!=RTEMS_SUCCESSFUL) { | |
|
419 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
|
515 | if (status == RTEMS_SUCCESSFUL) // MATR | |
|
516 | { | |
|
517 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); | |
|
518 | if (status!=RTEMS_SUCCESSFUL) { | |
|
519 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") | |
|
520 | } | |
|
420 | 521 | } |
|
421 | 522 | |
|
422 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
|
423 | if (status!=RTEMS_SUCCESSFUL) { | |
|
424 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
|
523 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
|
524 | { | |
|
525 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
|
526 | if (status!=RTEMS_SUCCESSFUL) { | |
|
527 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
|
528 | } | |
|
425 | 529 | } |
|
426 | 530 | |
|
427 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
|
428 | if (status!=RTEMS_SUCCESSFUL) { | |
|
429 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
|
531 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
|
532 | { | |
|
533 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
|
534 | if (status!=RTEMS_SUCCESSFUL) { | |
|
535 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
|
536 | } | |
|
430 | 537 | } |
|
431 | 538 | |
|
432 | return 0; | |
|
539 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
|
540 | { | |
|
541 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
|
542 | if (status!=RTEMS_SUCCESSFUL) { | |
|
543 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
|
544 | } | |
|
545 | } | |
|
546 | ||
|
547 | return status; | |
|
433 | 548 | } |
|
434 | 549 | |
|
435 | rtems_status_code create_message_queues( void ) | |
|
550 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
|
436 | 551 | { |
|
437 | 552 | rtems_status_code status; |
|
438 | 553 | rtems_status_code ret; |
|
439 | 554 | rtems_id queue_id; |
|
440 | 555 | |
|
556 | // create the queue for handling TM packet sending | |
|
441 | 557 | ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, |
|
442 | 558 | ACTION_MSG_PKTS_MAX_SIZE, |
|
443 | 559 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
444 | 560 | if (ret != RTEMS_SUCCESSFUL) { |
|
445 | 561 | BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret) |
|
446 | 562 | } |
|
447 | 563 | |
|
564 | // create the queue for handling valid TCs | |
|
448 | 565 | status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, |
|
449 | 566 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
450 | 567 | if (status != RTEMS_SUCCESSFUL) { |
|
451 | 568 | ret = status; |
|
452 | 569 | BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret) |
|
453 | 570 | } |
|
454 | 571 | |
|
455 | 572 | return ret; |
|
456 | 573 | } |
@@ -1,325 +1,331 | |||
|
1 |
#include |
|
|
2 | #include <fsw_params.h> | |
|
1 | #include "fsw_misc.h" | |
|
3 | 2 | |
|
4 | 3 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
5 | 4 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
6 | 5 | { // configure the timer for the waveforms simulation |
|
7 | 6 | rtems_status_code status; |
|
8 | 7 | rtems_isr_entry old_isr_handler; |
|
9 | 8 | |
|
10 | 9 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
11 | 10 | if (status!=RTEMS_SUCCESSFUL) |
|
12 | 11 | { |
|
13 | 12 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
14 | 13 | } |
|
15 | 14 | |
|
16 | 15 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); |
|
17 | 16 | |
|
18 | 17 | return 1; |
|
19 | 18 | } |
|
20 | 19 | |
|
21 | 20 | int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
22 | 21 | { |
|
23 | 22 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
24 | 23 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
25 | 24 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
26 | 25 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
27 | 26 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
28 | 27 | |
|
29 | 28 | return 1; |
|
30 | 29 | } |
|
31 | 30 | |
|
32 | 31 | int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
33 | 32 | { |
|
34 | 33 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
35 | 34 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
36 | 35 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
37 | 36 | |
|
38 | 37 | return 1; |
|
39 | 38 | } |
|
40 | 39 | |
|
41 | 40 | int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) |
|
42 | 41 | { |
|
43 | 42 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
44 | 43 | |
|
45 | 44 | return 1; |
|
46 | 45 | } |
|
47 | 46 | |
|
48 | 47 | void update_spacewire_statistics() |
|
49 | 48 | { |
|
50 | 49 | rtems_status_code status; |
|
51 | 50 | spw_stats spacewire_stats_grspw; |
|
52 | 51 | |
|
53 | 52 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
54 | 53 | |
|
55 | 54 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
56 | 55 | + spacewire_stats_grspw.packets_received; |
|
57 | 56 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
58 | 57 | + spacewire_stats_grspw.packets_sent; |
|
59 | 58 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
60 | 59 | + spacewire_stats_grspw.parity_err; |
|
61 | 60 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
62 | 61 | + spacewire_stats_grspw.disconnect_err; |
|
63 | 62 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
64 | 63 | + spacewire_stats_grspw.escape_err; |
|
65 | 64 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
66 | 65 | + spacewire_stats_grspw.credit_err; |
|
67 | 66 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
68 | 67 | + spacewire_stats_grspw.write_sync_err; |
|
69 | 68 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
70 | 69 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
71 | 70 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
72 | 71 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
73 | 72 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
74 | 73 | + spacewire_stats_grspw.early_ep; |
|
75 | 74 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
76 | 75 | + spacewire_stats_grspw.invalid_address; |
|
77 | 76 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
78 | 77 | + spacewire_stats_grspw.rx_eep_err; |
|
79 | 78 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
80 | 79 | + spacewire_stats_grspw.rx_truncated; |
|
81 | 80 | //spacewire_stats.tx_link_err; |
|
82 | 81 | |
|
83 | 82 | //**************************** |
|
84 | 83 | // DPU_SPACEWIRE_IF_STATISTICS |
|
85 | 84 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
86 | 85 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
87 | 86 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
88 | 87 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
89 | 88 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
90 | 89 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
91 | 90 | |
|
92 | 91 | //****************************************** |
|
93 | 92 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
94 | 93 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
95 | 94 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
96 | 95 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
97 | 96 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
98 | 97 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
99 | 98 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb; |
|
100 | 99 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb; |
|
101 | 100 | housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err; |
|
102 | 101 | housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err; |
|
103 | 102 | |
|
104 | 103 | //********************************************* |
|
105 | 104 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
106 | 105 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
107 | 106 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
108 | 107 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
109 | 108 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
110 | 109 | |
|
111 | 110 | } |
|
112 | 111 | |
|
113 | 112 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
114 | 113 | { |
|
115 | 114 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
116 | 115 | |
|
117 | 116 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; |
|
118 | 117 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
119 | 118 | |
|
120 | 119 | return 0; |
|
121 | 120 | } |
|
122 | 121 | |
|
123 |
|
|
|
122 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
|
124 | 123 | { |
|
124 | /** This function sets the scaler reload register of the apbuart module | |
|
125 | * | |
|
126 | * @param regs is the address of the apbuart registers in memory | |
|
127 | * @param value is the value that will be stored in the scaler register | |
|
128 | * | |
|
129 | * The value shall be set by the software to get data on the serial interface. | |
|
130 | * | |
|
131 | */ | |
|
132 | ||
|
125 | 133 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
126 | 134 | |
|
127 | 135 | apbuart_regs->scaler = value; |
|
128 | 136 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
129 | ||
|
130 | return 0; | |
|
131 | 137 | } |
|
132 | 138 | |
|
133 | 139 | //************ |
|
134 | 140 | // RTEMS TASKS |
|
135 | 141 | |
|
136 | 142 | rtems_task stat_task(rtems_task_argument argument) |
|
137 | 143 | { |
|
138 | 144 | int i; |
|
139 | 145 | int j; |
|
140 | 146 | i = 0; |
|
141 | 147 | j = 0; |
|
142 | 148 | BOOT_PRINTF("in STAT *** \n") |
|
143 | 149 | while(1){ |
|
144 | 150 | rtems_task_wake_after(1000); |
|
145 | 151 | PRINTF1("%d\n", j) |
|
146 | 152 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
147 | 153 | // #ifdef PRINT_TASK_STATISTICS |
|
148 | 154 | // rtems_cpu_usage_report(); |
|
149 | 155 | // rtems_cpu_usage_reset(); |
|
150 | 156 | // #endif |
|
151 | 157 | i = 0; |
|
152 | 158 | } |
|
153 | 159 | else i++; |
|
154 | 160 | j++; |
|
155 | 161 | } |
|
156 | 162 | } |
|
157 | 163 | |
|
158 | 164 | rtems_task hous_task(rtems_task_argument argument) |
|
159 | 165 | { |
|
160 | 166 | rtems_status_code status; |
|
161 | 167 | spw_ioctl_pkt_send spw_ioctl_send; |
|
162 | 168 | rtems_id queue_id; |
|
163 | 169 | |
|
164 | 170 | spw_ioctl_send.hlen = 0; |
|
165 | 171 | spw_ioctl_send.hdr = NULL; |
|
166 | 172 | spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
167 | 173 | spw_ioctl_send.data = (char*) &housekeeping_packet; |
|
168 | 174 | spw_ioctl_send.options = 0; |
|
169 | 175 | |
|
170 | 176 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id ); |
|
171 | 177 | if (status != RTEMS_SUCCESSFUL) |
|
172 | 178 | { |
|
173 | 179 | PRINTF1("in HOUS *** ERR %d\n", status) |
|
174 | 180 | } |
|
175 | 181 | |
|
176 | 182 | BOOT_PRINTF("in HOUS ***\n") |
|
177 | 183 | |
|
178 | 184 | if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) { |
|
179 | 185 | status = rtems_rate_monotonic_create( HK_name, &HK_id ); |
|
180 | 186 | if( status != RTEMS_SUCCESSFUL ) { |
|
181 | 187 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
182 | 188 | } |
|
183 | 189 | } |
|
184 | 190 | |
|
185 | 191 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
186 | 192 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
187 | 193 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
188 | 194 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
189 | 195 | housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8); |
|
190 | 196 | housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK); |
|
191 | 197 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
192 | 198 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
193 | 199 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
194 | 200 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
195 | 201 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
196 | 202 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
197 | 203 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
198 | 204 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
199 | 205 | |
|
200 | 206 | status = rtems_rate_monotonic_cancel(HK_id); |
|
201 | 207 | if( status != RTEMS_SUCCESSFUL ) { |
|
202 | 208 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
203 | 209 | } |
|
204 | 210 | else { |
|
205 | 211 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
206 | 212 | } |
|
207 | 213 | |
|
208 | 214 | while(1){ // launch the rate monotonic task |
|
209 | 215 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
210 | 216 | if ( status != RTEMS_SUCCESSFUL ) { |
|
211 | 217 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status); |
|
212 | 218 | } |
|
213 | 219 | else { |
|
214 | 220 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
215 | 221 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
216 | 222 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
217 | 223 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
218 | 224 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
219 | 225 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
220 | 226 | housekeeping_packet.sid = SID_HK; |
|
221 | 227 | |
|
222 | 228 | update_spacewire_statistics(); |
|
223 | 229 | |
|
224 | 230 | // SEND PACKET |
|
225 | 231 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
226 | 232 | if (status != RTEMS_SUCCESSFUL) { |
|
227 | 233 | PRINTF1("in HOUS *** ERR %d\n", status) |
|
228 | 234 | } |
|
229 | 235 | } |
|
230 | 236 | } |
|
231 | 237 | |
|
232 | 238 | PRINTF("in HOUS *** deleting task\n") |
|
233 | 239 | |
|
234 | 240 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
235 | 241 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
236 | 242 | exit( 1 ); |
|
237 | 243 | } |
|
238 | 244 | |
|
239 | 245 | rtems_task send_task( rtems_task_argument argument) |
|
240 | 246 | { |
|
241 | 247 | rtems_status_code status; // RTEMS status code |
|
242 | 248 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer |
|
243 | 249 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
244 | 250 | size_t size; // size of the incoming TC packet |
|
245 | 251 | u_int32_t count; |
|
246 | 252 | rtems_id queue_id; |
|
247 | 253 | |
|
248 | 254 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id ); |
|
249 | 255 | if (status != RTEMS_SUCCESSFUL) |
|
250 | 256 | { |
|
251 | 257 | PRINTF1("in SEND *** ERR getting queue id, %d\n", status) |
|
252 | 258 | } |
|
253 | 259 | |
|
254 | 260 | BOOT_PRINTF("in SEND *** \n") |
|
255 | 261 | |
|
256 | 262 | while(1) |
|
257 | 263 | { |
|
258 | 264 | status = rtems_message_queue_receive( queue_id, incomingData, &size, |
|
259 | 265 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
260 | 266 | |
|
261 | 267 | if (status!=RTEMS_SUCCESSFUL) |
|
262 | 268 | { |
|
263 | 269 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
264 | 270 | } |
|
265 | 271 | else |
|
266 | 272 | { |
|
267 | 273 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet |
|
268 | 274 | { |
|
269 | 275 | status = write( fdSPW, incomingData, size ); |
|
270 | 276 | if (status == -1){ |
|
271 | 277 | PRINTF2("in SEND *** (2.a) ERR = %d, size = %d\n", status, size) |
|
272 | 278 | } |
|
273 | 279 | } |
|
274 | 280 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
275 | 281 | { |
|
276 | 282 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
277 | 283 | if (spw_ioctl_send->hlen == 0) |
|
278 | 284 | { |
|
279 | 285 | status = write( fdSPW, spw_ioctl_send->data, spw_ioctl_send->dlen ); |
|
280 | 286 | if (status == -1){ |
|
281 | 287 | PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen) |
|
282 | 288 | } |
|
283 | 289 | } |
|
284 | 290 | else |
|
285 | 291 | { |
|
286 | 292 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
287 | 293 | if (status == -1){ |
|
288 | 294 | PRINTF2("in SEND *** (2.c) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen) |
|
289 | 295 | PRINTF1(" hlen = %d\n", spw_ioctl_send->hlen) |
|
290 | 296 | } |
|
291 | 297 | } |
|
292 | 298 | } |
|
293 | 299 | } |
|
294 | 300 | |
|
295 | 301 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
296 | 302 | if (status != RTEMS_SUCCESSFUL) |
|
297 | 303 | { |
|
298 | 304 | PRINTF1("in SEND *** (3) ERR = %d\n", status) |
|
299 | 305 | } |
|
300 | 306 | else |
|
301 | 307 | { |
|
302 | 308 | if (count > maxCount) |
|
303 | 309 | { |
|
304 | 310 | maxCount = count; |
|
305 | 311 | } |
|
306 | 312 | } |
|
307 | 313 | } |
|
308 | 314 | } |
|
309 | 315 | |
|
310 | 316 | rtems_id get_pkts_queue_id( void ) |
|
311 | 317 | { |
|
312 | 318 | rtems_id queue_id; |
|
313 | 319 | rtems_status_code status; |
|
314 | 320 | |
|
315 | 321 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id ); |
|
316 | 322 | if (status != RTEMS_SUCCESSFUL) |
|
317 | 323 | { |
|
318 | 324 | PRINTF1("in get_pkts_queue_id *** ERR %d\n", status) |
|
319 | 325 | } |
|
320 | 326 | return queue_id; |
|
321 | 327 | } |
|
322 | 328 | |
|
323 | 329 | |
|
324 | 330 | |
|
325 | 331 |
@@ -1,688 +1,669 | |||
|
1 | 1 | #include <fsw_processing.h> |
|
2 | 2 | #include <math.h> |
|
3 | 3 | |
|
4 | 4 | #include <fsw_processing_globals.c> |
|
5 | 5 | |
|
6 | 6 | unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ]; |
|
7 | 7 | BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ]; |
|
8 | 8 | float averaged_spec_mat_f0[ TOTAL_SIZE_SM ]; |
|
9 | 9 | char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ]; |
|
10 | 10 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; |
|
11 | 11 | |
|
12 | 12 | //*********************************************************** |
|
13 | 13 | // Interrupt Service Routine for spectral matrices processing |
|
14 | 14 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
15 | 15 | { |
|
16 | 16 | unsigned char status; |
|
17 | 17 | unsigned char i; |
|
18 | 18 | |
|
19 | 19 | status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0] |
|
20 | 20 | for (i=0; i<4; i++) |
|
21 | 21 | { |
|
22 | 22 | if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation |
|
23 | 23 | { |
|
24 | 24 | switch(i) |
|
25 | 25 | { |
|
26 | 26 | case 0: |
|
27 | 27 | if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0) |
|
28 | 28 | { |
|
29 | 29 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis; |
|
30 | 30 | } |
|
31 | 31 | else |
|
32 | 32 | { |
|
33 | 33 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; |
|
34 | 34 | } |
|
35 | 35 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; |
|
36 | 36 | break; |
|
37 | 37 | case 1: |
|
38 | 38 | if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1) |
|
39 | 39 | { |
|
40 | 40 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis; |
|
41 | 41 | } |
|
42 | 42 | else |
|
43 | 43 | { |
|
44 | 44 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; |
|
45 | 45 | } |
|
46 | 46 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; |
|
47 | 47 | break; |
|
48 | 48 | case 2: |
|
49 | 49 | if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1) |
|
50 | 50 | { |
|
51 | 51 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis; |
|
52 | 52 | } |
|
53 | 53 | else |
|
54 | 54 | { |
|
55 | 55 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; |
|
56 | 56 | } |
|
57 | 57 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb; |
|
58 | 58 | break; |
|
59 | 59 | case 3: |
|
60 | 60 | if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2) |
|
61 | 61 | { |
|
62 | 62 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis; |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; |
|
67 | 67 | } |
|
68 | 68 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7; |
|
69 | 69 | break; |
|
70 | 70 | default: |
|
71 | 71 | break; |
|
72 | 72 | } |
|
73 | 73 | } |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | // reset error codes to 0 |
|
77 | 77 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111] |
|
78 | 78 | |
|
79 | 79 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
80 | 80 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 ); |
|
81 | 81 | } |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
85 | 85 | { |
|
86 | 86 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
87 | 87 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 ); |
|
88 | 88 | } |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | //************ |
|
92 | 92 | // RTEMS TASKS |
|
93 | 93 | |
|
94 | 94 | rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ |
|
95 | 95 | { |
|
96 | 96 | rtems_event_set event_out; |
|
97 | 97 | unsigned int nb_interrupt_f0 = 0; |
|
98 | 98 | |
|
99 | 99 | BOOT_PRINTF("in SMIQ *** \n") |
|
100 | 100 | |
|
101 | 101 | while(1){ |
|
102 | 102 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
103 | 103 | nb_interrupt_f0 = nb_interrupt_f0 + 1; |
|
104 | 104 | if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){ |
|
105 | 105 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
106 | 106 | { |
|
107 | 107 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
108 | 108 | } |
|
109 | 109 | nb_interrupt_f0 = 0; |
|
110 | 110 | } |
|
111 | 111 | } |
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ |
|
115 | 115 | //{ |
|
116 | 116 | // rtems_event_set event_out; |
|
117 | 117 | // unsigned int nb_interrupt_f0 = 0; |
|
118 | 118 | |
|
119 | 119 | // PRINTF("in SMIQ *** \n") |
|
120 | 120 | |
|
121 | 121 | // while(1){ |
|
122 | 122 | // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
123 | 123 | // nb_interrupt_f0 = nb_interrupt_f0 + 1; |
|
124 | 124 | // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){ |
|
125 | 125 | // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
126 | 126 | // { |
|
127 | 127 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
128 | 128 | // } |
|
129 | 129 | // nb_interrupt_f0 = 0; |
|
130 | 130 | // } |
|
131 | 131 | // } |
|
132 | 132 | //} |
|
133 | 133 | |
|
134 | 134 | rtems_task spw_bppr_task(rtems_task_argument argument) |
|
135 | 135 | { |
|
136 | 136 | rtems_status_code status; |
|
137 | 137 | rtems_event_set event_out; |
|
138 | static int Nb_average_f0 = 0; | |
|
139 | //static int nb_average_f1 = 0; | |
|
140 | //static int nb_average_f2 = 0; | |
|
141 | 138 | |
|
142 | 139 | BOOT_PRINTF("in BPPR ***\n"); |
|
143 | 140 | |
|
144 | while(true){ // wait for an event to begin with the processing | |
|
141 | while( true ){ // wait for an event to begin with the processing | |
|
145 | 142 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); |
|
146 | if (status == RTEMS_SUCCESSFUL) { | |
|
147 | if ((spectral_matrix_regs->status & 0x00000001)==1) { | |
|
148 | matrix_average(spec_mat_f0_0, averaged_spec_mat_f0); | |
|
149 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; | |
|
150 | //printf("f0_a\n"); | |
|
151 | Nb_average_f0++; | |
|
152 | } | |
|
153 | if (((spectral_matrix_regs->status>>1) & 0x00000001)==1) { | |
|
154 | matrix_average(spec_mat_f0_1, compressed_spec_mat_f0); | |
|
155 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; | |
|
156 | //printf("f0_b\n"); | |
|
157 | Nb_average_f0++; | |
|
158 | } | |
|
159 | if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) { | |
|
160 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); | |
|
161 | //printf("f0 compressed\n"); | |
|
162 | Nb_average_f0 = 0; | |
|
163 | matrix_reset(averaged_spec_mat_f0); | |
|
164 | } | |
|
165 | } | |
|
166 | 143 | } |
|
167 | 144 | } |
|
168 | 145 | |
|
169 | 146 | rtems_task avf0_task(rtems_task_argument argument) |
|
170 | 147 | { |
|
171 | 148 | int i; |
|
172 | 149 | static int nb_average; |
|
173 | 150 | rtems_event_set event_out; |
|
174 | 151 | rtems_status_code status; |
|
175 | 152 | |
|
176 | 153 | nb_average = 0; |
|
177 | 154 | |
|
178 | 155 | BOOT_PRINTF("in AVFO *** \n") |
|
179 | 156 | |
|
180 | 157 | while(1){ |
|
181 | 158 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
182 | 159 | for(i=0; i<TOTAL_SIZE_SM; i++){ |
|
183 | 160 | averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i] |
|
184 | 161 | + spec_mat_f0_b[i] |
|
185 | 162 | + spec_mat_f0_c[i] |
|
186 | 163 | + spec_mat_f0_d[i] |
|
187 | 164 | + spec_mat_f0_e[i] |
|
188 | 165 | + spec_mat_f0_f[i] |
|
189 | 166 | + spec_mat_f0_g[i] |
|
190 | 167 | + spec_mat_f0_h[i]; |
|
191 | 168 | } |
|
192 | 169 | nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0; |
|
193 | 170 | if (nb_average == NB_AVERAGE_NORMAL_f0) { |
|
194 | 171 | nb_average = 0; |
|
195 | 172 | status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 |
|
196 | 173 | if (status != RTEMS_SUCCESSFUL) { |
|
197 | 174 | printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); |
|
198 | 175 | } |
|
199 | 176 | } |
|
200 | 177 | } |
|
201 | 178 | } |
|
202 | 179 | |
|
203 | 180 | rtems_task bpf0_task(rtems_task_argument argument) |
|
204 | 181 | { |
|
205 | 182 | rtems_event_set event_out; |
|
206 | 183 | |
|
207 | 184 | BOOT_PRINTF("in BPFO *** \n") |
|
208 | 185 | |
|
209 | 186 | while(1){ |
|
210 | 187 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
211 | 188 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); |
|
212 | 189 | BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0); |
|
213 | 190 | //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n") |
|
214 | 191 | } |
|
215 | 192 | } |
|
216 | 193 | |
|
217 | 194 | rtems_task matr_task(rtems_task_argument argument) |
|
218 | 195 | { |
|
219 | 196 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
220 | 197 | rtems_event_set event_out; |
|
221 | 198 | rtems_status_code status; |
|
222 | 199 | rtems_id queue_id; |
|
223 | 200 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
224 | 201 | |
|
225 | 202 | init_header_asm( &headerASM ); |
|
226 | 203 | |
|
227 | 204 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id ); |
|
228 | 205 | if (status != RTEMS_SUCCESSFUL) |
|
229 | 206 | { |
|
230 | 207 | PRINTF1("in MATR *** ERR getting queue id, %d\n", status) |
|
231 | 208 | } |
|
232 | 209 | |
|
233 | 210 | BOOT_PRINTF("in MATR *** \n") |
|
234 | 211 | |
|
235 | 212 | fill_averaged_spectral_matrix( ); |
|
236 | 213 | |
|
237 | 214 | while(1){ |
|
238 | 215 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
239 | 216 | |
|
240 | 217 | #ifdef GSA |
|
241 | 218 | #else |
|
242 | 219 | fill_averaged_spectral_matrix( ); |
|
243 | 220 | #endif |
|
244 | 221 | convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char); |
|
245 | 222 | |
|
246 | 223 | send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); |
|
247 | 224 | } |
|
248 | 225 | } |
|
249 | 226 | |
|
250 | 227 | //***************************** |
|
251 | 228 | // Spectral matrices processing |
|
252 | void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat) | |
|
253 | { | |
|
254 | int i; | |
|
255 | for(i=0; i<TOTAL_SIZE_SM; i++){ | |
|
256 | averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_0[i] | |
|
257 | + spec_mat_f0_1[i] | |
|
258 | + spec_mat_f0_c[i] | |
|
259 | + spec_mat_f0_d[i] | |
|
260 | + spec_mat_f0_e[i] | |
|
261 | + spec_mat_f0_f[i] | |
|
262 | + spec_mat_f0_g[i] | |
|
263 | + spec_mat_f0_h[i]; | |
|
264 | } | |
|
265 | } | |
|
266 | 229 | |
|
267 | 230 | void matrix_reset(volatile float *averaged_spec_mat) |
|
268 | 231 | { |
|
269 | 232 | // int i; |
|
270 | 233 | // for(i=0; i<TOTAL_SIZE_SM; i++){ |
|
271 | 234 | // averaged_spec_mat_f0[i] = 0; |
|
272 | 235 | // } |
|
273 | 236 | } |
|
274 | 237 | |
|
275 | 238 | void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) |
|
276 | 239 | { |
|
277 | 240 | int i; |
|
278 | 241 | int j; |
|
279 | 242 | switch (fChannel){ |
|
280 | 243 | case 0: |
|
281 | 244 | for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){ |
|
282 | 245 | j = 17 + (i * 8); |
|
283 | 246 | compressed_spec_mat[i] = (averaged_spec_mat[j] |
|
284 | 247 | + averaged_spec_mat[j+1] |
|
285 | 248 | + averaged_spec_mat[j+2] |
|
286 | 249 | + averaged_spec_mat[j+3] |
|
287 | 250 | + averaged_spec_mat[j+4] |
|
288 | 251 | + averaged_spec_mat[j+5] |
|
289 | 252 | + averaged_spec_mat[j+6] |
|
290 | 253 | + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0); |
|
291 | 254 | } |
|
292 | 255 | break; |
|
293 | 256 | case 1: |
|
294 | 257 | // case fChannel = f1 to be completed later |
|
295 | 258 | break; |
|
296 | 259 | case 2: |
|
297 | 260 | // case fChannel = f1 to be completed later |
|
298 | 261 | break; |
|
299 | 262 | default: |
|
300 | 263 | break; |
|
301 | 264 | } |
|
302 | 265 | } |
|
303 | 266 | |
|
304 | 267 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ |
|
305 | 268 | int i; |
|
306 | 269 | int j; |
|
307 | 270 | unsigned char tmp_u_char; |
|
308 | 271 | unsigned char * pt_char = NULL; |
|
309 | 272 | float PSDB, PSDE; |
|
310 | 273 | float NVEC_V0; |
|
311 | 274 | float NVEC_V1; |
|
312 | 275 | float NVEC_V2; |
|
313 | 276 | //float significand; |
|
314 | 277 | //int exponent; |
|
315 | 278 | float aux; |
|
316 | 279 | float tr_SB_SB; |
|
317 | 280 | float tmp; |
|
318 | 281 | float sx_re; |
|
319 | 282 | float sx_im; |
|
320 | 283 | float nebx_re = 0; |
|
321 | 284 | float nebx_im = 0; |
|
322 | 285 | float ny = 0; |
|
323 | 286 | float nz = 0; |
|
324 | 287 | float bx_bx_star = 0; |
|
325 | 288 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ |
|
326 | 289 | //============================================== |
|
327 | 290 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits |
|
328 | 291 | PSDB = compressed_spec_mat[i*30] // S11 |
|
329 | 292 | + compressed_spec_mat[(i*30) + 10] // S22 |
|
330 | 293 | + compressed_spec_mat[(i*30) + 18]; // S33 |
|
331 | 294 | //significand = frexp(PSDB, &exponent); |
|
332 | 295 | pt_char = (unsigned char*) &PSDB; |
|
333 | 296 | LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float |
|
334 | 297 | LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float |
|
335 | 298 | //============================================== |
|
336 | 299 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits |
|
337 | 300 | PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44 |
|
338 | 301 | + compressed_spec_mat[(i*30) + 28] * K55_pe // S55 |
|
339 | 302 | + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45 |
|
340 | 303 | - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45 |
|
341 | 304 | pt_char = (unsigned char*) &PSDE; |
|
342 | 305 | LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float |
|
343 | 306 | LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float |
|
344 | 307 | //============================================================================== |
|
345 | 308 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits |
|
346 | 309 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits |
|
347 | 310 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits |
|
348 | 311 | tmp = sqrt( |
|
349 | 312 | compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12 |
|
350 | 313 | +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13 |
|
351 | 314 | +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23 |
|
352 | 315 | ); |
|
353 | 316 | NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23 |
|
354 | 317 | NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13 |
|
355 | 318 | NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12 |
|
356 | 319 | LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127); |
|
357 | 320 | LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127); |
|
358 | 321 | pt_char = (unsigned char*) &NVEC_V2; |
|
359 | 322 | LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 |
|
360 | 323 | //======================================================= |
|
361 | 324 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits |
|
362 | 325 | aux = 2*tmp / PSDB; // compute the ellipticity |
|
363 | 326 | tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity |
|
364 | 327 | LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char |
|
365 | 328 | //============================================================== |
|
366 | 329 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits |
|
367 | 330 | for(j = 0; j<NB_VALUES_PER_SM;j++){ |
|
368 | 331 | tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30] |
|
369 | 332 | + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10] |
|
370 | 333 | + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18] |
|
371 | 334 | + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2] |
|
372 | 335 | + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3] |
|
373 | 336 | + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4] |
|
374 | 337 | + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5] |
|
375 | 338 | + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12] |
|
376 | 339 | + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13]; |
|
377 | 340 | } |
|
378 | 341 | aux = PSDB*PSDB; |
|
379 | 342 | tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) ); |
|
380 | 343 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); |
|
381 | 344 | LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char |
|
382 | 345 | //======================================================================================= |
|
383 | 346 | // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) |
|
384 | 347 | sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re |
|
385 | 348 | + compressed_spec_mat[(i*30) + 6] * K14_sx_re |
|
386 | 349 | + compressed_spec_mat[(i*30) + 8] * K15_sx_re |
|
387 | 350 | + compressed_spec_mat[(i*30) + 14] * K24_sx_re |
|
388 | 351 | + compressed_spec_mat[(i*30) + 16] * K25_sx_re |
|
389 | 352 | + compressed_spec_mat[(i*30) + 22] * K35_sx_re; |
|
390 | 353 | sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im |
|
391 | 354 | + compressed_spec_mat[(i*30) + 7] * K14_sx_im |
|
392 | 355 | + compressed_spec_mat[(i*30) + 9] * K15_sx_im |
|
393 | 356 | + compressed_spec_mat[(i*30) + 15] * K24_sx_im |
|
394 | 357 | + compressed_spec_mat[(i*30) + 17] * K25_sx_im |
|
395 | 358 | + compressed_spec_mat[(i*30) + 23] * K35_sx_im; |
|
396 | 359 | LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression |
|
397 | 360 | if ( abs(sx_re) > abs(sx_im) ) { |
|
398 | 361 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx |
|
399 | 362 | } |
|
400 | 363 | else { |
|
401 | 364 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx |
|
402 | 365 | } |
|
403 | 366 | //====================================================================== |
|
404 | 367 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) |
|
405 | 368 | ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2; |
|
406 | 369 | nz = NVEC_V0; |
|
407 | 370 | bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22 |
|
408 | 371 | + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33 |
|
409 | 372 | - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23 |
|
410 | 373 | nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re |
|
411 | 374 | +compressed_spec_mat[(i*30) + 16] * K25_ny_re |
|
412 | 375 | +compressed_spec_mat[(i*30) + 20] * K34_ny_re |
|
413 | 376 | +compressed_spec_mat[(i*30) + 22] * K35_ny_re) |
|
414 | 377 | + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re |
|
415 | 378 | +compressed_spec_mat[(i*30) + 16] * K25_nz_re |
|
416 | 379 | +compressed_spec_mat[(i*30) + 20] * K34_nz_re |
|
417 | 380 | +compressed_spec_mat[(i*30) + 22] * K35_nz_re); |
|
418 | 381 | nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re |
|
419 | 382 | +compressed_spec_mat[(i*30) + 17] * K25_ny_re |
|
420 | 383 | +compressed_spec_mat[(i*30) + 21] * K34_ny_re |
|
421 | 384 | +compressed_spec_mat[(i*30) + 23] * K35_ny_re) |
|
422 | 385 | + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im |
|
423 | 386 | +compressed_spec_mat[(i*30) + 17] * K25_nz_im |
|
424 | 387 | +compressed_spec_mat[(i*30) + 21] * K34_nz_im |
|
425 | 388 | +compressed_spec_mat[(i*30) + 23] * K35_nz_im); |
|
426 | 389 | tmp = nebx_re / bx_bx_star; |
|
427 | 390 | LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression |
|
428 | 391 | if ( abs(nebx_re) > abs(nebx_im) ) { |
|
429 | 392 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx |
|
430 | 393 | } |
|
431 | 394 | else { |
|
432 | 395 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx |
|
433 | 396 | } |
|
434 | 397 | } |
|
435 | 398 | |
|
436 | 399 | } |
|
437 | 400 | |
|
438 | 401 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ |
|
439 | 402 | // BP2 autocorrelation |
|
440 | 403 | int i; |
|
441 | 404 | int aux = 0; |
|
442 | 405 | |
|
443 | 406 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ |
|
444 | 407 | // S12 |
|
445 | 408 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]); |
|
446 | 409 | compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux; |
|
447 | 410 | compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux; |
|
448 | 411 | // S13 |
|
449 | 412 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]); |
|
450 | 413 | compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux; |
|
451 | 414 | compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux; |
|
452 | 415 | // S23 |
|
453 | 416 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]); |
|
454 | 417 | compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux; |
|
455 | 418 | compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux; |
|
456 | 419 | // S45 |
|
457 | 420 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]); |
|
458 | 421 | compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux; |
|
459 | 422 | compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux; |
|
460 | 423 | // S14 |
|
461 | 424 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]); |
|
462 | 425 | compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux; |
|
463 | 426 | compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux; |
|
464 | 427 | // S15 |
|
465 | 428 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]); |
|
466 | 429 | compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux; |
|
467 | 430 | compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux; |
|
468 | 431 | // S24 |
|
469 | 432 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]); |
|
470 | 433 | compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux; |
|
471 | 434 | compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux; |
|
472 | 435 | // S25 |
|
473 | 436 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]); |
|
474 | 437 | compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux; |
|
475 | 438 | compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux; |
|
476 | 439 | // S34 |
|
477 | 440 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]); |
|
478 | 441 | compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux; |
|
479 | 442 | compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux; |
|
480 | 443 | // S35 |
|
481 | 444 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]); |
|
482 | 445 | compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux; |
|
483 | 446 | compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux; |
|
484 | 447 | } |
|
485 | 448 | } |
|
486 | 449 | |
|
487 | 450 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header) |
|
488 | 451 | { |
|
489 | 452 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
490 | 453 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
491 | 454 | header->reserved = 0x00; |
|
492 | 455 | header->userApplication = CCSDS_USER_APP; |
|
493 | 456 | header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
494 | 457 | header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
495 | 458 | header->packetSequenceControl[0] = 0xc0; |
|
496 | 459 | header->packetSequenceControl[1] = 0x00; |
|
497 | 460 | header->packetLength[0] = 0x00; |
|
498 | 461 | header->packetLength[1] = 0x00; |
|
499 | 462 | // DATA FIELD HEADER |
|
500 | 463 | header->spare1_pusVersion_spare2 = 0x10; |
|
501 | 464 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
502 | 465 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
503 | 466 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
504 | 467 | // AUXILIARY DATA HEADER |
|
505 | 468 | header->sid = 0x00; |
|
506 | 469 | header->biaStatusInfo = 0x00; |
|
507 | 470 | header->cntASM = 0x00; |
|
508 | 471 | header->nrASM = 0x00; |
|
509 | 472 | header->time[0] = 0x00; |
|
510 | 473 | header->time[0] = 0x00; |
|
511 | 474 | header->time[0] = 0x00; |
|
512 | 475 | header->time[0] = 0x00; |
|
513 | 476 | header->time[0] = 0x00; |
|
514 | 477 | header->time[0] = 0x00; |
|
515 | 478 | header->blkNr[0] = 0x00; // BLK_NR MSB |
|
516 | 479 | header->blkNr[1] = 0x00; // BLK_NR LSB |
|
517 | 480 | } |
|
518 | 481 | |
|
519 | 482 | void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
520 | 483 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) |
|
521 | 484 | { |
|
522 | 485 | unsigned int i; |
|
523 | 486 | unsigned int length = 0; |
|
524 | 487 | rtems_status_code status; |
|
525 | 488 | |
|
526 | 489 | header->sid = (unsigned char) sid; |
|
527 | 490 | |
|
528 | 491 | for (i=0; i<2; i++) |
|
529 | 492 | { |
|
530 | 493 | // BUILD THE DATA |
|
531 | 494 | spw_ioctl_send->dlen = TOTAL_SIZE_SM; |
|
532 | 495 | spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM]; |
|
533 | 496 | spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
534 | 497 | spw_ioctl_send->hdr = (char *) header; |
|
535 | 498 | spw_ioctl_send->options = 0; |
|
536 | 499 | |
|
537 | 500 | // BUILD THE HEADER |
|
538 | 501 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM; |
|
539 | 502 | header->packetLength[0] = (unsigned char) (length>>8); |
|
540 | 503 | header->packetLength[1] = (unsigned char) (length); |
|
541 | 504 | header->sid = (unsigned char) sid; // SID |
|
542 | 505 | header->cntASM = 2; |
|
543 | 506 | header->nrASM = (unsigned char) (i+1); |
|
544 | 507 | header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB |
|
545 | 508 | header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB |
|
546 | 509 | // SET PACKET TIME |
|
547 | 510 | header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
548 | 511 | header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
549 | 512 | header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
550 | 513 | header->time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
551 | 514 | header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
552 | 515 | header->time[5] = (unsigned char) (time_management_regs->fine_time); |
|
553 | 516 | header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
554 | 517 | header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
555 | 518 | header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
556 | 519 | header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
557 | 520 | header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
558 | 521 | header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
559 | 522 | // SEND PACKET |
|
560 | 523 | status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
561 | 524 | if (status != RTEMS_SUCCESSFUL) { |
|
562 | 525 | printf("in send_spectral_matrix *** ERR %d\n", (int) status); |
|
563 | 526 | } |
|
564 | 527 | } |
|
565 | 528 | } |
|
566 | 529 | |
|
567 | 530 | void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix) |
|
568 | 531 | { |
|
569 | 532 | unsigned int i; |
|
570 | 533 | unsigned int j; |
|
571 | 534 | char * pt_char_input; |
|
572 | 535 | char * pt_char_output; |
|
573 | 536 | |
|
574 | 537 | pt_char_input = NULL; |
|
575 | 538 | pt_char_output = NULL; |
|
576 | 539 | |
|
577 | 540 | for( i=0; i<NB_BINS_PER_SM; i++) |
|
578 | 541 | { |
|
579 | 542 | for ( j=0; j<NB_VALUES_PER_SM; j++) |
|
580 | 543 | { |
|
581 | 544 | pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ]; |
|
582 | 545 | pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ]; |
|
583 | 546 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
584 | 547 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
585 | 548 | } |
|
586 | 549 | } |
|
587 | 550 | } |
|
588 | 551 | |
|
589 |
void fill_averaged_spectral_matrix( |
|
|
552 | void fill_averaged_spectral_matrix(void) | |
|
590 | 553 | { |
|
554 | /** This function fills spectral matrices related buffers with arbitrary data. | |
|
555 | * | |
|
556 | * This function is for testing purpose only. | |
|
557 | * | |
|
558 | */ | |
|
591 | 559 | |
|
592 | 560 | #ifdef GSA |
|
593 | 561 | float offset = 10.; |
|
594 | 562 | float coeff = 100000.; |
|
595 | 563 | |
|
596 | 564 | averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset; |
|
597 | 565 | averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset; |
|
598 | 566 | averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset; |
|
599 | 567 | averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset; |
|
600 | 568 | averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset; |
|
601 | 569 | averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset; |
|
602 | 570 | averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset; |
|
603 | 571 | averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset; |
|
604 | 572 | averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset; |
|
605 | 573 | averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset; |
|
606 | 574 | averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset; |
|
607 | 575 | averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset; |
|
608 | 576 | averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset; |
|
609 | 577 | averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset; |
|
610 | 578 | averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset; |
|
611 | 579 | averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff; |
|
612 | 580 | averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff; |
|
613 | 581 | averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff; |
|
614 | 582 | averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff; |
|
615 | 583 | averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff; |
|
616 | 584 | averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff; |
|
617 | 585 | averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff; |
|
618 | 586 | averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff; |
|
619 | 587 | averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff; |
|
620 | 588 | averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff; |
|
621 | 589 | averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff; |
|
622 | 590 | averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff; |
|
623 | 591 | averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff; |
|
624 | 592 | averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff; |
|
625 | 593 | averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff; |
|
626 | 594 | offset = 10000000; |
|
627 | 595 | averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff; |
|
628 | 596 | averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff; |
|
629 | 597 | averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff; |
|
630 | 598 | averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff; |
|
631 | 599 | averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff; |
|
632 | 600 | averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff; |
|
633 | 601 | averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff; |
|
634 | 602 | averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff; |
|
635 | 603 | averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff; |
|
636 | 604 | averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff; |
|
637 | 605 | averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff; |
|
638 | 606 | averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff; |
|
639 | 607 | averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff; |
|
640 | 608 | averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff; |
|
641 | 609 | averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff; |
|
642 | 610 | |
|
643 | 611 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ]; |
|
644 | 612 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ]; |
|
645 | 613 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ]; |
|
646 | 614 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ]; |
|
647 | 615 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ]; |
|
648 | 616 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ]; |
|
649 | 617 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ]; |
|
650 | 618 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ]; |
|
651 | 619 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ]; |
|
652 | 620 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ]; |
|
653 | 621 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ]; |
|
654 | 622 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ]; |
|
655 | 623 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ]; |
|
656 | 624 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ]; |
|
657 | 625 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ]; |
|
658 | 626 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ]; |
|
659 | 627 | #else |
|
660 | 628 | unsigned int i; |
|
661 | 629 | |
|
662 | 630 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
663 | 631 | { |
|
664 | 632 | if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0) |
|
665 | 633 | averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ]; |
|
666 | 634 | else |
|
667 | 635 | averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ]; |
|
668 | 636 | } |
|
669 | 637 | #endif |
|
670 | 638 | } |
|
671 | 639 | |
|
672 | 640 | void reset_spectral_matrix_regs() |
|
673 | 641 | { |
|
642 | /** This function resets the spectral matrices module registers. | |
|
643 | * | |
|
644 | * The registers affected by this function are located at the following offset addresses: | |
|
645 | * | |
|
646 | * - 0x00 config | |
|
647 | * - 0x04 status | |
|
648 | * - 0x08 matrixF0_Address0 | |
|
649 | * - 0x10 matrixFO_Address1 | |
|
650 | * - 0x14 matrixF1_Address | |
|
651 | * - 0x18 matrixF2_Address | |
|
652 | * | |
|
653 | */ | |
|
654 | ||
|
674 | 655 | #ifdef GSA |
|
675 | 656 | #else |
|
676 | 657 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; |
|
677 | 658 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; |
|
678 | 659 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; |
|
679 | 660 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; |
|
680 | 661 | #endif |
|
681 | 662 | } |
|
682 | 663 | |
|
683 | 664 | //****************** |
|
684 | 665 | // general functions |
|
685 | 666 | |
|
686 | 667 | |
|
687 | 668 | |
|
688 | 669 |
@@ -1,200 +1,207 | |||
|
1 | 1 | #include "fsw_spacewire.h" |
|
2 | 2 | |
|
3 | 3 | char *lstates[6] = {"Error-reset", |
|
4 | 4 | "Error-wait", |
|
5 | 5 | "Ready", |
|
6 | 6 | "Started", |
|
7 | 7 | "Connecting", |
|
8 | 8 | "Run" |
|
9 | 9 | }; |
|
10 | 10 | |
|
11 | 11 | // RTEMS TASK |
|
12 | 12 | rtems_task spiq_task(rtems_task_argument unused) |
|
13 | 13 | { |
|
14 | 14 | rtems_event_set event_out; |
|
15 | 15 | rtems_status_code status; |
|
16 | 16 | unsigned char lfrMode; |
|
17 | 17 | |
|
18 | 18 | while(true){ |
|
19 | 19 | BOOT_PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n") |
|
20 | 20 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
21 | 21 | |
|
22 | 22 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode |
|
23 | 23 | |
|
24 | 24 | status = spacewire_wait_for_link(); |
|
25 | 25 | |
|
26 | 26 | if (status != RTEMS_SUCCESSFUL) |
|
27 | 27 | { |
|
28 | 28 | //**************** |
|
29 | 29 | // STOP THE SYSTEM |
|
30 | 30 | spacewire_compute_stats_offsets(); |
|
31 | 31 | stop_current_mode(); |
|
32 | 32 | if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task |
|
33 | 33 | PRINTF("in SPIQ *** Error suspending RECV Task\n") |
|
34 | 34 | } |
|
35 | 35 | if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task |
|
36 | 36 | PRINTF("in SPIQ *** Error suspending HOUS Task\n") |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | //*************************** |
|
40 | 40 | // RESTART THE SPACEWIRE LINK |
|
41 | 41 | spacewire_configure_link(); |
|
42 | 42 | |
|
43 | 43 | //******************* |
|
44 | 44 | // RESTART THE SYSTEM |
|
45 | 45 | //ioctl(fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS); // clear statistics |
|
46 | 46 | status = rtems_task_restart( Task_id[TASKID_HOUS], 1 ); |
|
47 | 47 | if (status != RTEMS_SUCCESSFUL) { |
|
48 | 48 | PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status) |
|
49 | 49 | } |
|
50 | 50 | status = rtems_task_restart(Task_id[TASKID_RECV], 1); |
|
51 | 51 | if ( status != RTEMS_SUCCESSFUL) { |
|
52 | 52 | PRINTF("in SPIQ *** Error restarting RECV Task\n") |
|
53 | 53 | } |
|
54 | 54 | enter_mode(lfrMode, NULL); // enter the mode that was running before the SpaceWire interruption |
|
55 | 55 | } |
|
56 | 56 | } |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | int spacewire_configure_link( void ) |
|
60 | 60 | { |
|
61 | 61 | rtems_status_code status; |
|
62 | 62 | |
|
63 | 63 | close(fdSPW); // close the device if it is already open |
|
64 | 64 | BOOT_PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n") |
|
65 | 65 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware |
|
66 | 66 | if ( fdSPW<0 ) { |
|
67 | 67 | PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, -1) != RTEMS_SUCCESSFUL){ |
|
71 | 71 | PRINTF(".") |
|
72 | 72 | fflush( stdout ); |
|
73 | 73 | close( fdSPW ); // close the device |
|
74 | 74 | fdSPW = open( GRSPW_DEVICE_NAME, O_RDWR ); // open the device. the open call reset the hardware |
|
75 | 75 | if (fdSPW<0) { |
|
76 | 76 | PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") |
|
77 | 77 | } |
|
78 | 78 | rtems_task_wake_after(100); |
|
79 | 79 | } |
|
80 | 80 | |
|
81 | 81 | BOOT_PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n") |
|
82 | 82 | |
|
83 | 83 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
84 | 84 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
85 | 85 | |
|
86 | 86 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
87 | 87 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
88 | 88 | // |
|
89 | 89 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
90 | 90 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
91 | 91 | // |
|
92 | 92 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
93 | 93 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
94 | 94 | // |
|
95 | 95 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
96 | 96 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
97 | 97 | // |
|
98 | 98 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks |
|
99 | 99 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
100 | 100 | // |
|
101 | 101 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full |
|
102 | 102 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
103 | 103 | // |
|
104 | 104 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
105 | 105 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
106 | 106 | |
|
107 | 107 | BOOT_PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n") |
|
108 | 108 | |
|
109 | 109 | return RTEMS_SUCCESSFUL; |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | int spacewire_wait_for_link(void) |
|
113 | 113 | { |
|
114 | 114 | unsigned int i; |
|
115 | 115 | int linkStatus; |
|
116 | 116 | rtems_status_code status = RTEMS_UNSATISFIED; |
|
117 | 117 | |
|
118 | 118 | for(i = 0; i< 10; i++){ |
|
119 | 119 | PRINTF(".") |
|
120 | 120 | fflush( stdout ); |
|
121 | 121 | ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
122 | 122 | PRINTF1("in spacewire_wait_for_link *** link status is: %s\n", lstates[linkStatus]) |
|
123 | 123 | if ( linkStatus == 5) { |
|
124 | 124 | PRINTF("in spacewire_wait_for_link *** link is running\n") |
|
125 | 125 | status = RTEMS_SUCCESSFUL; |
|
126 | 126 | break; |
|
127 | 127 | } |
|
128 | 128 | rtems_task_wake_after(100); |
|
129 | 129 | } |
|
130 | 130 | |
|
131 | 131 | return status; |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force |
|
135 | 135 | { |
|
136 | 136 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
137 | 137 | |
|
138 | 138 | if (val == 1) { |
|
139 | 139 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
140 | 140 | } |
|
141 | 141 | if (val== 0) { |
|
142 | 142 | *spwptr = *spwptr & 0xffdfffff; |
|
143 | 143 | } |
|
144 | 144 | } |
|
145 | 145 | |
|
146 | 146 | void spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable |
|
147 | 147 | { |
|
148 | 148 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
149 | 149 | |
|
150 | 150 | if (val == 1) |
|
151 | 151 | { |
|
152 | 152 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
153 | 153 | } |
|
154 | 154 | if (val== 0) |
|
155 | 155 | { |
|
156 | 156 | *spwptr = *spwptr & 0xfffdffff; |
|
157 | 157 | } |
|
158 | 158 | } |
|
159 | 159 | |
|
160 | void spacewire_compute_stats_offsets() | |
|
160 | void spacewire_compute_stats_offsets( void ) | |
|
161 | 161 | { |
|
162 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
|
163 | * | |
|
164 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
|
165 | * to keep the counters consistent even after a reset of the SpaceWire driver. | |
|
166 | * | |
|
167 | */ | |
|
168 | ||
|
162 | 169 | spw_stats spacewire_stats_grspw; |
|
163 | 170 | rtems_status_code status; |
|
164 | 171 | |
|
165 | 172 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
166 | 173 | |
|
167 | 174 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
168 | 175 | + spacewire_stats.packets_received; |
|
169 | 176 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
170 | 177 | + spacewire_stats.packets_sent; |
|
171 | 178 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
172 | 179 | + spacewire_stats.parity_err; |
|
173 | 180 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
174 | 181 | + spacewire_stats.disconnect_err; |
|
175 | 182 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
176 | 183 | + spacewire_stats.escape_err; |
|
177 | 184 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
178 | 185 | + spacewire_stats.credit_err; |
|
179 | 186 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
180 | 187 | + spacewire_stats.write_sync_err; |
|
181 | 188 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
182 | 189 | + spacewire_stats.rx_rmap_header_crc_err; |
|
183 | 190 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
184 | 191 | + spacewire_stats.rx_rmap_data_crc_err; |
|
185 | 192 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
186 | 193 | + spacewire_stats.early_ep; |
|
187 | 194 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
188 | 195 | + spacewire_stats.invalid_address; |
|
189 | 196 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
190 | 197 | + spacewire_stats.rx_eep_err; |
|
191 | 198 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
192 | 199 | + spacewire_stats.rx_truncated; |
|
193 | 200 | } |
|
194 | 201 | |
|
195 | 202 | void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc) |
|
196 | 203 | { |
|
197 | 204 | //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) { |
|
198 | 205 | // printf("In timecode_irq_handler *** Error sending event to DUMB\n"); |
|
199 | 206 | //} |
|
200 | 207 | } |
This diff has been collapsed as it changes many lines, (1090 lines changed) Show them Hide them | |||
@@ -1,1476 +1,1284 | |||
|
1 | #include <tc_handler.h> | |
|
2 | #include <fsw_params.h> | |
|
1 | /** Functions and tasks related to TeleCommand handling. | |
|
2 | * | |
|
3 | * @file | |
|
4 | * @author P. LEROY | |
|
5 | * | |
|
6 | * A group of functions to handle TeleCommands:\n | |
|
7 | * action launching\n | |
|
8 | * TC parsing\n | |
|
9 | * ... | |
|
10 | * | |
|
11 | */ | |
|
12 | ||
|
13 | #include "tc_handler.h" | |
|
3 | 14 | |
|
4 | 15 | char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
5 | 16 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
6 | 17 | "in DUMB *** waveforms_isr", // RTEMS_EVENT_2 |
|
7 | 18 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
8 | 19 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
9 | 20 | "in DUMB *** waveforms_simulator_isr" // RTEMS_EVENT_5 |
|
10 | 21 | }; |
|
11 | 22 | |
|
12 | 23 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field |
|
13 | unsigned char currentTC_COMPUTED_CRC[2]; | |
|
14 | 24 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; |
|
15 | 25 | unsigned int currentTM_length; |
|
16 | 26 | unsigned char currentTC_processedFlag; |
|
17 | 27 | |
|
18 | 28 | unsigned int lookUpTableForCRC[256]; |
|
19 | 29 | |
|
20 | 30 | //********************** |
|
21 | 31 | // GENERAL USE FUNCTIONS |
|
22 | 32 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) |
|
23 | 33 | { |
|
34 | /** This function generate the CRC for one byte and returns the value of the new syndrome. | |
|
35 | * | |
|
36 | * @param D is the current byte of data. | |
|
37 | * @param Chk is the current syndrom value. | |
|
38 | * @return the value of the new syndrome on two bytes. | |
|
39 | * | |
|
40 | */ | |
|
41 | ||
|
24 | 42 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
25 | 43 | } |
|
26 | 44 | |
|
27 | 45 | void initLookUpTableForCRC( void ) |
|
28 | 46 | { |
|
47 | /** This function is used to initiates the look-up table for fast CRC computation. | |
|
48 | * | |
|
49 | * The global table lookUpTableForCRC[256] is initiated. | |
|
50 | * | |
|
51 | */ | |
|
52 | ||
|
29 | 53 | unsigned int i; |
|
30 | 54 | unsigned int tmp; |
|
31 | 55 | |
|
32 | 56 | for (i=0; i<256; i++) |
|
33 | 57 | { |
|
34 | 58 | tmp = 0; |
|
35 | 59 | if((i & 1) != 0) { |
|
36 | 60 | tmp = tmp ^ 0x1021; |
|
37 | 61 | } |
|
38 | 62 | if((i & 2) != 0) { |
|
39 | 63 | tmp = tmp ^ 0x2042; |
|
40 | 64 | } |
|
41 | 65 | if((i & 4) != 0) { |
|
42 | 66 | tmp = tmp ^ 0x4084; |
|
43 | 67 | } |
|
44 | 68 | if((i & 8) != 0) { |
|
45 | 69 | tmp = tmp ^ 0x8108; |
|
46 | 70 | } |
|
47 | 71 | if((i & 16) != 0) { |
|
48 | 72 | tmp = tmp ^ 0x1231; |
|
49 | 73 | } |
|
50 | 74 | if((i & 32) != 0) { |
|
51 | 75 | tmp = tmp ^ 0x2462; |
|
52 | 76 | } |
|
53 | 77 | if((i & 64) != 0) { |
|
54 | 78 | tmp = tmp ^ 0x48c4; |
|
55 | 79 | } |
|
56 | 80 | if((i & 128) != 0) { |
|
57 | 81 | tmp = tmp ^ 0x9188; |
|
58 | 82 | } |
|
59 | 83 | lookUpTableForCRC[i] = tmp; |
|
60 | 84 | } |
|
61 | 85 | } |
|
62 | 86 | |
|
63 | 87 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) |
|
64 | 88 | { |
|
89 | /** This function calculates a two bytes Cyclic Redundancy Code. | |
|
90 | * | |
|
91 | * @param data points to a buffer containing the data on which to compute the CRC. | |
|
92 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. | |
|
93 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. | |
|
94 | * | |
|
95 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. | |
|
96 | * | |
|
97 | */ | |
|
98 | ||
|
65 | 99 | unsigned int Chk; |
|
66 | 100 | int j; |
|
67 | 101 | Chk = 0xffff; // reset the syndrom to all ones |
|
68 | 102 | for (j=0; j<sizeOfData; j++) { |
|
69 | 103 | Chk = Crc_opt(data[j], Chk); |
|
70 | 104 | } |
|
71 | 105 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); |
|
72 | 106 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); |
|
73 | 107 | } |
|
74 | 108 | |
|
75 | 109 | void updateLFRCurrentMode() |
|
76 | 110 | { |
|
111 | /** This function updates the value of the global variable lfrCurrentMode. | |
|
112 | * | |
|
113 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
|
114 | * | |
|
115 | */ | |
|
116 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
|
77 | 117 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
78 | 118 | } |
|
79 | 119 | |
|
80 | 120 | //********************* |
|
81 | 121 | // ACCEPTANCE FUNCTIONS |
|
82 |
int |
|
|
122 | int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_queu_id, rtems_id queue_pkts_id) | |
|
83 | 123 | { |
|
124 | /** This function executes the TeleCommand acceptance steps. | |
|
125 | * | |
|
126 | * @param TC points to the TeleCommand packet which is under investigation. | |
|
127 | * @param tc_len_recv contains the length of the packet that has been received. | |
|
128 | * @param queue_queu_id is the id of the rtems queue in which messages are written if the acceptance is not successful | |
|
129 | * @param queue_pkts_id is the id of the rtems queue in which messages are written if the acceptance is successful | |
|
130 | * @return status code | |
|
131 | * | |
|
132 | * The acceptance steps can result in two different actions. | |
|
133 | * 1. If the acceptance is successful, the TC is sent in the receiving queue for processing. | |
|
134 | * 2. If the acceptance fails, a TM packet is transmitted to report the error. | |
|
135 | * | |
|
136 | */ | |
|
137 | ||
|
84 | 138 | int ret = 0; |
|
85 | 139 | rtems_status_code status; |
|
86 | Packet_TM_LFR_TC_EXE_CORRUPTED_t packet; | |
|
87 | 140 | unsigned int parserCode = 0; |
|
88 | 141 | unsigned char computed_CRC[2]; |
|
89 | unsigned int packetLength; | |
|
90 | unsigned char *packetDataField; | |
|
91 | 142 | |
|
92 | 143 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 ); |
|
93 |
parserCode = |
|
|
144 | parserCode = tc_parser( TC, tc_len_recv ) ; | |
|
94 | 145 | if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM) |
|
95 | 146 | | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) ) |
|
96 |
{ // |
|
|
97 | packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field | |
|
98 | packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length | |
|
99 | // | |
|
100 | packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
|
101 | packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
|
102 | packet.reserved = DEFAULT_RESERVED; | |
|
103 | packet.userApplication = CCSDS_USER_APP; | |
|
104 | // PACKET HEADER | |
|
105 | packet.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); | |
|
106 | packet.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); | |
|
107 | packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
|
108 | packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
|
109 | packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8); | |
|
110 | packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED ); | |
|
111 | // DATA FIELD HEADER | |
|
112 | packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
|
113 | packet.serviceType = TM_TYPE_TC_EXE; | |
|
114 | packet.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
|
115 | packet.destinationID = TM_DESTINATION_ID_GROUND; | |
|
116 | packet.time[0] = (time_management_regs->coarse_time>>24 ); | |
|
117 | packet.time[1] = (time_management_regs->coarse_time>>16 ); | |
|
118 | packet.time[2] = (time_management_regs->coarse_time>>8 ); | |
|
119 | packet.time[3] = (time_management_regs->coarse_time ); | |
|
120 | packet.time[4] = (time_management_regs->fine_time>>8 ); | |
|
121 | packet.time[5] = (time_management_regs->fine_time ); | |
|
122 | // | |
|
123 | packet.tc_failure_code[0] = (unsigned char) (FAILURE_CODE_CORRUPTED >> 8); | |
|
124 | packet.tc_failure_code[1] = (unsigned char) (FAILURE_CODE_CORRUPTED ); | |
|
125 | packet.telecommand_pkt_id[0] = TC->packetID[0]; | |
|
126 | packet.telecommand_pkt_id[1] = TC->packetID[1]; | |
|
127 | packet.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
|
128 | packet.pkt_seq_control[0] = TC->packetSequenceControl[1]; | |
|
129 | packet.tc_service = TC->serviceType; | |
|
130 | packet.tc_subtype = TC->serviceSubType; | |
|
131 | packet.pkt_len_rcv_value[0] = TC->packetLength[0]; | |
|
132 | packet.pkt_len_rcv_value[1] = TC->packetLength[1]; | |
|
133 | packet.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0]; | |
|
134 | packet.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1]; | |
|
135 | packet.rcv_crc[0] = packetDataField[ packetLength - 1 ]; | |
|
136 | packet.rcv_crc[1] = packetDataField[ packetLength ]; | |
|
137 | packet.computed_crc[0] = computed_CRC[0]; | |
|
138 | packet.computed_crc[1] = computed_CRC[1]; | |
|
139 | // SEND DATA | |
|
140 | status = rtems_message_queue_urgent( queue_pkts_id, &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4); | |
|
141 | if (status != RTEMS_SUCCESSFUL) { | |
|
142 | PRINTF("in TC_acceptance *** ERR rtems_message_queue_urgent\n") | |
|
143 | ret = LFR_DEFAULT; | |
|
144 | } | |
|
147 | { // send TM_LFR_TC_EXE_CORRUPTED | |
|
148 | send_tm_lfr_tc_exe_corrupted( TC, queue_queu_id, computed_CRC, currentTC_LEN_RCV ); | |
|
145 | 149 | } |
|
146 | 150 | else { // send valid TC to the action launcher |
|
147 | 151 | status = rtems_message_queue_send( queue_queu_id, TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
148 | 152 | ret = LFR_SUCCESSFUL; |
|
149 | 153 | } |
|
150 | 154 | return ret; |
|
151 | 155 | } |
|
152 | 156 | |
|
153 |
|
|
|
157 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV) | |
|
154 | 158 | { |
|
155 | unsigned char ret = 0; | |
|
156 | unsigned char pid = 0; | |
|
157 | unsigned char category = 0; | |
|
158 | unsigned int length = 0; | |
|
159 | unsigned char packetType = 0; | |
|
160 | unsigned char packetSubtype = 0; | |
|
161 | unsigned char * CCSDSContent = NULL; | |
|
159 | /** This function parses TeleCommands. | |
|
160 | * | |
|
161 | * @param TC points to the TeleCommand that will be parsed. | |
|
162 | * @param TC_LEN_RCV is the received packet length. | |
|
163 | * @return Status code of the parsing. | |
|
164 | * | |
|
165 | * The parsing checks: | |
|
166 | * - process id | |
|
167 | * - category | |
|
168 | * - length: a global check is performed and a per subtype check also | |
|
169 | * - type | |
|
170 | * - subtype | |
|
171 | * - crc | |
|
172 | * | |
|
173 | */ | |
|
174 | ||
|
175 | int status; | |
|
176 | unsigned char pid; | |
|
177 | unsigned char category; | |
|
178 | unsigned int length; | |
|
179 | unsigned char packetType; | |
|
180 | unsigned char packetSubtype; | |
|
181 | ||
|
182 | status = CCSDS_TM_VALID; | |
|
162 | 183 | |
|
163 | 184 | // APID check *** APID on 2 bytes |
|
164 | 185 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx |
|
165 | 186 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 |
|
166 | 187 | length = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; |
|
167 | 188 | packetType = TCPacket->serviceType; |
|
168 | 189 | packetSubtype = TCPacket->serviceSubType; |
|
169 | 190 | |
|
170 |
if ( pid != CCSDS_PROCESS_ID ) |
|
|
171 | ret = ILLEGAL_APID; | |
|
172 | } | |
|
173 | else if ( category != CCSDS_PACKET_CATEGORY ) { | |
|
174 | ret = ILLEGAL_APID; | |
|
191 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID | |
|
192 | { | |
|
193 | status = ILLEGAL_APID; | |
|
175 | 194 | } |
|
176 | else if (length != TC_LEN_RCV ) { // packet length check | |
|
177 | ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD | |
|
178 | } | |
|
179 | else if ( length >= CCSDS_TC_PKT_MAX_SIZE ) { | |
|
180 | ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size | |
|
195 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY | |
|
196 | { | |
|
197 | if ( category != CCSDS_PACKET_CATEGORY ) | |
|
198 | { | |
|
199 | status = ILLEGAL_APID; | |
|
200 | } | |
|
181 | 201 | } |
|
182 | else if ( packetType == TC_TYPE_GEN ){ // service type, subtype and packet length check | |
|
183 | switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61 | |
|
184 | case TC_SUBTYPE_RESET: | |
|
185 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
186 | ret = WRONG_LEN_PACKET; | |
|
187 | } | |
|
188 | else { | |
|
189 | ret = CCSDS_TM_VALID; | |
|
190 | } | |
|
191 | break; | |
|
192 | case TC_SUBTYPE_LOAD_COMM: | |
|
193 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
194 | ret = WRONG_LEN_PACKET; | |
|
195 | } | |
|
196 | else { | |
|
197 | ret = CCSDS_TM_VALID; | |
|
198 | } | |
|
199 | break; | |
|
200 | case TC_SUBTYPE_LOAD_NORM: | |
|
201 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
202 | ret = WRONG_LEN_PACKET; | |
|
203 | } | |
|
204 | else { | |
|
205 | ret = CCSDS_TM_VALID; | |
|
206 | } | |
|
207 | break; | |
|
208 | case TC_SUBTYPE_LOAD_BURST: | |
|
209 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
210 | ret = WRONG_LEN_PACKET; | |
|
211 | } | |
|
212 | else { | |
|
213 | ret = CCSDS_TM_VALID; | |
|
214 | } | |
|
215 | break; | |
|
216 | case TC_SUBTYPE_LOAD_SBM1: | |
|
217 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
218 | ret = WRONG_LEN_PACKET; | |
|
219 | } | |
|
220 | else { | |
|
221 | ret = CCSDS_TM_VALID; | |
|
222 | } | |
|
223 | break; | |
|
224 | case TC_SUBTYPE_LOAD_SBM2: | |
|
225 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
226 | ret = WRONG_LEN_PACKET; | |
|
227 | } | |
|
228 | else { | |
|
229 | ret = CCSDS_TM_VALID; | |
|
230 | } | |
|
231 | break; | |
|
232 | case TC_SUBTYPE_DUMP: | |
|
233 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
234 | ret = WRONG_LEN_PACKET; | |
|
235 | } | |
|
236 | else { | |
|
237 | ret = CCSDS_TM_VALID; | |
|
238 | } | |
|
239 | break; | |
|
240 | case TC_SUBTYPE_ENTER: | |
|
241 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
242 | ret = WRONG_LEN_PACKET; | |
|
243 | } | |
|
244 | else { | |
|
245 | ret = CCSDS_TM_VALID; | |
|
246 | } | |
|
247 | break; | |
|
248 | case TC_SUBTYPE_UPDT_INFO: | |
|
249 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
250 | ret = WRONG_LEN_PACKET; | |
|
251 | } | |
|
252 | else { | |
|
253 | ret = CCSDS_TM_VALID; | |
|
254 | } | |
|
255 | break; | |
|
256 | case TC_SUBTYPE_EN_CAL: | |
|
257 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
258 | ret = WRONG_LEN_PACKET; | |
|
259 | } | |
|
260 | else { | |
|
261 | ret = CCSDS_TM_VALID; | |
|
262 | } | |
|
263 | break; | |
|
264 | case TC_SUBTYPE_DIS_CAL: | |
|
265 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
266 | ret = WRONG_LEN_PACKET; | |
|
267 | } | |
|
268 | else { | |
|
269 | ret = CCSDS_TM_VALID; | |
|
270 | } | |
|
271 | break; | |
|
272 | default: | |
|
273 | ret = ILL_SUBTYPE; | |
|
274 | break; | |
|
202 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE | |
|
203 | { | |
|
204 | if (length != TC_LEN_RCV ) { | |
|
205 | status = WRONG_LEN_PACKET; | |
|
206 | } | |
|
207 | } | |
|
208 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE | |
|
209 | { | |
|
210 | if ( length >= CCSDS_TC_PKT_MAX_SIZE ) { | |
|
211 | status = WRONG_LEN_PACKET; | |
|
275 | 212 | } |
|
276 | 213 | } |
|
277 | else if ( packetType == TC_TYPE_TIME ){ | |
|
278 | if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) { | |
|
279 | ret = ILL_SUBTYPE; | |
|
280 |
|
|
|
281 | else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
282 | ret = WRONG_LEN_PACKET; | |
|
283 | } | |
|
284 | else { | |
|
285 | ret = CCSDS_TM_VALID; | |
|
286 | } | |
|
214 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE | |
|
215 | { | |
|
216 | status = tc_check_type( packetType ); | |
|
217 | } | |
|
218 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE | |
|
219 | { | |
|
220 | status = tc_check_subtype( packetSubtype ); | |
|
221 | } | |
|
222 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE | |
|
223 | { | |
|
224 | status = tc_check_length( packetSubtype, length ); | |
|
225 | } | |
|
226 | if (status == CCSDS_TM_VALID ) // CHECK CRC | |
|
227 | { | |
|
228 | status = tc_check_crc( TCPacket, length ); | |
|
287 | 229 | } |
|
288 | else { | |
|
289 | ret = ILL_TYPE; | |
|
230 | ||
|
231 | return status; | |
|
232 | } | |
|
233 | ||
|
234 | int tc_check_type( unsigned char packetType ) | |
|
235 | { | |
|
236 | /** This function checks that the type of a TeleCommand is valid. | |
|
237 | * | |
|
238 | * @param packetType is the type to check. | |
|
239 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. | |
|
240 | * | |
|
241 | */ | |
|
242 | ||
|
243 | int status; | |
|
244 | ||
|
245 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) | |
|
246 | { | |
|
247 | status = CCSDS_TM_VALID; | |
|
248 | } | |
|
249 | else | |
|
250 | { | |
|
251 | status = ILL_TYPE; | |
|
252 | } | |
|
253 | ||
|
254 | return status; | |
|
255 | } | |
|
256 | ||
|
257 | int tc_check_subtype( unsigned char packetSubType ) | |
|
258 | { | |
|
259 | /** This function checks that the subtype of a TeleCommand is valid. | |
|
260 | * | |
|
261 | * @param packetSubType is the subtype to check. | |
|
262 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. | |
|
263 | * | |
|
264 | */ | |
|
265 | ||
|
266 | int status; | |
|
267 | ||
|
268 | if ( (packetSubType == TC_SUBTYPE_RESET) | |
|
269 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) | |
|
270 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) | |
|
271 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) | |
|
272 | || (packetSubType == TC_SUBTYPE_DUMP) | |
|
273 | || (packetSubType == TC_SUBTYPE_ENTER) | |
|
274 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) || (packetSubType == TC_SUBTYPE_UPDT_TIME) | |
|
275 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) ) | |
|
276 | { | |
|
277 | status = CCSDS_TM_VALID; | |
|
278 | } | |
|
279 | else | |
|
280 | { | |
|
281 | status = ILL_TYPE; | |
|
290 | 282 | } |
|
291 | 283 | |
|
292 | // source ID check // Source ID not documented in the ICD | |
|
284 | return status; | |
|
285 | } | |
|
286 | ||
|
287 | int tc_check_length( unsigned char packetSubType, unsigned int length ) | |
|
288 | { | |
|
289 | /** This function checks that the subtype and the length are compliant. | |
|
290 | * | |
|
291 | * @param packetSubType is the subtype to check. | |
|
292 | * @param length is the length to check. | |
|
293 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. | |
|
294 | * | |
|
295 | */ | |
|
296 | ||
|
297 | int status; | |
|
298 | ||
|
299 | status = LFR_SUCCESSFUL; | |
|
293 | 300 | |
|
294 | // packet error control, CRC check | |
|
295 | if ( ret == CCSDS_TM_VALID ) { | |
|
296 | CCSDSContent = (unsigned char*) TCPacket->packetID; | |
|
297 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | |
|
298 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { | |
|
299 | ret = INCOR_CHECKSUM; | |
|
301 | switch(packetSubType) | |
|
302 | { | |
|
303 | case TC_SUBTYPE_RESET: | |
|
304 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
305 | status = WRONG_LEN_PACKET; | |
|
306 | } | |
|
307 | else { | |
|
308 | status = CCSDS_TM_VALID; | |
|
309 | } | |
|
310 | break; | |
|
311 | case TC_SUBTYPE_LOAD_COMM: | |
|
312 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
313 | status = WRONG_LEN_PACKET; | |
|
314 | } | |
|
315 | else { | |
|
316 | status = CCSDS_TM_VALID; | |
|
317 | } | |
|
318 | break; | |
|
319 | case TC_SUBTYPE_LOAD_NORM: | |
|
320 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
321 | status = WRONG_LEN_PACKET; | |
|
322 | } | |
|
323 | else { | |
|
324 | status = CCSDS_TM_VALID; | |
|
300 | 325 | } |
|
301 | else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { | |
|
302 | ret = INCOR_CHECKSUM; | |
|
326 | break; | |
|
327 | case TC_SUBTYPE_LOAD_BURST: | |
|
328 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
329 | status = WRONG_LEN_PACKET; | |
|
330 | } | |
|
331 | else { | |
|
332 | status = CCSDS_TM_VALID; | |
|
333 | } | |
|
334 | break; | |
|
335 | case TC_SUBTYPE_LOAD_SBM1: | |
|
336 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
337 | status = WRONG_LEN_PACKET; | |
|
338 | } | |
|
339 | else { | |
|
340 | status = CCSDS_TM_VALID; | |
|
341 | } | |
|
342 | break; | |
|
343 | case TC_SUBTYPE_LOAD_SBM2: | |
|
344 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
345 | status = WRONG_LEN_PACKET; | |
|
346 | } | |
|
347 | else { | |
|
348 | status = CCSDS_TM_VALID; | |
|
349 | } | |
|
350 | break; | |
|
351 | case TC_SUBTYPE_DUMP: | |
|
352 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
353 | status = WRONG_LEN_PACKET; | |
|
303 | 354 | } |
|
304 | 355 | else { |
|
305 |
|
|
|
356 | status = CCSDS_TM_VALID; | |
|
357 | } | |
|
358 | break; | |
|
359 | case TC_SUBTYPE_ENTER: | |
|
360 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
361 | status = WRONG_LEN_PACKET; | |
|
362 | } | |
|
363 | else { | |
|
364 | status = CCSDS_TM_VALID; | |
|
365 | } | |
|
366 | break; | |
|
367 | case TC_SUBTYPE_UPDT_INFO: | |
|
368 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
369 | status = WRONG_LEN_PACKET; | |
|
370 | } | |
|
371 | else { | |
|
372 | status = CCSDS_TM_VALID; | |
|
373 | } | |
|
374 | break; | |
|
375 | case TC_SUBTYPE_EN_CAL: | |
|
376 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
377 | status = WRONG_LEN_PACKET; | |
|
306 | 378 | } |
|
379 | else { | |
|
380 | status = CCSDS_TM_VALID; | |
|
381 | } | |
|
382 | break; | |
|
383 | case TC_SUBTYPE_DIS_CAL: | |
|
384 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
385 | status = WRONG_LEN_PACKET; | |
|
386 | } | |
|
387 | else { | |
|
388 | status = CCSDS_TM_VALID; | |
|
389 | } | |
|
390 | break; | |
|
391 | case TC_SUBTYPE_UPDT_TIME: | |
|
392 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { | |
|
393 | status = WRONG_LEN_PACKET; | |
|
394 | } | |
|
395 | else { | |
|
396 | status = CCSDS_TM_VALID; | |
|
397 | } | |
|
398 | break; | |
|
399 | default: // if the subtype is not a legal value, return ILL_SUBTYPE | |
|
400 | status = ILL_SUBTYPE; | |
|
401 | break ; | |
|
307 | 402 | } |
|
308 | 403 | |
|
309 |
return |
|
|
404 | return status; | |
|
405 | } | |
|
406 | ||
|
407 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length ) | |
|
408 | { | |
|
409 | /** This function checks the CRC validity of the corresponding TeleCommand packet. | |
|
410 | * | |
|
411 | * @param TCPacket points to the TeleCommand packet to check. | |
|
412 | * @param length is the length of the TC packet. | |
|
413 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. | |
|
414 | * | |
|
415 | */ | |
|
416 | ||
|
417 | int status; | |
|
418 | unsigned char * CCSDSContent; | |
|
419 | unsigned char currentTC_COMPUTED_CRC[2]; | |
|
420 | ||
|
421 | CCSDSContent = (unsigned char*) TCPacket->packetID; | |
|
422 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | |
|
423 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { | |
|
424 | status = INCOR_CHECKSUM; | |
|
425 | } | |
|
426 | else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { | |
|
427 | status = INCOR_CHECKSUM; | |
|
428 | } | |
|
429 | else { | |
|
430 | status = CCSDS_TM_VALID; | |
|
431 | } | |
|
432 | ||
|
433 | return status; | |
|
310 | 434 | } |
|
311 | 435 | |
|
312 | 436 | //*********** |
|
313 | 437 | // RTEMS TASK |
|
314 | 438 | rtems_task recv_task( rtems_task_argument unused ) |
|
315 | 439 | { |
|
440 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
|
441 | * | |
|
442 | * @param unused is the starting argument of the RTEMS task | |
|
443 | * | |
|
444 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
|
445 | * 1. It reads the incoming data. | |
|
446 | * 2. Launches the acceptance procedure. | |
|
447 | * 3. If the Telecommand is valid, sends it to the ACTN task using an RTEMS message queue. | |
|
448 | * | |
|
449 | */ | |
|
450 | ||
|
316 | 451 | int len = 0; |
|
317 | 452 | unsigned int i = 0; |
|
318 | 453 | ccsdsTelecommandPacket_t currentTC; |
|
319 | 454 | char data[100]; |
|
320 | 455 | rtems_status_code status; |
|
321 | 456 | rtems_id queue_queu_id; |
|
322 | 457 | rtems_id queue_pkts_id; |
|
323 | 458 | |
|
324 | 459 | for(i=0; i<100; i++) data[i] = 0; |
|
325 | 460 | |
|
461 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
|
462 | ||
|
326 | 463 | status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_queu_id ); |
|
327 | 464 | if (status != RTEMS_SUCCESSFUL) |
|
328 | 465 | { |
|
329 | 466 | PRINTF1("in RECV *** ERR getting queue_queu id, %d\n", status) |
|
330 | 467 | } |
|
331 | 468 | |
|
332 | 469 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_pkts_id ); |
|
333 | 470 | if (status != RTEMS_SUCCESSFUL) |
|
334 | 471 | { |
|
335 | 472 | PRINTF1("in RECV *** ERR getting queue_pkts id, %d\n", status) |
|
336 | 473 | } |
|
337 | 474 | |
|
338 | 475 | BOOT_PRINTF("in RECV *** \n") |
|
339 | 476 | |
|
340 | 477 | while(1) |
|
341 | 478 | { |
|
342 | 479 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking |
|
343 | 480 | if (len == -1){ // error during the read call |
|
344 | 481 | PRINTF("In RECV *** last read call returned -1\n") |
|
345 | 482 | } |
|
346 | 483 | else { |
|
347 | 484 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
348 | 485 | PRINTF("In RECV *** packet lenght too short\n") |
|
349 | 486 | } |
|
350 | 487 | else { |
|
351 | 488 | currentTC_LEN_RCV[0] = 0x00; |
|
352 | 489 | currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field |
|
353 | 490 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
354 | 491 | // CHECK THE TC |
|
355 |
|
|
|
492 | tc_acceptance(¤tTC, currentTC_LEN_RCV_AsUnsignedInt, queue_queu_id, queue_pkts_id); | |
|
356 | 493 | } |
|
357 | 494 | } |
|
358 | 495 | } |
|
359 | 496 | } |
|
360 | 497 | |
|
361 | 498 | rtems_task actn_task( rtems_task_argument unused ) |
|
362 | 499 | { |
|
500 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
|
501 | * | |
|
502 | * @param unused is the starting argument of the RTEMS task | |
|
503 | * | |
|
504 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
|
505 | * on the incoming TeleCommand. | |
|
506 | * | |
|
507 | */ | |
|
508 | ||
|
363 | 509 | int result; |
|
364 | 510 | rtems_status_code status; // RTEMS status code |
|
365 | 511 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
366 | 512 | size_t size; // size of the incoming TC packet |
|
367 | 513 | unsigned char subtype; // subtype of the current TC packet |
|
368 | 514 | rtems_id queue_rcv_id; |
|
369 | 515 | rtems_id queue_snd_id; |
|
370 | 516 | |
|
371 | 517 | status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_rcv_id ); |
|
372 | 518 | if (status != RTEMS_SUCCESSFUL) |
|
373 | 519 | { |
|
374 | 520 | PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status) |
|
375 | 521 | } |
|
376 | 522 | |
|
377 | 523 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_snd_id ); |
|
378 | 524 | if (status != RTEMS_SUCCESSFUL) |
|
379 | 525 | { |
|
380 | 526 | PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status) |
|
381 | 527 | } |
|
382 | 528 | |
|
383 | 529 | result = LFR_SUCCESSFUL; |
|
384 | 530 | subtype = 0; // subtype of the current TC packet |
|
385 | 531 | |
|
386 | 532 | BOOT_PRINTF("in ACTN *** \n") |
|
387 | 533 | |
|
388 | 534 | while(1) |
|
389 | 535 | { |
|
390 | 536 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
391 | 537 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
392 | 538 | if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
393 | 539 | else |
|
394 | 540 | { |
|
395 | 541 | subtype = TC.serviceSubType; |
|
396 | 542 | switch(subtype) |
|
397 | 543 | { |
|
398 | 544 | case TC_SUBTYPE_RESET: |
|
399 | 545 | result = action_reset( &TC, queue_snd_id ); |
|
400 | 546 | close_action( &TC, result, queue_snd_id ); |
|
401 | 547 | break; |
|
402 | 548 | // |
|
403 | 549 | case TC_SUBTYPE_LOAD_COMM: |
|
404 | 550 | result = action_load_common_par( &TC ); |
|
405 | 551 | close_action( &TC, result, queue_snd_id ); |
|
406 | 552 | break; |
|
407 | 553 | // |
|
408 | 554 | case TC_SUBTYPE_LOAD_NORM: |
|
409 | 555 | result = action_load_normal_par( &TC, queue_snd_id ); |
|
410 | 556 | close_action( &TC, result, queue_snd_id ); |
|
411 | 557 | break; |
|
412 | 558 | // |
|
413 | 559 | case TC_SUBTYPE_LOAD_BURST: |
|
414 | 560 | result = action_load_burst_par( &TC, queue_snd_id ); |
|
415 | 561 | close_action( &TC, result, queue_snd_id ); |
|
416 | 562 | break; |
|
417 | 563 | // |
|
418 | 564 | case TC_SUBTYPE_LOAD_SBM1: |
|
419 | 565 | result = action_load_sbm1_par( &TC, queue_snd_id ); |
|
420 | 566 | close_action( &TC, result, queue_snd_id ); |
|
421 | 567 | break; |
|
422 | 568 | // |
|
423 | 569 | case TC_SUBTYPE_LOAD_SBM2: |
|
424 | 570 | result = action_load_sbm2_par( &TC, queue_snd_id ); |
|
425 | 571 | close_action( &TC, result, queue_snd_id ); |
|
426 | 572 | break; |
|
427 | 573 | // |
|
428 | 574 | case TC_SUBTYPE_DUMP: |
|
429 |
result = action_dump_par( |
|
|
575 | result = action_dump_par( queue_snd_id ); | |
|
430 | 576 | close_action( &TC, result, queue_snd_id ); |
|
431 | 577 | break; |
|
432 | 578 | // |
|
433 | 579 | case TC_SUBTYPE_ENTER: |
|
434 | 580 | result = action_enter_mode( &TC, queue_snd_id ); |
|
435 | 581 | close_action( &TC, result, queue_snd_id ); |
|
436 | 582 | break; |
|
437 | 583 | // |
|
438 | 584 | case TC_SUBTYPE_UPDT_INFO: |
|
439 | 585 | result = action_update_info( &TC, queue_snd_id ); |
|
440 | 586 | close_action( &TC, result, queue_snd_id ); |
|
441 | 587 | break; |
|
442 | 588 | // |
|
443 | 589 | case TC_SUBTYPE_EN_CAL: |
|
444 | 590 | result = action_enable_calibration( &TC, queue_snd_id ); |
|
445 | 591 | close_action( &TC, result, queue_snd_id ); |
|
446 | 592 | break; |
|
447 | 593 | // |
|
448 | 594 | case TC_SUBTYPE_DIS_CAL: |
|
449 | 595 | result = action_disable_calibration( &TC, queue_snd_id ); |
|
450 | 596 | close_action( &TC, result, queue_snd_id ); |
|
451 | 597 | break; |
|
452 | 598 | // |
|
453 | 599 | case TC_SUBTYPE_UPDT_TIME: |
|
454 | 600 | result = action_update_time( &TC ); |
|
455 | 601 | close_action( &TC, result, queue_snd_id ); |
|
456 | 602 | break; |
|
457 | 603 | // |
|
458 | 604 | default: |
|
459 | 605 | break; |
|
460 | 606 | } |
|
461 | 607 | } |
|
462 | 608 | } |
|
463 | 609 | } |
|
464 | 610 | |
|
465 | 611 | rtems_task dumb_task( rtems_task_argument unused ) |
|
466 | 612 | { |
|
613 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
|
614 | * | |
|
615 | * @param unused is the starting argument of the RTEMS task | |
|
616 | * | |
|
617 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
|
618 | * | |
|
619 | */ | |
|
620 | ||
|
467 | 621 | unsigned int i; |
|
468 | 622 | unsigned int intEventOut; |
|
469 | 623 | unsigned int coarse_time = 0; |
|
470 | 624 | unsigned int fine_time = 0; |
|
471 | 625 | rtems_event_set event_out; |
|
472 | 626 | |
|
473 | 627 | BOOT_PRINTF("in DUMB *** \n") |
|
474 | 628 | |
|
475 | 629 | while(1){ |
|
476 | 630 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5, |
|
477 | 631 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
478 | 632 | intEventOut = (unsigned int) event_out; |
|
479 | 633 | for ( i=0; i<32; i++) |
|
480 | 634 | { |
|
481 | 635 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
482 | 636 | { |
|
483 | 637 | coarse_time = time_management_regs->coarse_time; |
|
484 | 638 | fine_time = time_management_regs->fine_time; |
|
485 | 639 | printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); |
|
486 | 640 | } |
|
487 | 641 | } |
|
488 | 642 | } |
|
489 | 643 | } |
|
490 | 644 | |
|
491 | 645 | //*********** |
|
492 | 646 | // TC ACTIONS |
|
493 | 647 | |
|
494 | 648 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
495 | 649 | { |
|
650 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
|
651 | * | |
|
652 | * @param TC points to the TeleCommand packet that is being processed | |
|
653 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
654 | * | |
|
655 | */ | |
|
656 | ||
|
496 | 657 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
497 | 658 | return LFR_DEFAULT; |
|
498 | 659 | } |
|
499 | 660 | |
|
500 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
|
501 | { | |
|
502 | parameter_dump_packet.unused0 = TC->dataAndCRC[0]; | |
|
503 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1]; | |
|
504 | ||
|
505 | set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1); | |
|
506 | ||
|
507 | return LFR_SUCCESSFUL; | |
|
508 | } | |
|
509 | ||
|
510 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
511 | { | |
|
512 | int result; | |
|
513 | unsigned int tmp; | |
|
514 | ||
|
515 | result = LFR_SUCCESSFUL; | |
|
516 | ||
|
517 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
|
518 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
519 | result = LFR_DEFAULT; | |
|
520 | } | |
|
521 | else { | |
|
522 | // sy_lfr_n_swf_l | |
|
523 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[0]; | |
|
524 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[1]; | |
|
525 | ||
|
526 | // sy_lfr_n_swf_p | |
|
527 | tmp = ( unsigned int ) floor( | |
|
528 | (TC->dataAndCRC[2] * 256 | |
|
529 | + TC->dataAndCRC[3])/8 | |
|
530 | ) * 8; | |
|
531 | if ( (tmp < 16) || (tmp>65528) ) | |
|
532 | { | |
|
533 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, 12, TC->dataAndCRC[2]); | |
|
534 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, 13, TC->dataAndCRC[3]); | |
|
535 | result = LFR_DEFAULT; | |
|
536 | } | |
|
537 | else | |
|
538 | { | |
|
539 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8); | |
|
540 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp ); | |
|
541 | } | |
|
542 | ||
|
543 | // sy_lfr_n_asm_p | |
|
544 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[4]; | |
|
545 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[5]; | |
|
546 | ||
|
547 | // sy_lfr_n_bp_p0 | |
|
548 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[6]; | |
|
549 | ||
|
550 | // sy_lfr_n_bp_p1 | |
|
551 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[7]; | |
|
552 | } | |
|
553 | ||
|
554 | return result; | |
|
555 | } | |
|
556 | ||
|
557 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
558 | { | |
|
559 | int result; | |
|
560 | unsigned char lfrMode; | |
|
561 | ||
|
562 | result = LFR_DEFAULT; | |
|
563 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
564 | ||
|
565 | if ( lfrMode == LFR_MODE_BURST ) { | |
|
566 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
567 | result = LFR_DEFAULT; | |
|
568 | } | |
|
569 | else { | |
|
570 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0]; | |
|
571 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1]; | |
|
572 | ||
|
573 | result = LFR_SUCCESSFUL; | |
|
574 | } | |
|
575 | ||
|
576 | return result; | |
|
577 | } | |
|
578 | ||
|
579 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
580 | { | |
|
581 | int result; | |
|
582 | unsigned char lfrMode; | |
|
583 | ||
|
584 | result = LFR_DEFAULT; | |
|
585 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
586 | ||
|
587 | if ( lfrMode == LFR_MODE_SBM1 ) { | |
|
588 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
589 | result = LFR_DEFAULT; | |
|
590 | } | |
|
591 | else { | |
|
592 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0]; | |
|
593 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1]; | |
|
594 | ||
|
595 | result = LFR_SUCCESSFUL; | |
|
596 | } | |
|
597 | ||
|
598 | return result; | |
|
599 | } | |
|
600 | ||
|
601 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
602 | { | |
|
603 | int result; | |
|
604 | unsigned char lfrMode; | |
|
605 | ||
|
606 | result = LFR_DEFAULT; | |
|
607 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
608 | ||
|
609 | if ( lfrMode == LFR_MODE_SBM2 ) { | |
|
610 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
611 | result = LFR_DEFAULT; | |
|
612 | } | |
|
613 | else { | |
|
614 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0]; | |
|
615 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1]; | |
|
616 | ||
|
617 | result = LFR_SUCCESSFUL; | |
|
618 | } | |
|
619 | ||
|
620 | return result; | |
|
621 | } | |
|
622 | ||
|
623 | int action_dump_par(ccsdsTelecommandPacket_t *TC) | |
|
624 | { | |
|
625 | int status; | |
|
626 | // send parameter dump packet | |
|
627 | status = write(fdSPW, (char *) ¶meter_dump_packet, | |
|
628 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + 4); | |
|
629 | if (status == -1) | |
|
630 | { | |
|
631 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
|
632 | status = RTEMS_UNSATISFIED; | |
|
633 | } | |
|
634 | else | |
|
635 | { | |
|
636 | status = RTEMS_SUCCESSFUL; | |
|
637 | } | |
|
638 | ||
|
639 | return status; | |
|
640 | } | |
|
641 | ||
|
642 | 661 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
643 | 662 | { |
|
663 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
|
664 | * | |
|
665 | * @param TC points to the TeleCommand packet that is being processed | |
|
666 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
667 | * | |
|
668 | */ | |
|
669 | ||
|
644 | 670 | rtems_status_code status; |
|
645 | 671 | unsigned char requestedMode; |
|
646 | 672 | |
|
647 | 673 | requestedMode = TC->dataAndCRC[1]; |
|
648 | 674 | |
|
649 | 675 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
650 | 676 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
651 | 677 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
652 | 678 | { |
|
653 | 679 | status = RTEMS_UNSATISFIED; |
|
654 | 680 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode ); |
|
655 | 681 | } |
|
656 | 682 | else |
|
657 | 683 | { |
|
658 | 684 | printf("try to enter mode %d\n", requestedMode); |
|
659 | 685 | |
|
660 | 686 | #ifdef PRINT_TASK_STATISTICS |
|
661 | 687 | if (requestedMode != LFR_MODE_STANDBY) |
|
662 | 688 | { |
|
663 | 689 | rtems_cpu_usage_reset(); |
|
664 | 690 | maxCount = 0; |
|
665 | 691 | } |
|
666 | 692 | #endif |
|
667 | 693 | |
|
668 | 694 | status = transition_validation(requestedMode); |
|
669 | 695 | |
|
670 | 696 | if ( status == LFR_SUCCESSFUL ) { |
|
671 | 697 | if ( lfrCurrentMode != LFR_MODE_STANDBY) |
|
672 | 698 | { |
|
673 | 699 | status = stop_current_mode(); |
|
674 | 700 | } |
|
675 | 701 | if (status != RTEMS_SUCCESSFUL) |
|
676 | 702 | { |
|
677 | 703 | PRINTF("ERR *** in action_enter *** stop_current_mode\n") |
|
678 | 704 | } |
|
679 | 705 | status = enter_mode(requestedMode, TC); |
|
680 | 706 | } |
|
681 | 707 | else |
|
682 | 708 | { |
|
683 | 709 | PRINTF("ERR *** in action_enter *** transition rejected\n") |
|
684 | 710 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
685 | 711 | } |
|
686 | 712 | } |
|
687 | 713 | |
|
688 | 714 | return status; |
|
689 | 715 | } |
|
690 | 716 | |
|
691 |
int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
|
717 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
718 | { | |
|
719 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
|
720 | * | |
|
721 | * @param TC points to the TeleCommand packet that is being processed | |
|
722 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
723 | * | |
|
724 | */ | |
|
725 | ||
|
692 | 726 | unsigned int val; |
|
693 | 727 | int result; |
|
694 | 728 | unsigned char lfrMode; |
|
695 | 729 | |
|
696 | 730 | result = LFR_DEFAULT; |
|
697 | 731 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
698 | 732 | |
|
699 | 733 | if ( (lfrMode == LFR_MODE_STANDBY) ) { |
|
700 | 734 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
701 | 735 | result = LFR_DEFAULT; |
|
702 | 736 | } |
|
703 | 737 | else { |
|
704 | 738 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
705 | 739 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
706 | 740 | val++; |
|
707 | 741 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
708 | 742 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
709 | 743 | result = LFR_SUCCESSFUL; |
|
710 | 744 | } |
|
711 | 745 | |
|
712 | 746 | return result; |
|
713 | 747 | } |
|
714 | 748 | |
|
715 | 749 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
716 | 750 | { |
|
751 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
|
752 | * | |
|
753 | * @param TC points to the TeleCommand packet that is being processed | |
|
754 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
755 | * | |
|
756 | */ | |
|
757 | ||
|
717 | 758 | int result; |
|
718 | 759 | unsigned char lfrMode; |
|
719 | 760 | |
|
720 | 761 | result = LFR_DEFAULT; |
|
721 | 762 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
722 | 763 | |
|
723 | 764 | if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { |
|
724 | 765 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
725 | 766 | result = LFR_DEFAULT; |
|
726 | 767 | } |
|
727 | 768 | else { |
|
728 | 769 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
729 | 770 | result = LFR_DEFAULT; |
|
730 | 771 | } |
|
731 | 772 | return result; |
|
732 | 773 | } |
|
733 | 774 | |
|
734 | 775 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
735 | 776 | { |
|
777 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
|
778 | * | |
|
779 | * @param TC points to the TeleCommand packet that is being processed | |
|
780 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
781 | * | |
|
782 | */ | |
|
783 | ||
|
736 | 784 | int result; |
|
737 | 785 | unsigned char lfrMode; |
|
738 | 786 | |
|
739 | 787 | result = LFR_DEFAULT; |
|
740 | 788 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
741 | 789 | |
|
742 | 790 | if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { |
|
743 | 791 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
744 | 792 | result = LFR_DEFAULT; |
|
745 | 793 | } |
|
746 | 794 | else { |
|
747 | 795 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
748 | 796 | result = LFR_DEFAULT; |
|
749 | 797 | } |
|
750 | 798 | return result; |
|
751 | 799 | } |
|
752 | 800 | |
|
753 | 801 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
754 | 802 | { |
|
803 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
|
804 | * | |
|
805 | * @param TC points to the TeleCommand packet that is being processed | |
|
806 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
807 | * | |
|
808 | */ | |
|
809 | ||
|
755 | 810 | unsigned int val; |
|
756 | 811 | |
|
757 | 812 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
758 | 813 | + (TC->dataAndCRC[1] << 16) |
|
759 | 814 | + (TC->dataAndCRC[2] << 8) |
|
760 | 815 | + TC->dataAndCRC[3]; |
|
761 | 816 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
762 | 817 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
763 | 818 | val++; |
|
764 | 819 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
765 | 820 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
766 | 821 | time_management_regs->ctrl = time_management_regs->ctrl | 1; |
|
767 | 822 | |
|
768 | 823 | return LFR_SUCCESSFUL; |
|
769 | 824 | } |
|
770 | 825 | |
|
771 | 826 | //******************* |
|
772 | 827 | // ENTERING THE MODES |
|
773 | 828 | |
|
774 | 829 | int transition_validation(unsigned char requestedMode) |
|
775 | 830 | { |
|
776 | 831 | int status; |
|
777 | 832 | |
|
778 | 833 | switch (requestedMode) |
|
779 | 834 | { |
|
780 | 835 | case LFR_MODE_STANDBY: |
|
781 | 836 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
782 | 837 | status = LFR_DEFAULT; |
|
783 | 838 | } |
|
784 | 839 | else |
|
785 | 840 | { |
|
786 | 841 | status = LFR_SUCCESSFUL; |
|
787 | 842 | } |
|
788 | 843 | break; |
|
789 | 844 | case LFR_MODE_NORMAL: |
|
790 | 845 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
791 | 846 | status = LFR_DEFAULT; |
|
792 | 847 | } |
|
793 | 848 | else { |
|
794 | 849 | status = LFR_SUCCESSFUL; |
|
795 | 850 | } |
|
796 | 851 | break; |
|
797 | 852 | case LFR_MODE_BURST: |
|
798 | 853 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
799 | 854 | status = LFR_DEFAULT; |
|
800 | 855 | } |
|
801 | 856 | else { |
|
802 | 857 | status = LFR_SUCCESSFUL; |
|
803 | 858 | } |
|
804 | 859 | break; |
|
805 | 860 | case LFR_MODE_SBM1: |
|
806 | 861 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
807 | 862 | status = LFR_DEFAULT; |
|
808 | 863 | } |
|
809 | 864 | else { |
|
810 | 865 | status = LFR_SUCCESSFUL; |
|
811 | 866 | } |
|
812 | 867 | break; |
|
813 | 868 | case LFR_MODE_SBM2: |
|
814 | 869 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
815 | 870 | status = LFR_DEFAULT; |
|
816 | 871 | } |
|
817 | 872 | else { |
|
818 | 873 | status = LFR_SUCCESSFUL; |
|
819 | 874 | } |
|
820 | 875 | break; |
|
821 | 876 | default: |
|
822 | 877 | status = LFR_DEFAULT; |
|
823 | 878 | break; |
|
824 | 879 | } |
|
825 | 880 | |
|
826 | 881 | return status; |
|
827 | 882 | } |
|
828 | 883 | |
|
829 | 884 | int stop_current_mode() |
|
830 | 885 | { |
|
886 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
|
887 | * | |
|
888 | * @return RTEMS directive status codes: | |
|
889 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
|
890 | * - RTEMS_INVALID_ID - task id invalid | |
|
891 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
|
892 | * | |
|
893 | */ | |
|
894 | ||
|
831 | 895 | rtems_status_code status; |
|
832 | 896 | |
|
833 | 897 | status = RTEMS_SUCCESSFUL; |
|
834 | 898 | |
|
835 | 899 | // mask all IRQ lines related to signal processing |
|
836 | 900 | LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP) |
|
837 | 901 | LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP) |
|
838 | 902 | |
|
839 | 903 | #ifdef GSA |
|
840 | 904 | LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP) |
|
841 | 905 | LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP) |
|
842 | 906 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR ); |
|
843 | 907 | #else |
|
844 | 908 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
845 | 909 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
846 | 910 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt |
|
847 | 911 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
848 | 912 | LEON_Mask_interrupt( IRQ_SM ); // for SM simulation |
|
849 | 913 | LEON_Clear_interrupt( IRQ_SM ); // for SM simulation |
|
850 | 914 | #endif |
|
851 | 915 | //********************** |
|
852 | 916 | // suspend several tasks |
|
853 | 917 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
854 | suspend_science_tasks(); | |
|
918 | status = suspend_science_tasks(); | |
|
855 | 919 | } |
|
856 | 920 | |
|
857 | 921 | if (status != RTEMS_SUCCESSFUL) |
|
858 | 922 | { |
|
859 |
PRINTF(" |
|
|
923 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
|
860 | 924 | } |
|
861 | 925 | |
|
862 | 926 | //************************* |
|
863 | 927 | // initialize the registers |
|
864 | 928 | #ifdef GSA |
|
865 | 929 | #else |
|
866 | 930 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
867 | 931 | reset_wfp_status(); // reset all the status bits |
|
868 | 932 | #endif |
|
869 | 933 | |
|
870 | 934 | return status; |
|
871 | 935 | } |
|
872 | 936 | |
|
873 | 937 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC ) |
|
874 | 938 | { |
|
875 | 939 | rtems_status_code status; |
|
876 | 940 | |
|
877 | 941 | status = RTEMS_UNSATISFIED; |
|
878 | 942 | |
|
879 | 943 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); |
|
880 | 944 | lfrCurrentMode = mode; |
|
881 | 945 | |
|
882 | 946 | switch(mode){ |
|
883 | 947 | case LFR_MODE_STANDBY: |
|
884 | 948 | status = enter_standby_mode( TC ); |
|
885 | 949 | break; |
|
886 | 950 | case LFR_MODE_NORMAL: |
|
887 | 951 | status = enter_normal_mode( TC ); |
|
888 | 952 | break; |
|
889 | 953 | case LFR_MODE_BURST: |
|
890 | 954 | status = enter_burst_mode( TC ); |
|
891 | 955 | break; |
|
892 | 956 | case LFR_MODE_SBM1: |
|
893 | 957 | status = enter_sbm1_mode( TC ); |
|
894 | 958 | break; |
|
895 | 959 | case LFR_MODE_SBM2: |
|
896 | 960 | status = enter_sbm2_mode( TC ); |
|
897 | 961 | break; |
|
898 | 962 | default: |
|
899 | 963 | status = RTEMS_UNSATISFIED; |
|
900 | 964 | } |
|
901 | 965 | |
|
902 | 966 | if (status != RTEMS_SUCCESSFUL) |
|
903 | 967 | { |
|
904 | 968 | PRINTF("in enter_mode *** ERR\n") |
|
905 | 969 | status = RTEMS_UNSATISFIED; |
|
906 | 970 | } |
|
907 | 971 | |
|
908 | 972 | return status; |
|
909 | 973 | } |
|
910 | 974 | |
|
911 | 975 | int enter_standby_mode() |
|
912 | 976 | { |
|
913 | 977 | reset_waveform_picker_regs(); |
|
914 | 978 | |
|
915 | 979 | PRINTF1("maxCount = %d\n", maxCount) |
|
916 | 980 | |
|
917 | 981 | #ifdef PRINT_TASK_STATISTICS |
|
918 | 982 | rtems_cpu_usage_report(); |
|
919 | 983 | #endif |
|
920 | 984 | |
|
921 | 985 | #ifdef PRINT_STACK_REPORT |
|
922 | 986 | rtems_stack_checker_report_usage(); |
|
923 | 987 | #endif |
|
924 | 988 | |
|
925 | 989 | return LFR_SUCCESSFUL; |
|
926 | 990 | } |
|
927 | 991 | |
|
928 | 992 | int enter_normal_mode() |
|
929 | 993 | { |
|
930 | 994 | rtems_status_code status; |
|
931 | 995 | |
|
932 | 996 | status = restart_science_tasks(); |
|
933 | 997 | |
|
934 | 998 | #ifdef GSA |
|
935 | 999 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR ); |
|
936 | 1000 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
937 | 1001 | LEON_Clear_interrupt( IRQ_WF ); |
|
938 | 1002 | LEON_Unmask_interrupt( IRQ_WF ); |
|
939 | 1003 | // |
|
940 | 1004 | set_local_nb_interrupt_f0_MAX(); |
|
941 | 1005 | LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board |
|
942 | 1006 | LEON_Unmask_interrupt( IRQ_SM ); |
|
943 | 1007 | #else |
|
944 | 1008 | //**************** |
|
945 | 1009 | // waveform picker |
|
946 | 1010 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
947 | 1011 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
948 | 1012 | reset_waveform_picker_regs(); |
|
949 | 1013 | set_wfp_burst_enable_register(LFR_MODE_NORMAL); |
|
950 | 1014 | //**************** |
|
951 | 1015 | // spectral matrix |
|
952 | 1016 | // set_local_nb_interrupt_f0_MAX(); |
|
953 | 1017 | // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board |
|
954 | 1018 | // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
955 | 1019 | // spectral_matrix_regs->config = 0x01; |
|
956 | 1020 | // spectral_matrix_regs->status = 0x00; |
|
957 | 1021 | #endif |
|
958 | 1022 | |
|
959 | 1023 | return status; |
|
960 | 1024 | } |
|
961 | 1025 | |
|
962 | 1026 | int enter_burst_mode() |
|
963 | 1027 | { |
|
964 | 1028 | rtems_status_code status; |
|
965 | 1029 | |
|
966 | 1030 | status = restart_science_tasks(); |
|
967 | 1031 | |
|
968 | 1032 | #ifdef GSA |
|
969 | 1033 | LEON_Unmask_interrupt( IRQ_SM ); |
|
970 | 1034 | #else |
|
971 | 1035 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
972 | 1036 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
973 | 1037 | reset_waveform_picker_regs(); |
|
974 | 1038 | set_wfp_burst_enable_register(LFR_MODE_BURST); |
|
975 | 1039 | #endif |
|
976 | 1040 | |
|
977 | 1041 | return status; |
|
978 | 1042 | } |
|
979 | 1043 | |
|
980 | 1044 | int enter_sbm1_mode() |
|
981 | 1045 | { |
|
982 | 1046 | rtems_status_code status; |
|
983 | 1047 | |
|
984 | 1048 | status = restart_science_tasks(); |
|
985 | 1049 | |
|
986 | 1050 | set_local_sbm1_nb_cwf_max(); |
|
987 | 1051 | |
|
988 | 1052 | reset_local_sbm1_nb_cwf_sent(); |
|
989 | 1053 | |
|
990 | 1054 | #ifdef GSA |
|
991 | 1055 | LEON_Unmask_interrupt( IRQ_SM ); |
|
992 | 1056 | #else |
|
993 | 1057 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
994 | 1058 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
995 | 1059 | reset_waveform_picker_regs(); |
|
996 | 1060 | set_wfp_burst_enable_register(LFR_MODE_SBM1); |
|
997 | 1061 | // SM simulation |
|
998 | 1062 | // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
999 | 1063 | // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board |
|
1000 | 1064 | // LEON_Unmask_interrupt( IRQ_SM ); |
|
1001 | 1065 | #endif |
|
1002 | 1066 | |
|
1003 | 1067 | return status; |
|
1004 | 1068 | } |
|
1005 | 1069 | |
|
1006 | 1070 | int enter_sbm2_mode() |
|
1007 | 1071 | { |
|
1008 | 1072 | rtems_status_code status; |
|
1009 | 1073 | |
|
1010 | 1074 | status = restart_science_tasks(); |
|
1011 | 1075 | |
|
1012 | 1076 | set_local_sbm2_nb_cwf_max(); |
|
1013 | 1077 | |
|
1014 | 1078 | reset_local_sbm2_nb_cwf_sent(); |
|
1015 | 1079 | |
|
1016 | 1080 | #ifdef GSA |
|
1017 | 1081 | LEON_Unmask_interrupt( IRQ_SM ); |
|
1018 | 1082 | #else |
|
1019 | 1083 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1020 | 1084 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1021 | 1085 | reset_waveform_picker_regs(); |
|
1022 | 1086 | set_wfp_burst_enable_register(LFR_MODE_SBM2); |
|
1023 | 1087 | #endif |
|
1024 | 1088 | |
|
1025 | 1089 | return status; |
|
1026 | 1090 | } |
|
1027 | 1091 | |
|
1028 | 1092 | int restart_science_tasks() |
|
1029 | 1093 | { |
|
1030 | 1094 | rtems_status_code status[6]; |
|
1031 | 1095 | rtems_status_code ret; |
|
1032 | 1096 | |
|
1033 | 1097 | ret = RTEMS_SUCCESSFUL; |
|
1034 | 1098 | |
|
1035 | 1099 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); |
|
1036 | 1100 | if (status[0] != RTEMS_SUCCESSFUL) |
|
1037 | 1101 | { |
|
1038 | 1102 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) |
|
1039 | 1103 | } |
|
1040 | 1104 | |
|
1041 | 1105 | status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 ); |
|
1042 | 1106 | if (status[1] != RTEMS_SUCCESSFUL) |
|
1043 | 1107 | { |
|
1044 | 1108 | PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1]) |
|
1045 | 1109 | } |
|
1046 | 1110 | |
|
1047 | 1111 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
1048 | 1112 | if (status[2] != RTEMS_SUCCESSFUL) |
|
1049 | 1113 | { |
|
1050 | 1114 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) |
|
1051 | 1115 | } |
|
1052 | 1116 | |
|
1053 | 1117 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
1054 | 1118 | if (status[3] != RTEMS_SUCCESSFUL) |
|
1055 | 1119 | { |
|
1056 | 1120 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) |
|
1057 | 1121 | } |
|
1058 | 1122 | |
|
1059 | 1123 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
1060 | 1124 | if (status[4] != RTEMS_SUCCESSFUL) |
|
1061 | 1125 | { |
|
1062 | 1126 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) |
|
1063 | 1127 | } |
|
1064 | 1128 | |
|
1065 | 1129 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
1066 | 1130 | if (status[5] != RTEMS_SUCCESSFUL) |
|
1067 | 1131 | { |
|
1068 | 1132 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) |
|
1069 | 1133 | } |
|
1070 | 1134 | |
|
1071 | 1135 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || |
|
1072 | 1136 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
1073 | 1137 | { |
|
1074 | 1138 | ret = RTEMS_UNSATISFIED; |
|
1075 | 1139 | } |
|
1076 | 1140 | |
|
1077 | 1141 | return ret; |
|
1078 | 1142 | } |
|
1079 | 1143 | |
|
1080 | 1144 | int suspend_science_tasks() |
|
1081 | 1145 | { |
|
1082 | rtems_status_code status[6]; | |
|
1083 | rtems_status_code ret; | |
|
1084 | ||
|
1085 | ret = RTEMS_SUCCESSFUL; | |
|
1146 | /** This function suspends the science tasks. | |
|
1147 | * | |
|
1148 | * @return RTEMS directive status codes: | |
|
1149 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
|
1150 | * - RTEMS_INVALID_ID - task id invalid | |
|
1151 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
|
1152 | * | |
|
1153 | */ | |
|
1086 | 1154 | |
|
1087 | status[0] = rtems_task_suspend( Task_id[TASKID_AVF0] ); | |
|
1088 | if (status[0] != RTEMS_SUCCESSFUL) | |
|
1089 | { | |
|
1090 | PRINTF1("in suspend_science_task *** 0 ERR %d\n", status[0]) | |
|
1091 | } | |
|
1155 | rtems_status_code status; | |
|
1092 | 1156 | |
|
1093 |
status |
|
|
1094 |
if (status |
|
|
1157 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); | |
|
1158 | if (status != RTEMS_SUCCESSFUL) | |
|
1095 | 1159 | { |
|
1096 |
PRINTF1("in suspend_science_task *** |
|
|
1160 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
|
1097 | 1161 | } |
|
1098 | ||
|
1099 | status[2] = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
|
1100 | if (status[2] != RTEMS_SUCCESSFUL) | |
|
1162 | if (status == RTEMS_SUCCESSFUL) // suspend BPF0 | |
|
1101 | 1163 | { |
|
1102 | PRINTF1("in suspend_science_task *** 2 ERR %d\n", status[2]) | |
|
1164 | status = rtems_task_suspend( Task_id[TASKID_BPF0] ); | |
|
1165 | if (status != RTEMS_SUCCESSFUL) | |
|
1166 | { | |
|
1167 | PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status) | |
|
1168 | } | |
|
1169 | } | |
|
1170 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
|
1171 | { | |
|
1172 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
|
1173 | if (status != RTEMS_SUCCESSFUL) | |
|
1174 | { | |
|
1175 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
|
1176 | } | |
|
1103 | 1177 | } |
|
1104 | 1178 | |
|
1105 | status[3] = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
|
1106 | if (status[3] != RTEMS_SUCCESSFUL) | |
|
1179 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
|
1107 | 1180 | { |
|
1108 | PRINTF1("in suspend_science_task *** 3 ERR %d\n", status[3]) | |
|
1181 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
|
1182 | if (status != RTEMS_SUCCESSFUL) | |
|
1183 | { | |
|
1184 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
|
1185 | } | |
|
1109 | 1186 | } |
|
1110 | ||
|
1111 | status[4] = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
|
1112 | if (status[4] != RTEMS_SUCCESSFUL) | |
|
1187 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
|
1113 | 1188 | { |
|
1114 | PRINTF1("in suspend_science_task *** 4 ERR %d\n", status[4]) | |
|
1189 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
|
1190 | if (status != RTEMS_SUCCESSFUL) | |
|
1191 | { | |
|
1192 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
|
1193 | } | |
|
1194 | } | |
|
1195 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
|
1196 | { | |
|
1197 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
|
1198 | if (status != RTEMS_SUCCESSFUL) | |
|
1199 | { | |
|
1200 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
|
1201 | } | |
|
1115 | 1202 | } |
|
1116 | 1203 | |
|
1117 | status[5] = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
|
1118 | if (status[5] != RTEMS_SUCCESSFUL) | |
|
1119 | { | |
|
1120 | PRINTF1("in suspend_science_task *** 5 ERR %d\n", status[5]) | |
|
1121 | } | |
|
1122 | ||
|
1123 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || | |
|
1124 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
|
1125 | { | |
|
1126 | ret = RTEMS_UNSATISFIED; | |
|
1127 | } | |
|
1128 | ||
|
1129 | return ret; | |
|
1204 | return status; | |
|
1130 | 1205 | } |
|
1131 | 1206 | |
|
1132 | 1207 | //**************** |
|
1133 | 1208 | // CLOSING ACTIONS |
|
1134 | ||
|
1135 | int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
1136 | { | |
|
1137 | int ret; | |
|
1138 | rtems_status_code status; | |
|
1139 | Packet_TM_LFR_TC_EXE_SUCCESS_t TM; | |
|
1140 | unsigned char messageSize; | |
|
1141 | ||
|
1142 | ret = LFR_SUCCESSFUL; | |
|
1143 | ||
|
1144 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
|
1145 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
|
1146 | TM.reserved = DEFAULT_RESERVED; | |
|
1147 | TM.userApplication = CCSDS_USER_APP; | |
|
1148 | // PACKET HEADER | |
|
1149 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); | |
|
1150 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); | |
|
1151 | TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8); | |
|
1152 | TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE ); | |
|
1153 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8); | |
|
1154 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS ); | |
|
1155 | // DATA FIELD HEADER | |
|
1156 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
|
1157 | TM.serviceType = TM_TYPE_TC_EXE; | |
|
1158 | TM.serviceSubType = TM_SUBTYPE_EXE_OK; | |
|
1159 | TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id | |
|
1160 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
1161 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
1162 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
1163 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
1164 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
1165 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
1166 | // | |
|
1167 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
|
1168 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
|
1169 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
|
1170 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
|
1171 | ||
|
1172 | messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
|
1173 | ||
|
1174 | // SEND DATA | |
|
1175 | status = rtems_message_queue_urgent( queue_id, &TM, messageSize); | |
|
1176 | if (status != RTEMS_SUCCESSFUL) { | |
|
1177 | PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n") | |
|
1178 | ret = LFR_DEFAULT; | |
|
1179 | } | |
|
1180 | ||
|
1181 | return LFR_SUCCESSFUL; | |
|
1182 | } | |
|
1183 | ||
|
1184 | int send_tm_lfr_tc_exe_inconsistent(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, | |
|
1185 | unsigned char byte_position, unsigned char rcv_value) | |
|
1186 | { | |
|
1187 | int ret; | |
|
1188 | rtems_status_code status; | |
|
1189 | Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM; | |
|
1190 | unsigned char messageSize; | |
|
1191 | ||
|
1192 | ret = LFR_SUCCESSFUL; | |
|
1193 | ||
|
1194 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
|
1195 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
|
1196 | TM.reserved = DEFAULT_RESERVED; | |
|
1197 | TM.userApplication = CCSDS_USER_APP; | |
|
1198 | // PACKET HEADER | |
|
1199 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); | |
|
1200 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); | |
|
1201 | TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8); | |
|
1202 | TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE ); | |
|
1203 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8); | |
|
1204 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT ); | |
|
1205 | // DATA FIELD HEADER | |
|
1206 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
|
1207 | TM.serviceType = TM_TYPE_TC_EXE; | |
|
1208 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
|
1209 | TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id | |
|
1210 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
1211 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
1212 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
1213 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
1214 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
1215 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
1216 | // | |
|
1217 | TM.tc_failure_code[0] = (char) (FAILURE_CODE_INCONSISTENT >> 8); | |
|
1218 | TM.tc_failure_code[1] = (char) (FAILURE_CODE_INCONSISTENT ); | |
|
1219 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
|
1220 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
|
1221 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
|
1222 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
|
1223 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
|
1224 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
|
1225 | TM.byte_position = byte_position; | |
|
1226 | TM.rcv_value = rcv_value; | |
|
1227 | ||
|
1228 | messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
|
1229 | ||
|
1230 | // SEND DATA | |
|
1231 | status = rtems_message_queue_urgent( queue_id, &TM, messageSize); | |
|
1232 | if (status != RTEMS_SUCCESSFUL) { | |
|
1233 | PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n") | |
|
1234 | ret = LFR_DEFAULT; | |
|
1235 | } | |
|
1236 | ||
|
1237 | return LFR_SUCCESSFUL; | |
|
1238 | } | |
|
1239 | ||
|
1240 | int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
1241 | { | |
|
1242 | int ret; | |
|
1243 | rtems_status_code status; | |
|
1244 | Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM; | |
|
1245 | unsigned char messageSize; | |
|
1246 | ||
|
1247 | ret = LFR_SUCCESSFUL; | |
|
1248 | ||
|
1249 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
|
1250 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
|
1251 | TM.reserved = DEFAULT_RESERVED; | |
|
1252 | TM.userApplication = CCSDS_USER_APP; | |
|
1253 | // PACKET HEADER | |
|
1254 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); | |
|
1255 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); | |
|
1256 | TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8); | |
|
1257 | TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE ); | |
|
1258 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8); | |
|
1259 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE ); | |
|
1260 | // DATA FIELD HEADER | |
|
1261 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
|
1262 | TM.serviceType = TM_TYPE_TC_EXE; | |
|
1263 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
|
1264 | TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id | |
|
1265 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
1266 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
1267 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
1268 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
1269 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
1270 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
1271 | // | |
|
1272 | TM.tc_failure_code[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8); | |
|
1273 | TM.tc_failure_code[1] = (char) (FAILURE_CODE_NOT_EXECUTABLE ); | |
|
1274 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
|
1275 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
|
1276 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
|
1277 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
|
1278 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
|
1279 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
|
1280 | TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0]; | |
|
1281 | TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]; | |
|
1282 | ||
|
1283 | messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
|
1284 | ||
|
1285 | // SEND DATA | |
|
1286 | status = rtems_message_queue_urgent( queue_id, &TM, messageSize); | |
|
1287 | if (status != RTEMS_SUCCESSFUL) { | |
|
1288 | PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n") | |
|
1289 | ret = LFR_DEFAULT; | |
|
1290 | } | |
|
1291 | ||
|
1292 | return LFR_SUCCESSFUL; | |
|
1293 | } | |
|
1294 | ||
|
1295 | int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
1296 | { | |
|
1297 | int ret; | |
|
1298 | rtems_status_code status; | |
|
1299 | Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM; | |
|
1300 | unsigned char messageSize; | |
|
1301 | ||
|
1302 | ret = LFR_SUCCESSFUL; | |
|
1303 | ||
|
1304 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
|
1305 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
|
1306 | TM.reserved = DEFAULT_RESERVED; | |
|
1307 | TM.userApplication = CCSDS_USER_APP; | |
|
1308 | // PACKET HEADER | |
|
1309 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); | |
|
1310 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); | |
|
1311 | TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8); | |
|
1312 | TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE ); | |
|
1313 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8); | |
|
1314 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED ); | |
|
1315 | // DATA FIELD HEADER | |
|
1316 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
|
1317 | TM.serviceType = TM_TYPE_TC_EXE; | |
|
1318 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
|
1319 | TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id | |
|
1320 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
1321 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
1322 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
1323 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
1324 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
1325 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
1326 | // | |
|
1327 | TM.tc_failure_code[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8); | |
|
1328 | TM.tc_failure_code[1] = (char) (FAILURE_CODE_NOT_IMPLEMENTED ); | |
|
1329 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
|
1330 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
|
1331 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
|
1332 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
|
1333 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
|
1334 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
|
1335 | ||
|
1336 | messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
|
1337 | ||
|
1338 | // SEND DATA | |
|
1339 | status = rtems_message_queue_urgent( queue_id, &TM, messageSize); | |
|
1340 | if (status != RTEMS_SUCCESSFUL) { | |
|
1341 | PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n") | |
|
1342 | ret = LFR_DEFAULT; | |
|
1343 | } | |
|
1344 | ||
|
1345 | return LFR_SUCCESSFUL; | |
|
1346 | } | |
|
1347 | ||
|
1348 | int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
|
1349 | { | |
|
1350 | int ret; | |
|
1351 | rtems_status_code status; | |
|
1352 | Packet_TM_LFR_TC_EXE_ERROR_t TM; | |
|
1353 | unsigned char messageSize; | |
|
1354 | ||
|
1355 | ret = LFR_SUCCESSFUL; | |
|
1356 | ||
|
1357 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
|
1358 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
|
1359 | TM.reserved = DEFAULT_RESERVED; | |
|
1360 | TM.userApplication = CCSDS_USER_APP; | |
|
1361 | // PACKET HEADER | |
|
1362 | TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8); | |
|
1363 | TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE ); | |
|
1364 | TM.packetSequenceControl[0] = (TM_PACKET_SEQ_CTRL_STANDALONE >> 8); | |
|
1365 | TM.packetSequenceControl[1] = (TM_PACKET_SEQ_CTRL_STANDALONE ); | |
|
1366 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8); | |
|
1367 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR ); | |
|
1368 | // DATA FIELD HEADER | |
|
1369 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
|
1370 | TM.serviceType = TM_TYPE_TC_EXE; | |
|
1371 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
|
1372 | TM.destinationID = TM_DESTINATION_ID_GROUND; // default destination id | |
|
1373 | TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
1374 | TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
1375 | TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
1376 | TM.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
1377 | TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
1378 | TM.time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
1379 | // | |
|
1380 | TM.tc_failure_code[0] = (char) (FAILURE_CODE_ERROR >> 8); | |
|
1381 | TM.tc_failure_code[1] = (char) (FAILURE_CODE_ERROR ); | |
|
1382 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
|
1383 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
|
1384 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
|
1385 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
|
1386 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
|
1387 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
|
1388 | ||
|
1389 | messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
|
1390 | ||
|
1391 | // SEND DATA | |
|
1392 | status = rtems_message_queue_urgent( queue_id, &TM, messageSize); | |
|
1393 | if (status != RTEMS_SUCCESSFUL) { | |
|
1394 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") | |
|
1395 | ret = LFR_DEFAULT; | |
|
1396 | } | |
|
1397 | ||
|
1398 | return LFR_SUCCESSFUL; | |
|
1399 | } | |
|
1400 | ||
|
1401 | 1209 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) |
|
1402 | 1210 | { |
|
1403 | 1211 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1404 | 1212 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1405 | 1213 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1406 | 1214 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1407 | 1215 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1408 | 1216 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1409 | 1217 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1410 | 1218 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1411 | 1219 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1412 | 1220 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1413 | 1221 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1414 | 1222 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1415 | 1223 | } |
|
1416 | 1224 | |
|
1417 | 1225 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC) |
|
1418 | 1226 | { |
|
1419 | 1227 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1420 | 1228 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1421 | 1229 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1422 | 1230 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1423 | 1231 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1424 | 1232 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1425 | 1233 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1426 | 1234 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1427 | 1235 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1428 | 1236 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1429 | 1237 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1430 | 1238 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1431 | 1239 | } |
|
1432 | 1240 | |
|
1433 | 1241 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id) |
|
1434 | 1242 | { |
|
1435 | 1243 | unsigned int val = 0; |
|
1436 | 1244 | if (result == LFR_SUCCESSFUL) |
|
1437 | 1245 | { |
|
1438 | 1246 | if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) ) |
|
1439 | 1247 | { |
|
1440 | 1248 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1441 | 1249 | } |
|
1442 | 1250 | update_last_TC_exe( TC ); |
|
1443 | 1251 | val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1]; |
|
1444 | 1252 | val++; |
|
1445 | 1253 | housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8); |
|
1446 | 1254 | housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val); |
|
1447 | 1255 | } |
|
1448 | 1256 | else |
|
1449 | 1257 | { |
|
1450 | 1258 | update_last_TC_rej( TC ); |
|
1451 | 1259 | val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1]; |
|
1452 | 1260 | val++; |
|
1453 | 1261 | housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8); |
|
1454 | 1262 | housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val); |
|
1455 | 1263 | } |
|
1456 | 1264 | } |
|
1457 | 1265 | |
|
1458 | 1266 | //*************************** |
|
1459 | 1267 | // Interrupt Service Routines |
|
1460 | 1268 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1461 | 1269 | { |
|
1462 | 1270 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1463 | 1271 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
1464 | 1272 | } |
|
1465 | 1273 | } |
|
1466 | 1274 | |
|
1467 | 1275 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1468 | 1276 | { |
|
1469 | 1277 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1470 | 1278 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
1471 | 1279 | } |
|
1472 | 1280 | } |
|
1473 | 1281 | |
|
1474 | 1282 | |
|
1475 | 1283 | |
|
1476 | 1284 |
@@ -1,973 +1,1106 | |||
|
1 | #include <wf_handler.h> | |
|
1 | /** Functions and tasks related to waveform packet generation. | |
|
2 | * | |
|
3 | * @file | |
|
4 | * @author P. LEROY | |
|
5 | * | |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
|
7 | * | |
|
8 | */ | |
|
9 | ||
|
10 | #include "wf_handler.h" | |
|
2 | 11 | |
|
3 | 12 | // SWF |
|
4 | 13 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
5 | 14 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
6 | 15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
7 | 16 | // CWF |
|
8 | 17 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7]; |
|
9 | 18 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7]; |
|
10 | 19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7]; |
|
11 | 20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7]; |
|
12 | 21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7]; |
|
13 | 22 | |
|
14 | 23 | unsigned char doubleSendCWF1 = 0; |
|
15 | 24 | unsigned char doubleSendCWF2 = 0; |
|
16 | 25 | |
|
17 | 26 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
18 | 27 | { |
|
19 | 28 | |
|
20 | 29 | #ifdef GSA |
|
21 | 30 | #else |
|
22 | 31 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
23 | 32 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
24 | 33 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
25 | 34 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
26 | 35 | // (1) change the receiving buffer for the waveform picker |
|
27 | 36 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) { |
|
28 | 37 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis); |
|
29 | 38 | } |
|
30 | 39 | else { |
|
31 | 40 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); |
|
32 | 41 | } |
|
33 | 42 | // (2) send an event for the waveforms transmission |
|
34 | 43 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
35 | 44 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
36 | 45 | } |
|
37 | 46 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
38 | 47 | } |
|
39 | 48 | } |
|
40 | 49 | #endif |
|
41 | 50 | |
|
42 | 51 | switch(lfrCurrentMode) |
|
43 | 52 | { |
|
44 | 53 | //******** |
|
45 | 54 | // STANDBY |
|
46 | 55 | case(LFR_MODE_STANDBY): |
|
47 | 56 | break; |
|
48 | 57 | |
|
49 | 58 | //****** |
|
50 | 59 | // NORMAL |
|
51 | 60 | case(LFR_MODE_NORMAL): |
|
52 | 61 | #ifdef GSA |
|
53 | 62 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
54 | 63 | #else |
|
55 | 64 | if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable |
|
56 | 65 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
57 | 66 | } |
|
58 | 67 | else { |
|
59 | 68 | if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full |
|
60 | 69 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08; |
|
61 | 70 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
62 | 71 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
63 | 72 | } |
|
64 | 73 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00; |
|
65 | 74 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0 |
|
66 | 75 | } |
|
67 | 76 | } |
|
68 | 77 | #endif |
|
69 | 78 | break; |
|
70 | 79 | |
|
71 | 80 | //****** |
|
72 | 81 | // BURST |
|
73 | 82 | case(LFR_MODE_BURST): |
|
74 | 83 | #ifdef GSA |
|
75 | 84 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
76 | 85 | #else |
|
77 | 86 | if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit |
|
78 | 87 | // (1) change the receiving buffer for the waveform picker |
|
79 | 88 | if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { |
|
80 | 89 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis); |
|
81 | 90 | } |
|
82 | 91 | else { |
|
83 | 92 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); |
|
84 | 93 | } |
|
85 | 94 | // (2) send an event for the waveforms transmission |
|
86 | 95 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
87 | 96 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
88 | 97 | } |
|
89 | 98 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
90 | 99 | } |
|
91 | 100 | #endif |
|
92 | 101 | break; |
|
93 | 102 | |
|
94 | 103 | //***** |
|
95 | 104 | // SBM1 |
|
96 | 105 | case(LFR_MODE_SBM1): |
|
97 | 106 | #ifdef GSA |
|
98 | 107 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
99 | 108 | #else |
|
100 | 109 | if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit |
|
101 | 110 | // (1) change the receiving buffer for the waveform picker |
|
102 | 111 | if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) ) |
|
103 | 112 | { |
|
104 | 113 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm); |
|
105 | 114 | } |
|
106 | 115 | else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm ) |
|
107 | 116 | { |
|
108 | 117 | doubleSendCWF1 = 1; |
|
109 | 118 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); |
|
110 | 119 | } |
|
111 | 120 | else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) { |
|
112 | 121 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis); |
|
113 | 122 | } |
|
114 | 123 | else { |
|
115 | 124 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); |
|
116 | 125 | } |
|
117 | 126 | // (2) send an event for the waveforms transmission |
|
118 | 127 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { |
|
119 | 128 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
120 | 129 | } |
|
121 | 130 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 |
|
122 | 131 | } |
|
123 | 132 | if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit |
|
124 | 133 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
125 | 134 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
126 | 135 | } |
|
127 | 136 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 |
|
128 | 137 | reset_local_sbm1_nb_cwf_sent(); |
|
129 | 138 | } |
|
130 | 139 | |
|
131 | 140 | #endif |
|
132 | 141 | break; |
|
133 | 142 | |
|
134 | 143 | //***** |
|
135 | 144 | // SBM2 |
|
136 | 145 | case(LFR_MODE_SBM2): |
|
137 | 146 | #ifdef GSA |
|
138 | 147 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
139 | 148 | #else |
|
140 | 149 | if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit |
|
141 | 150 | // (1) change the receiving buffer for the waveform picker |
|
142 | 151 | if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) ) |
|
143 | 152 | { |
|
144 | 153 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm); |
|
145 | 154 | } |
|
146 | 155 | else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) { |
|
147 | 156 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); |
|
148 | 157 | doubleSendCWF2 = 1; |
|
149 | 158 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) { |
|
150 | 159 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
151 | 160 | } |
|
152 | 161 | reset_local_sbm2_nb_cwf_sent(); |
|
153 | 162 | } |
|
154 | 163 | else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) { |
|
155 | 164 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis); |
|
156 | 165 | } |
|
157 | 166 | else { |
|
158 | 167 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); |
|
159 | 168 | } |
|
160 | 169 | // (2) send an event for the waveforms transmission |
|
161 | 170 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { |
|
162 | 171 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
163 | 172 | } |
|
164 | 173 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
165 | 174 | } |
|
166 | 175 | if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full |
|
167 | 176 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { |
|
168 | 177 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
169 | 178 | } |
|
170 | 179 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 |
|
171 | 180 | } |
|
172 | 181 | #endif |
|
173 | 182 | break; |
|
174 | 183 | |
|
175 | 184 | //******** |
|
176 | 185 | // DEFAULT |
|
177 | 186 | default: |
|
178 | 187 | break; |
|
179 | 188 | } |
|
180 | 189 | } |
|
181 | 190 | |
|
182 | 191 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ) |
|
183 | 192 | { |
|
184 | 193 | unsigned char lfrMode; |
|
185 | 194 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
186 | 195 | |
|
187 | 196 | switch(lfrMode) { |
|
188 | 197 | case (LFR_MODE_STANDBY): |
|
189 | 198 | break; |
|
190 | 199 | case (LFR_MODE_NORMAL): |
|
191 | 200 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
192 | 201 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 ); |
|
193 | 202 | } |
|
194 | 203 | break; |
|
195 | 204 | case (LFR_MODE_BURST): |
|
196 | 205 | break; |
|
197 | 206 | case (LFR_MODE_SBM1): |
|
198 | 207 | break; |
|
199 | 208 | case (LFR_MODE_SBM2): |
|
200 | 209 | break; |
|
201 | 210 | } |
|
202 | 211 | } |
|
203 | 212 | |
|
204 | 213 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
205 | 214 | { |
|
206 | 215 | rtems_event_set event_out; |
|
207 | 216 | rtems_id queue_id; |
|
208 | 217 | rtems_status_code status; |
|
209 | 218 | |
|
210 | 219 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
211 | 220 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
212 | 221 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
213 | 222 | |
|
214 | 223 | init_waveforms(); |
|
215 | 224 | |
|
216 | 225 | status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id ); |
|
217 | 226 | if (status != RTEMS_SUCCESSFUL) |
|
218 | 227 | { |
|
219 | 228 | PRINTF1("in WFRM *** ERR getting queue id, %d\n", status) |
|
220 | 229 | } |
|
221 | 230 | |
|
222 | 231 | BOOT_PRINTF("in WFRM ***\n") |
|
223 | 232 | |
|
224 | 233 | while(1){ |
|
225 | 234 | // wait for an RTEMS_EVENT |
|
226 | 235 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
227 | 236 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
228 | 237 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
229 | 238 | |
|
230 | 239 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
231 | 240 | { |
|
232 | 241 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
233 | 242 | send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
234 | 243 | send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
235 | 244 | #ifdef GSA |
|
236 | 245 | waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0 |
|
237 | 246 | #endif |
|
238 | 247 | } |
|
239 | 248 | else if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
240 | 249 | { |
|
241 | 250 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
242 | 251 | send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
243 | 252 | send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
244 | 253 | #ifdef GSA |
|
245 | 254 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0 |
|
246 | 255 | #endif |
|
247 | 256 | } |
|
248 | 257 | else if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
249 | 258 | { |
|
250 | 259 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
251 | 260 | send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
252 | 261 | #ifdef GSA |
|
253 | 262 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 |
|
254 | 263 | #endif |
|
255 | 264 | } |
|
256 | 265 | else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM) |
|
257 | 266 | { |
|
258 | 267 | send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
259 | 268 | } |
|
260 | 269 | else |
|
261 | 270 | { |
|
262 | 271 | PRINTF("in WFRM *** unexpected event") |
|
263 | 272 | } |
|
264 | 273 | |
|
265 | 274 | |
|
266 | 275 | #ifdef GSA |
|
267 | 276 | // irq processed, reset the related register of the timer unit |
|
268 | 277 | gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010; |
|
269 | 278 | // clear the interruption |
|
270 | 279 | LEON_Unmask_interrupt( IRQ_WF ); |
|
271 | 280 | #endif |
|
272 | 281 | } |
|
273 | 282 | } |
|
274 | 283 | |
|
275 | 284 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
276 | 285 | { |
|
277 | 286 | rtems_event_set event_out; |
|
278 | 287 | rtems_id queue_id; |
|
279 | 288 | |
|
280 | 289 | init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 ); |
|
281 | 290 | init_header_continuous_wf3_light_table( headerCWF_F3_light ); |
|
282 | 291 | |
|
283 | 292 | queue_id = get_pkts_queue_id(); |
|
284 | 293 | |
|
285 | 294 | BOOT_PRINTF("in CWF3 ***\n") |
|
286 | 295 | |
|
287 | 296 | while(1){ |
|
288 | 297 | // wait for an RTEMS_EVENT |
|
289 | 298 | rtems_event_receive( RTEMS_EVENT_0, |
|
290 | 299 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
291 | 300 | PRINTF("send CWF F3 \n") |
|
292 | 301 | #ifdef GSA |
|
293 | 302 | #else |
|
294 | 303 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) { |
|
295 | 304 | send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id ); |
|
296 | 305 | } |
|
297 | 306 | else { |
|
298 | 307 | send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id ); |
|
299 | 308 | } |
|
300 | 309 | #endif |
|
301 | 310 | } |
|
302 | 311 | } |
|
303 | 312 | |
|
304 | 313 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
305 | 314 | { |
|
306 | 315 | rtems_event_set event_out; |
|
307 | 316 | rtems_id queue_id; |
|
308 | 317 | |
|
309 | 318 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
310 | 319 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
311 | 320 | |
|
312 | 321 | queue_id = get_pkts_queue_id(); |
|
313 | 322 | |
|
314 | 323 | BOOT_PRINTF("in CWF2 ***\n") |
|
315 | 324 | |
|
316 | 325 | while(1){ |
|
317 | 326 | // wait for an RTEMS_EVENT |
|
318 | 327 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
319 | 328 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
320 | 329 | |
|
321 | 330 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
322 | 331 | { |
|
323 | 332 | // F2 |
|
324 | 333 | #ifdef GSA |
|
325 | 334 | #else |
|
326 | 335 | if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { |
|
327 | 336 | send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
328 | 337 | } |
|
329 | 338 | else { |
|
330 | 339 | send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
331 | 340 | } |
|
332 | 341 | #endif |
|
333 | 342 | } |
|
334 | 343 | |
|
335 | 344 | else if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
336 | 345 | { |
|
337 | 346 | #ifdef GSA |
|
338 | 347 | #else |
|
339 | 348 | if (doubleSendCWF2 == 1) |
|
340 | 349 | { |
|
341 | 350 | doubleSendCWF2 = 0; |
|
342 | 351 | send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
343 | 352 | } |
|
344 | 353 | else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { |
|
345 | 354 | send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
346 | 355 | } |
|
347 | 356 | else { |
|
348 | 357 | send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
349 | 358 | } |
|
350 | 359 | param_local.local_sbm2_nb_cwf_sent ++; |
|
351 | 360 | #endif |
|
352 | 361 | } |
|
353 | 362 | else |
|
354 | 363 | { |
|
355 | 364 | PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode) |
|
356 | 365 | } |
|
357 | 366 | } |
|
358 | 367 | } |
|
359 | 368 | |
|
360 | 369 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
361 | 370 | { |
|
362 | 371 | rtems_event_set event_out; |
|
363 | 372 | rtems_id queue_id; |
|
364 | 373 | |
|
365 | 374 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
366 | 375 | |
|
367 | 376 | queue_id = get_pkts_queue_id(); |
|
368 | 377 | |
|
369 | 378 | BOOT_PRINTF("in CWF1 ***\n") |
|
370 | 379 | |
|
371 | 380 | while(1){ |
|
372 | 381 | // wait for an RTEMS_EVENT |
|
373 | 382 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
374 | 383 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
375 | 384 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
376 | 385 | { |
|
377 | 386 | #ifdef GSA |
|
378 | 387 | #else |
|
379 | 388 | if (doubleSendCWF1 == 1) |
|
380 | 389 | { |
|
381 | 390 | doubleSendCWF1 = 0; |
|
382 | 391 | send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
383 | 392 | } |
|
384 | 393 | else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) { |
|
385 | 394 | send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
386 | 395 | } |
|
387 | 396 | else { |
|
388 | 397 | send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
389 | 398 | } |
|
390 | 399 | param_local.local_sbm1_nb_cwf_sent ++; |
|
391 | 400 | #endif |
|
392 | 401 | } |
|
393 | 402 | else |
|
394 | 403 | { |
|
395 | 404 | PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode) |
|
396 | 405 | } |
|
397 | 406 | } |
|
398 | 407 | } |
|
399 | 408 | |
|
400 | 409 | //****************** |
|
401 | 410 | // general functions |
|
402 | 411 | void init_waveforms( void ) |
|
403 | 412 | { |
|
404 | 413 | int i = 0; |
|
405 | 414 | |
|
406 | 415 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
407 | 416 | { |
|
408 | 417 | //*** |
|
409 | 418 | // F0 |
|
410 | 419 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // |
|
411 | 420 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // |
|
412 | 421 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // |
|
413 | 422 | |
|
414 | 423 | //*** |
|
415 | 424 | // F1 |
|
416 | 425 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; |
|
417 | 426 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; |
|
418 | 427 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
419 | 428 | |
|
420 | 429 | //*** |
|
421 | 430 | // F2 |
|
422 | 431 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; |
|
423 | 432 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; |
|
424 | 433 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
425 | 434 | |
|
426 | 435 | //*** |
|
427 | 436 | // F3 |
|
428 | 437 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; |
|
429 | 438 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; |
|
430 | 439 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; |
|
431 | 440 | } |
|
432 | 441 | } |
|
433 | 442 | |
|
434 | 443 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
435 | 444 | { |
|
436 | 445 | unsigned char i; |
|
437 | 446 | |
|
438 | 447 | for (i=0; i<7; i++) |
|
439 | 448 | { |
|
440 | 449 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
441 | 450 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
442 | 451 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
443 | 452 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
444 | 453 | headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
445 | 454 | headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
446 | 455 | if (i == 0) |
|
447 | 456 | { |
|
448 | 457 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; |
|
449 | 458 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8); |
|
450 | 459 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 ); |
|
451 | 460 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
452 | 461 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
453 | 462 | } |
|
454 | 463 | else if (i == 6) |
|
455 | 464 | { |
|
456 | 465 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; |
|
457 | 466 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8); |
|
458 | 467 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 ); |
|
459 | 468 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); |
|
460 | 469 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); |
|
461 | 470 | } |
|
462 | 471 | else |
|
463 | 472 | { |
|
464 | 473 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; |
|
465 | 474 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8); |
|
466 | 475 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 ); |
|
467 | 476 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
468 | 477 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
469 | 478 | } |
|
470 | 479 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
471 | 480 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
472 | 481 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
473 | 482 | // DATA FIELD HEADER |
|
474 | 483 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
475 | 484 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
476 | 485 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
477 | 486 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
478 | 487 | // AUXILIARY DATA HEADER |
|
479 | 488 | headerSWF[ i ].sid = sid; |
|
480 | 489 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
481 | 490 | headerSWF[ i ].time[0] = 0x00; |
|
482 | 491 | headerSWF[ i ].time[0] = 0x00; |
|
483 | 492 | headerSWF[ i ].time[0] = 0x00; |
|
484 | 493 | headerSWF[ i ].time[0] = 0x00; |
|
485 | 494 | headerSWF[ i ].time[0] = 0x00; |
|
486 | 495 | headerSWF[ i ].time[0] = 0x00; |
|
487 | 496 | } |
|
488 | 497 | return LFR_SUCCESSFUL; |
|
489 | 498 | } |
|
490 | 499 | |
|
491 | 500 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
492 | 501 | { |
|
493 | 502 | unsigned int i; |
|
494 | 503 | |
|
495 | 504 | for (i=0; i<7; i++) |
|
496 | 505 | { |
|
497 | 506 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
498 | 507 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
499 | 508 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
500 | 509 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
501 | 510 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
502 | 511 | { |
|
503 | 512 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); |
|
504 | 513 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); |
|
505 | 514 | } |
|
506 | 515 | else |
|
507 | 516 | { |
|
508 | 517 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
509 | 518 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
510 | 519 | } |
|
511 | 520 | if (i == 0) |
|
512 | 521 | { |
|
513 | 522 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; |
|
514 | 523 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); |
|
515 | 524 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); |
|
516 | 525 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
517 | 526 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
518 | 527 | } |
|
519 | 528 | else if (i == 6) |
|
520 | 529 | { |
|
521 | 530 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; |
|
522 | 531 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8); |
|
523 | 532 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 ); |
|
524 | 533 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); |
|
525 | 534 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); |
|
526 | 535 | } |
|
527 | 536 | else |
|
528 | 537 | { |
|
529 | 538 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; |
|
530 | 539 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); |
|
531 | 540 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); |
|
532 | 541 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
533 | 542 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
534 | 543 | } |
|
535 | 544 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
536 | 545 | // PKT_CNT |
|
537 | 546 | // PKT_NR |
|
538 | 547 | // DATA FIELD HEADER |
|
539 | 548 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
540 | 549 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
541 | 550 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
542 | 551 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
543 | 552 | // AUXILIARY DATA HEADER |
|
544 | 553 | headerCWF[ i ].sid = sid; |
|
545 | 554 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
546 | 555 | headerCWF[ i ].time[0] = 0x00; |
|
547 | 556 | headerCWF[ i ].time[0] = 0x00; |
|
548 | 557 | headerCWF[ i ].time[0] = 0x00; |
|
549 | 558 | headerCWF[ i ].time[0] = 0x00; |
|
550 | 559 | headerCWF[ i ].time[0] = 0x00; |
|
551 | 560 | headerCWF[ i ].time[0] = 0x00; |
|
552 | 561 | } |
|
553 | 562 | return LFR_SUCCESSFUL; |
|
554 | 563 | } |
|
555 | 564 | |
|
556 | 565 | int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
557 | 566 | { |
|
558 | 567 | unsigned int i; |
|
559 | 568 | |
|
560 | 569 | for (i=0; i<7; i++) |
|
561 | 570 | { |
|
562 | 571 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
563 | 572 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
564 | 573 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
565 | 574 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
566 | 575 | |
|
567 | 576 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
568 | 577 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
569 | 578 | if (i == 0) |
|
570 | 579 | { |
|
571 | 580 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; |
|
572 | 581 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); |
|
573 | 582 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); |
|
574 | 583 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
575 | 584 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
576 | 585 | } |
|
577 | 586 | else if (i == 6) |
|
578 | 587 | { |
|
579 | 588 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; |
|
580 | 589 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8); |
|
581 | 590 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 ); |
|
582 | 591 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); |
|
583 | 592 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); |
|
584 | 593 | } |
|
585 | 594 | else |
|
586 | 595 | { |
|
587 | 596 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; |
|
588 | 597 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); |
|
589 | 598 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); |
|
590 | 599 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
591 | 600 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
592 | 601 | } |
|
593 | 602 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
594 | 603 | // DATA FIELD HEADER |
|
595 | 604 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
596 | 605 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
597 | 606 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
598 | 607 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
599 | 608 | // AUXILIARY DATA HEADER |
|
600 | 609 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
601 | 610 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
602 | 611 | headerCWF[ i ].time[0] = 0x00; |
|
603 | 612 | headerCWF[ i ].time[0] = 0x00; |
|
604 | 613 | headerCWF[ i ].time[0] = 0x00; |
|
605 | 614 | headerCWF[ i ].time[0] = 0x00; |
|
606 | 615 | headerCWF[ i ].time[0] = 0x00; |
|
607 | 616 | headerCWF[ i ].time[0] = 0x00; |
|
608 | 617 | } |
|
609 | 618 | return LFR_SUCCESSFUL; |
|
610 | 619 | } |
|
611 | 620 | |
|
612 | 621 | void reset_waveforms( void ) |
|
613 | 622 | { |
|
614 | 623 | int i = 0; |
|
615 | 624 | |
|
616 | 625 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
617 | 626 | { |
|
618 | 627 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000; |
|
619 | 628 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; |
|
620 | 629 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; |
|
621 | 630 | |
|
622 | 631 | //*** |
|
623 | 632 | // F1 |
|
624 | 633 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000; |
|
625 | 634 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000; |
|
626 | 635 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; |
|
627 | 636 | |
|
628 | 637 | //*** |
|
629 | 638 | // F2 |
|
630 | 639 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000; |
|
631 | 640 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; |
|
632 | 641 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000; |
|
633 | 642 | |
|
634 | 643 | //*** |
|
635 | 644 | // F3 |
|
636 | 645 | /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1 |
|
637 | 646 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1 |
|
638 | 647 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/ |
|
639 | 648 | } |
|
640 | 649 | } |
|
641 | 650 | |
|
642 | 651 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
643 | 652 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
644 | 653 | { |
|
654 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
|
655 | * | |
|
656 | * @param waveform points to the buffer containing the data that will be send. | |
|
657 | * @param sid is the source identifier of the data that will be sent. | |
|
658 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
|
659 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
|
660 | * contain information to setup the transmission of the data packets. | |
|
661 | * | |
|
662 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
|
663 | * | |
|
664 | */ | |
|
665 | ||
|
645 | 666 | unsigned int i; |
|
646 | 667 | int ret; |
|
647 | 668 | rtems_status_code status; |
|
648 | 669 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
649 | 670 | |
|
650 | 671 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
651 | 672 | spw_ioctl_send_SWF.options = 0; |
|
652 | 673 | |
|
653 | 674 | ret = LFR_DEFAULT; |
|
654 | 675 | |
|
655 | 676 | for (i=0; i<7; i++) // send waveform |
|
656 | 677 | { |
|
657 | 678 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; |
|
658 | 679 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
659 | 680 | // BUILD THE DATA |
|
660 | 681 | if (i==6) { |
|
661 | 682 | spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK; |
|
662 | 683 | } |
|
663 | 684 | else { |
|
664 | 685 | spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK; |
|
665 | 686 | } |
|
666 | 687 | // SET PACKET TIME |
|
667 | 688 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
668 | 689 | headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
669 | 690 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
670 | 691 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
671 | 692 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
672 | 693 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
673 | 694 | headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
674 | 695 | headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
675 | 696 | headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
676 | 697 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
677 | 698 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
678 | 699 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
679 | 700 | // SEND PACKET |
|
680 | 701 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
681 | 702 | if (status != RTEMS_SUCCESSFUL) { |
|
682 | 703 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
683 | 704 | ret = LFR_DEFAULT; |
|
684 | 705 | } |
|
685 | 706 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
686 | 707 | } |
|
687 | 708 | |
|
688 | 709 | return ret; |
|
689 | 710 | } |
|
690 | 711 | |
|
691 | 712 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
692 | 713 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
693 | 714 | { |
|
715 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
|
716 | * | |
|
717 | * @param waveform points to the buffer containing the data that will be send. | |
|
718 | * @param sid is the source identifier of the data that will be sent. | |
|
719 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
|
720 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
|
721 | * contain information to setup the transmission of the data packets. | |
|
722 | * | |
|
723 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
|
724 | * | |
|
725 | */ | |
|
726 | ||
|
694 | 727 | unsigned int i; |
|
695 | 728 | int ret; |
|
696 | 729 | rtems_status_code status; |
|
697 | 730 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
698 | 731 | |
|
699 | 732 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
700 | 733 | spw_ioctl_send_CWF.options = 0; |
|
701 | 734 | |
|
702 | 735 | ret = LFR_DEFAULT; |
|
703 | 736 | |
|
704 | 737 | for (i=0; i<7; i++) // send waveform |
|
705 | 738 | { |
|
706 | 739 | int coarseTime = 0x00; |
|
707 | 740 | int fineTime = 0x00; |
|
708 | 741 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; |
|
709 | 742 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
710 | 743 | // BUILD THE DATA |
|
711 | 744 | if (i==6) { |
|
712 | 745 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK; |
|
713 | 746 | } |
|
714 | 747 | else { |
|
715 | 748 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK; |
|
716 | 749 | } |
|
717 | 750 | // SET PACKET TIME |
|
718 | 751 | coarseTime = time_management_regs->coarse_time; |
|
719 | 752 | fineTime = time_management_regs->fine_time; |
|
720 | 753 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
721 | 754 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
722 | 755 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
723 | 756 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
724 | 757 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
725 | 758 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
726 | 759 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
727 | 760 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
728 | 761 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
729 | 762 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
730 | 763 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
731 | 764 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
732 | 765 | // SEND PACKET |
|
733 | 766 | if (sid == SID_NORM_CWF_F3) |
|
734 | 767 | { |
|
735 | 768 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
736 | 769 | if (status != RTEMS_SUCCESSFUL) { |
|
737 | 770 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
738 | 771 | ret = LFR_DEFAULT; |
|
739 | 772 | } |
|
740 | 773 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
741 | 774 | } |
|
742 | 775 | else |
|
743 | 776 | { |
|
744 | 777 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
745 | 778 | if (status != RTEMS_SUCCESSFUL) { |
|
746 | 779 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
747 | 780 | ret = LFR_DEFAULT; |
|
748 | 781 | } |
|
749 | 782 | } |
|
750 | 783 | } |
|
751 | 784 | |
|
752 | 785 | return ret; |
|
753 | 786 | } |
|
754 | 787 | |
|
755 | 788 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
756 | 789 | { |
|
790 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
|
791 | * | |
|
792 | * @param waveform points to the buffer containing the data that will be send. | |
|
793 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
|
794 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
|
795 | * contain information to setup the transmission of the data packets. | |
|
796 | * | |
|
797 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
|
798 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
|
799 | * | |
|
800 | */ | |
|
801 | ||
|
757 | 802 | unsigned int i; |
|
758 | 803 | int ret; |
|
759 | 804 | rtems_status_code status; |
|
760 | 805 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
761 | 806 | char *sample; |
|
762 | 807 | |
|
763 | 808 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
764 | 809 | spw_ioctl_send_CWF.options = 0; |
|
765 | 810 | |
|
766 | 811 | ret = LFR_DEFAULT; |
|
767 | 812 | |
|
768 | 813 | //********************** |
|
769 | 814 | // BUILD CWF3_light DATA |
|
770 | 815 | for ( i=0; i< 2048; i++) |
|
771 | 816 | { |
|
772 | 817 | sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; |
|
773 | 818 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
774 | 819 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
775 | 820 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
776 | 821 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
777 | 822 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
778 | 823 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
779 | 824 | } |
|
780 | 825 | |
|
781 | 826 | //********************* |
|
782 | 827 | // SEND CWF3_light DATA |
|
783 | 828 | |
|
784 | 829 | for (i=0; i<7; i++) // send waveform |
|
785 | 830 | { |
|
786 | 831 | int coarseTime = 0x00; |
|
787 | 832 | int fineTime = 0x00; |
|
788 | 833 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
789 | 834 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
790 | 835 | // BUILD THE DATA |
|
791 | 836 | if ( i == WFRM_INDEX_OF_LAST_PACKET ) { |
|
792 | 837 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK; |
|
793 | 838 | } |
|
794 | 839 | else { |
|
795 | 840 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK; |
|
796 | 841 | } |
|
797 | 842 | // SET PACKET TIME |
|
798 | 843 | coarseTime = time_management_regs->coarse_time; |
|
799 | 844 | fineTime = time_management_regs->fine_time; |
|
800 | 845 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
801 | 846 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
802 | 847 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
803 | 848 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
804 | 849 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
805 | 850 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
806 | 851 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
807 | 852 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
808 | 853 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
809 | 854 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
810 | 855 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
811 | 856 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
812 | 857 | // SEND PACKET |
|
813 | 858 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
814 | 859 | if (status != RTEMS_SUCCESSFUL) { |
|
815 | 860 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
816 | 861 | ret = LFR_DEFAULT; |
|
817 | 862 | } |
|
818 | 863 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
819 | 864 | } |
|
820 | 865 | |
|
821 | 866 | return ret; |
|
822 | 867 | } |
|
823 | 868 | |
|
824 | 869 | |
|
825 | 870 | //************** |
|
826 | 871 | // wfp registers |
|
827 | 872 | void set_wfp_data_shaping() |
|
828 | 873 | { |
|
874 | /** This function sets the data_shaping register of the waveform picker module. | |
|
875 | * | |
|
876 | * The value is read from one field of the parameter_dump_packet structure:\n | |
|
877 | * bw_sp0_sp1_r0_r1 | |
|
878 | * | |
|
879 | */ | |
|
880 | ||
|
829 | 881 | unsigned char data_shaping; |
|
830 | 882 | |
|
831 | 883 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
832 | 884 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
833 | 885 | |
|
834 | 886 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
835 | 887 | |
|
836 | 888 | #ifdef GSA |
|
837 | 889 | #else |
|
838 | 890 | waveform_picker_regs->data_shaping = |
|
839 | 891 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
840 | 892 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
841 | 893 | + ( (data_shaping & 0x04) ) // SP1 |
|
842 | 894 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
843 | 895 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
844 | 896 | #endif |
|
845 | 897 | } |
|
846 | 898 | |
|
847 | 899 | char set_wfp_delta_snapshot() |
|
848 | 900 | { |
|
901 | /** This function sets the delta_snapshot register of the waveform picker module. | |
|
902 | * | |
|
903 | * The value is read from two (unsigned char) of the parameter_dump_packet structure:\n | |
|
904 | * sy_lfr_n_swf_p[0] \n | |
|
905 | * sy_lfr_n_swf_p[1] | |
|
906 | * | |
|
907 | */ | |
|
908 | ||
|
849 | 909 | char ret; |
|
850 | 910 | unsigned int delta_snapshot; |
|
851 | 911 | unsigned int aux; |
|
852 | 912 | |
|
853 | 913 | aux = 0; |
|
854 | 914 | ret = LFR_DEFAULT; |
|
855 | 915 | |
|
856 | 916 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
857 | 917 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
858 | 918 | |
|
859 | 919 | #ifdef GSA |
|
860 | 920 | #else |
|
861 | 921 | if ( delta_snapshot < MIN_DELTA_SNAPSHOT ) |
|
862 | 922 | { |
|
863 | 923 | aux = MIN_DELTA_SNAPSHOT; |
|
864 | 924 | ret = LFR_DEFAULT; |
|
865 | 925 | } |
|
866 | 926 | else |
|
867 | 927 | { |
|
868 | 928 | aux = delta_snapshot ; |
|
869 | 929 | ret = LFR_SUCCESSFUL; |
|
870 | 930 | } |
|
871 | 931 | waveform_picker_regs->delta_snapshot = aux; // max 2 bytes |
|
872 | 932 | #endif |
|
873 | 933 | |
|
874 | 934 | return ret; |
|
875 | 935 | } |
|
876 | 936 | |
|
877 | 937 | void set_wfp_burst_enable_register( unsigned char mode) |
|
878 | 938 | { |
|
939 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
|
940 | * | |
|
941 | * @param mode is the LFR mode to launch. | |
|
942 | * | |
|
943 | * The burst bits shall be before the enable bits. | |
|
944 | * | |
|
945 | */ | |
|
946 | ||
|
879 | 947 | #ifdef GSA |
|
880 | 948 | #else |
|
881 | 949 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
882 | 950 | // the burst bits shall be set first, before the enable bits |
|
883 | 951 | switch(mode) { |
|
884 | 952 | case(LFR_MODE_NORMAL): |
|
885 | 953 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable |
|
886 | 954 | waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
887 | 955 | break; |
|
888 | 956 | case(LFR_MODE_BURST): |
|
889 | 957 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
890 | 958 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2 |
|
891 | 959 | break; |
|
892 | 960 | case(LFR_MODE_SBM1): |
|
893 | 961 | waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
894 | 962 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
895 | 963 | break; |
|
896 | 964 | case(LFR_MODE_SBM2): |
|
897 | 965 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
898 | 966 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
899 | 967 | break; |
|
900 | 968 | default: |
|
901 | 969 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
902 | 970 | break; |
|
903 | 971 | } |
|
904 | 972 | #endif |
|
905 | 973 | } |
|
906 | 974 | |
|
907 | 975 | void reset_wfp_burst_enable() |
|
908 | 976 | { |
|
977 | /** This function resets the waveform picker burst_enable register. | |
|
978 | * | |
|
979 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
|
980 | * | |
|
981 | */ | |
|
982 | ||
|
909 | 983 | #ifdef GSA |
|
910 | 984 | #else |
|
911 | 985 | waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
912 | 986 | #endif |
|
913 | 987 | } |
|
914 | 988 | |
|
915 | 989 | void reset_wfp_status() |
|
916 | 990 | { |
|
991 | /** This function resets the waveform picker status register. | |
|
992 | * | |
|
993 | * All status bits are set to 0 [new_err full_err full]. | |
|
994 | * | |
|
995 | */ | |
|
996 | ||
|
917 | 997 | #ifdef GSA |
|
918 | 998 | #else |
|
919 | 999 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
920 | 1000 | #endif |
|
921 | 1001 | } |
|
922 | 1002 | |
|
923 | 1003 | void reset_waveform_picker_regs() |
|
924 | 1004 | { |
|
1005 | /** This function resets the waveform picker module registers. | |
|
1006 | * | |
|
1007 | * The registers affected by this function are located at the following offset addresses: | |
|
1008 | * - 0x00 data_shaping | |
|
1009 | * - 0x04 burst_enable | |
|
1010 | * - 0x08 addr_data_f0 | |
|
1011 | * - 0x0C addr_data_f1 | |
|
1012 | * - 0x10 addr_data_f2 | |
|
1013 | * - 0x14 addr_data_f3 | |
|
1014 | * - 0x18 status | |
|
1015 | * - 0x1C delta_snapshot | |
|
1016 | * - 0x20 delta_f2_f1 | |
|
1017 | * - 0x24 delta_f2_f0 | |
|
1018 | * - 0x28 nb_burst | |
|
1019 | * - 0x2C nb_snapshot | |
|
1020 | * | |
|
1021 | */ | |
|
1022 | ||
|
925 | 1023 | #ifdef GSA |
|
926 | 1024 | #else |
|
927 | 1025 | set_wfp_data_shaping(); |
|
928 | 1026 | reset_wfp_burst_enable(); |
|
929 | 1027 | waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // |
|
930 | 1028 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // |
|
931 | 1029 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // |
|
932 | 1030 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // |
|
933 | 1031 | set_wfp_delta_snapshot(); // time in seconds between two snapshots |
|
934 | 1032 | waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes) |
|
935 | 1033 | waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes) |
|
936 | 1034 | waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets) |
|
937 | 1035 | waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1 |
|
938 | 1036 | waveform_picker_regs->status = 0x00; // |
|
939 | 1037 | #endif |
|
940 | 1038 | } |
|
941 | 1039 | |
|
942 | 1040 | //***************** |
|
943 | 1041 | // local parameters |
|
944 | 1042 | void set_local_sbm1_nb_cwf_max() |
|
945 | 1043 | { |
|
946 | // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot) | |
|
1044 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. | |
|
1045 | * | |
|
1046 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n | |
|
1047 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n | |
|
1048 | * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot) | |
|
1049 | * | |
|
1050 | */ | |
|
947 | 1051 | param_local.local_sbm1_nb_cwf_max = 2 * |
|
948 | 1052 | (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 |
|
949 | 1053 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2 |
|
950 | 1054 | } |
|
951 | 1055 | |
|
952 | 1056 | void set_local_sbm2_nb_cwf_max() |
|
953 | 1057 | { |
|
954 | // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz) | |
|
1058 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. | |
|
1059 | * | |
|
1060 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n | |
|
1061 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n | |
|
1062 | * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz) | |
|
1063 | * | |
|
1064 | */ | |
|
1065 | ||
|
955 | 1066 | param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 |
|
956 | 1067 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8; |
|
957 | 1068 | } |
|
958 | 1069 | |
|
959 | 1070 | void set_local_nb_interrupt_f0_MAX() |
|
960 | 1071 | { |
|
1072 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. | |
|
1073 | * | |
|
1074 | * This parameter is used for the SM validation only.\n | |
|
1075 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices | |
|
1076 | * module before launching a basic processing. | |
|
1077 | * | |
|
1078 | */ | |
|
1079 | ||
|
961 | 1080 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 |
|
962 | 1081 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; |
|
963 | 1082 | } |
|
964 | 1083 | |
|
965 | 1084 | void reset_local_sbm1_nb_cwf_sent() |
|
966 | 1085 | { |
|
1086 | /** This function resets the value of the sbm1_nb_cwf_sent local parameter. | |
|
1087 | * | |
|
1088 | * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n | |
|
1089 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active. | |
|
1090 | * | |
|
1091 | */ | |
|
1092 | ||
|
967 | 1093 | param_local.local_sbm1_nb_cwf_sent = 0; |
|
968 | 1094 | } |
|
969 | 1095 | |
|
970 | 1096 | void reset_local_sbm2_nb_cwf_sent() |
|
971 | 1097 | { |
|
1098 | /** This function resets the value of the sbm2_nb_cwf_sent local parameter. | |
|
1099 | * | |
|
1100 | * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n | |
|
1101 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active. | |
|
1102 | * | |
|
1103 | */ | |
|
1104 | ||
|
972 | 1105 | param_local.local_sbm2_nb_cwf_sent = 0; |
|
973 | 1106 | } |
General Comments 0
You need to be logged in to leave comments.
Login now