##// END OF EJS Templates
avf2 prc2 tasks added...
paul -
r124:9657f56b7e43 VHDLib206
parent child
Show More
@@ -0,0 +1,358
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf0_prc0.h"
11
12 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
13 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
15 ring_node_asm *current_ring_node_asm_norm_f0;
16
17 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
20 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
21
22 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
23
24 void reset_nb_sm_f0( unsigned char lfrMode )
25 {
26 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
27 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
28 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
29 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
30 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
31 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
32 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
33 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
34 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
35
36 if (lfrMode == LFR_MODE_SBM1)
37 {
38 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
39 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
40 }
41 else if (lfrMode == LFR_MODE_SBM2)
42 {
43 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
44 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
45 }
46 else if (lfrMode == LFR_MODE_BURST)
47 {
48 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
49 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
50 }
51 else
52 {
53 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
54 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
55 }
56 }
57
58 //************
59 // RTEMS TASKS
60
61 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
62 {
63 int i;
64
65 rtems_event_set event_out;
66 rtems_status_code status;
67 rtems_id queue_id_prc0;
68 asm_msg msgForMATR;
69 ring_node_sm *ring_node_tab[8];
70
71 unsigned int nb_norm_bp1;
72 unsigned int nb_norm_bp2;
73 unsigned int nb_norm_asm;
74 unsigned int nb_sbm_bp1;
75 unsigned int nb_sbm_bp2;
76
77 nb_norm_bp1 = 0;
78 nb_norm_bp2 = 0;
79 nb_norm_asm = 0;
80 nb_sbm_bp1 = 0;
81 nb_sbm_bp2 = 0;
82
83 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
84 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
85 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
86 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
87 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
88
89 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
90
91 status = get_message_queue_id_prc0( &queue_id_prc0 );
92 if (status != RTEMS_SUCCESSFUL)
93 {
94 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
95 }
96
97 while(1){
98 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
99 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
100 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
101 {
102 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
103 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
104 }
105
106 // compute the average and store it in the averaged_sm_f1 buffer
107 SM_average( current_ring_node_asm_norm_f0->matrix,
108 current_ring_node_asm_burst_sbm_f0->matrix,
109 ring_node_tab,
110 nb_norm_bp1, nb_sbm_bp1 );
111
112 // update nb_average
113 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
114 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
115 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
116 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
117 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
118
119 //****************************************
120 // initialize the mesage for the MATR task
121 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
122 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
123 msgForMATR.norm = current_ring_node_asm_norm_f0;
124 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
125 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
126 msgForMATR.coarseTime = time_management_regs->coarse_time;
127 msgForMATR.fineTime = time_management_regs->fine_time;
128
129 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
130 {
131 nb_sbm_bp1 = 0;
132 // set another ring for the ASM storage
133 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
134 if ( (lfrCurrentMode == LFR_MODE_BURST)
135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
136 {
137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
138 }
139 }
140
141 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
142 {
143 nb_sbm_bp2 = 0;
144 if ( (lfrCurrentMode == LFR_MODE_BURST)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
148 }
149 }
150
151 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
152 {
153 nb_norm_bp1 = 0;
154 // set another ring for the ASM storage
155 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
156 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
157 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
158 {
159 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
160 }
161 }
162
163 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
164 {
165 nb_norm_bp2 = 0;
166 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
167 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
168 {
169 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
170 }
171 }
172
173 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
174 {
175 nb_norm_asm = 0;
176 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
177 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
178 {
179 // PRINTF1("%lld\n", localTime)
180 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
181 }
182 }
183
184 //*************************
185 // send the message to MATR
186 if (msgForMATR.event != 0x00)
187 {
188 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
189 }
190
191 if (status != RTEMS_SUCCESSFUL) {
192 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
193 }
194 }
195 }
196
197 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
198 {
199 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
200 size_t size; // size of the incoming TC packet
201 asm_msg *incomingMsg;
202 //
203 spw_ioctl_pkt_send spw_ioctl_send_ASM;
204 rtems_status_code status;
205 rtems_id queue_id;
206 rtems_id queue_id_q_p0;
207 Header_TM_LFR_SCIENCE_ASM_t headerASM;
208 bp_packet_with_spare packet_norm_bp1_f0;
209 bp_packet packet_norm_bp2_f0;
210 bp_packet packet_sbm_bp1_f0;
211 bp_packet packet_sbm_bp2_f0;
212
213 unsigned long long int localTime;
214
215 ASM_init_header( &headerASM );
216
217 //*************
218 // NORM headers
219 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
222 BP_init_header( &packet_norm_bp2_f0.header,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
224 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
225
226 //****************************
227 // BURST SBM1 and SBM2 headers
228 if ( lfrRequestedMode == LFR_MODE_BURST )
229 {
230 BP_init_header( &packet_sbm_bp1_f0.header,
231 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
233 BP_init_header( &packet_sbm_bp2_f0.header,
234 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
235 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
236 }
237 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
238 {
239 BP_init_header( &packet_sbm_bp1_f0.header,
240 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
241 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
242 BP_init_header( &packet_sbm_bp2_f0.header,
243 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
244 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
245 }
246 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
247 {
248 BP_init_header( &packet_sbm_bp1_f0.header,
249 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
250 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
251 BP_init_header( &packet_sbm_bp2_f0.header,
252 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
253 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
254 }
255 else
256 {
257 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
258 }
259
260 status = get_message_queue_id_send( &queue_id );
261 if (status != RTEMS_SUCCESSFUL)
262 {
263 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
264 }
265 status = get_message_queue_id_prc0( &queue_id_q_p0);
266 if (status != RTEMS_SUCCESSFUL)
267 {
268 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
269 }
270
271 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
272
273 while(1){
274 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
275 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
276
277 incomingMsg = (asm_msg*) incomingData;
278
279 localTime = getTimeAsUnsignedLongLongInt( );
280 //****************
281 //****************
282 // BURST SBM1 SBM2
283 //****************
284 //****************
285 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
286 {
287 // 1) compress the matrix for Basic Parameters calculation
288 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
289 nb_sm_before_f0.burst_sbm_bp1,
290 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
291 ASM_F0_INDICE_START);
292 // 2) compute the BP1 set
293
294 // 3) send the BP1 set
295 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
297 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
299 // 4) compute the BP2 set if needed
300 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
301 {
302 // 1) compute the BP2 set
303
304 // 2) send the BP2 set
305 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
307 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
308 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
309 }
310 }
311
312 //*****
313 //*****
314 // NORM
315 //*****
316 //*****
317 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
318 {
319 // 1) compress the matrix for Basic Parameters calculation
320 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
321 nb_sm_before_f0.norm_bp1,
322 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
323 ASM_F0_INDICE_START );
324 // 2) compute the BP1 set
325
326 // 3) send the BP1 set
327 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
328 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
329 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
331 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
332 {
333 // 1) compute the BP2 set using the same ASM as the one used for BP1
334
335 // 2) send the BP2 set
336 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
337 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
338 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
339 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
340 }
341 }
342
343 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
344 {
345 // 1) reorganize the ASM and divide
346 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
347 asm_f0_reorganized,
348 nb_sm_before_f0.norm_bp1 );
349 // 2) convert the float array in a char array
350 ASM_convert( asm_f0_reorganized, asm_f0_char);
351 // 3) send the spectral matrix packets
352 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
353 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
354 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
355 }
356
357 }
358 }
@@ -0,0 +1,30
1 #ifndef AVF0_PRC0_H
2 #define AVF0_PRC0_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
14 unsigned int sbm1_bp1;
15 unsigned int sbm1_bp2;
16 unsigned int sbm2_bp1;
17 unsigned int sbm2_bp2;
18 } nb_sm_before_bp_asm_f0;
19
20 extern struct ring_node_sm *current_ring_node_sm_f0;
21 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
22
23 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
24
25 void reset_nb_sm_f0( unsigned char lfrMode );
26
27 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
28 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
29
30 #endif // AVF0_PRC0_H
@@ -0,0 +1,339
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf1_prc1.h"
11
12 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
13 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
15 ring_node_asm *current_ring_node_asm_norm_f1;
16
17 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
20 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
21
22 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
23
24 void reset_nb_sm_f1( unsigned char lfrMode )
25 {
26 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
27 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
28 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
29 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
30 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
31 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
32 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
33
34 if (lfrMode == LFR_MODE_SBM2)
35 {
36 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
37 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
38 }
39 else if (lfrMode == LFR_MODE_BURST)
40 {
41 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
42 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
43 }
44 else
45 {
46 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
47 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
48 }
49 }
50
51 //************
52 // RTEMS TASKS
53
54 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
55 {
56 int i;
57
58 rtems_event_set event_out;
59 rtems_status_code status;
60 rtems_id queue_id_prc1;
61 asm_msg msgForMATR;
62 ring_node_sm *ring_node_tab[8];
63
64 unsigned int nb_norm_bp1;
65 unsigned int nb_norm_bp2;
66 unsigned int nb_norm_asm;
67 unsigned int nb_sbm_bp1;
68 unsigned int nb_sbm_bp2;
69
70 nb_norm_bp1 = 0;
71 nb_norm_bp2 = 0;
72 nb_norm_asm = 0;
73 nb_sbm_bp1 = 0;
74 nb_sbm_bp2 = 0;
75
76 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
77 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
78 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
79 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
80 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
81
82 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
83
84 status = get_message_queue_id_prc1( &queue_id_prc1 );
85 if (status != RTEMS_SUCCESSFUL)
86 {
87 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
88 }
89
90 while(1){
91 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
92 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
93 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
94 {
95 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
96 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
97 }
98
99 // compute the average and store it in the averaged_sm_f1 buffer
100 SM_average( current_ring_node_asm_norm_f1->matrix,
101 current_ring_node_asm_burst_sbm_f1->matrix,
102 ring_node_tab,
103 nb_norm_bp1, nb_sbm_bp1 );
104
105 // update nb_average
106 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
107 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
108 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
110 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
111
112 //****************************************
113 // initialize the mesage for the MATR task
114 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
115 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
116 msgForMATR.norm = current_ring_node_asm_norm_f1;
117 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
118 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
119 msgForMATR.coarseTime = time_management_regs->coarse_time;
120 msgForMATR.fineTime = time_management_regs->fine_time;
121
122 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
123 {
124 nb_sbm_bp1 = 0;
125 // set another ring for the ASM storage
126 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
127 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
128 {
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
130 }
131 }
132
133 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
134 {
135 nb_sbm_bp2 = 0;
136 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
137 {
138 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
139 }
140 }
141
142 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
143 {
144 nb_norm_bp1 = 0;
145 // set another ring for the ASM storage
146 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 {
150 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
151 }
152 }
153
154 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
155 {
156 nb_norm_bp2 = 0;
157 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 {
160 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
161 }
162 }
163
164 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
165 {
166 nb_norm_asm = 0;
167 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
168 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
169 {
170 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
171 }
172 }
173
174 //*************************
175 // send the message to MATR
176 if (msgForMATR.event != 0x00)
177 {
178 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
179 }
180
181 if (status != RTEMS_SUCCESSFUL) {
182 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
183 }
184 }
185 }
186
187 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
188 {
189 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
190 size_t size; // size of the incoming TC packet
191 asm_msg *incomingMsg;
192 //
193 spw_ioctl_pkt_send spw_ioctl_send_ASM;
194 rtems_status_code status;
195 rtems_id queue_id_send;
196 rtems_id queue_id_q_p1;
197 Header_TM_LFR_SCIENCE_ASM_t headerASM;
198 bp_packet_with_spare packet_norm_bp1;
199 bp_packet packet_norm_bp2;
200 bp_packet packet_sbm_bp1;
201 bp_packet packet_sbm_bp2;
202
203 unsigned long long int localTime;
204
205 ASM_init_header( &headerASM );
206
207 //*************
208 // NORM headers
209 BP_init_header_with_spare( &packet_norm_bp1.header,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
211 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
212 BP_init_header( &packet_norm_bp2.header,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
214 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
215
216 //***********************
217 // BURST and SBM2 headers
218 if ( lfrRequestedMode == LFR_MODE_BURST )
219 {
220 BP_init_header( &packet_sbm_bp1.header,
221 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
223 BP_init_header( &packet_sbm_bp2.header,
224 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
225 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
226 }
227 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
228 {
229 BP_init_header( &packet_sbm_bp1.header,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
232 BP_init_header( &packet_sbm_bp2.header,
233 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
234 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
235 }
236 else
237 {
238 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
239 }
240
241 status = get_message_queue_id_send( &queue_id_send );
242 if (status != RTEMS_SUCCESSFUL)
243 {
244 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
245 }
246 status = get_message_queue_id_prc1( &queue_id_q_p1);
247 if (status != RTEMS_SUCCESSFUL)
248 {
249 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
250 }
251
252 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
253
254 while(1){
255 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
256 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
257
258 incomingMsg = (asm_msg*) incomingData;
259
260 localTime = getTimeAsUnsignedLongLongInt( );
261 //***********
262 //***********
263 // BURST SBM2
264 //***********
265 //***********
266 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
267 {
268 // 1) compress the matrix for Basic Parameters calculation
269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
270 nb_sm_before_f1.burst_sbm_bp1,
271 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
272 ASM_F1_INDICE_START);
273 // 2) compute the BP1 set
274
275 // 3) send the BP1 set
276 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
278 BP_send( (char *) &packet_sbm_bp1.header, queue_id_send,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA);
280 // 4) compute the BP2 set if needed
281 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
282 {
283 // 1) compute the BP2 set
284
285 // 2) send the BP2 set
286 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
288 BP_send( (char *) &packet_sbm_bp2.header, queue_id_send,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA);
290 }
291 }
292
293 //*****
294 //*****
295 // NORM
296 //*****
297 //*****
298 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
299 {
300 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
302 nb_sm_before_f1.norm_bp1,
303 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 ASM_F0_INDICE_START );
305 // 2) compute the BP1 set
306
307 // 3) send the BP1 set
308 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
309 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
310 BP_send( (char *) &packet_norm_bp1.header, queue_id_send,
311 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA);
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
313 {
314 // 1) compute the BP2 set
315
316 // 2) send the BP2 set
317 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
318 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
319 BP_send( (char *) &packet_norm_bp2.header, queue_id_send,
320 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA);
321 }
322 }
323
324 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
325 {
326 // 1) reorganize the ASM and divide
327 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
328 asm_f1_reorganized,
329 nb_sm_before_f1.norm_bp1 );
330 // 2) convert the float array in a char array
331 ASM_convert( asm_f1_reorganized, asm_f1_char);
332 // 3) send the spectral matrix packets
333 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
334 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
335 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
336 }
337
338 }
339 }
@@ -0,0 +1,28
1 #ifndef AVF1_PRC1_H
2 #define AVF1_PRC1_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
14 unsigned int sbm2_bp1;
15 unsigned int sbm2_bp2;
16 } nb_sm_before_bp_asm_f1;
17
18 extern struct ring_node_sm *current_ring_node_sm_f1;
19 extern struct ring_node_sm *ring_node_for_averaging_sm_f1;
20
21 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
22
23 void reset_nb_sm_f1( unsigned char lfrMode );
24
25 rtems_task avf1_task( rtems_task_argument lfrRequestedMode );
26 rtems_task prc1_task( rtems_task_argument lfrRequestedMode );
27
28 #endif // AVF1_PRC1_H
@@ -0,0 +1,240
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing at f2 = 256 Hz, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "avf2_prc2.h"
11
12 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
13 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f2;
15 ring_node_asm *current_ring_node_asm_norm_f2;
16
17 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
20 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
21
22 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
23
24 void reset_nb_sm_f2( void )
25 {
26 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
27 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
28 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
29 }
30
31 void SM_average_f2( float *averaged_spec_mat_f2,
32 ring_node_sm *ring_node,
33 unsigned int nbAverageNormF2 )
34 {
35 float sum;
36 unsigned int i;
37
38 for(i=0; i<TOTAL_SIZE_SM; i++)
39 {
40 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
41 if ( (nbAverageNormF2 == 0) )
42 {
43 averaged_spec_mat_f2[ i ] = sum;
44 }
45 else
46 {
47 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
48 }
49 }
50 }
51
52 //************
53 // RTEMS TASKS
54
55 rtems_task avf2_task( rtems_task_argument lfrRequestedMode )
56 {
57 rtems_event_set event_out;
58 rtems_status_code status;
59 rtems_id queue_id_prc2;
60 asm_msg msgForMATR;
61
62 unsigned int nb_norm_bp1;
63 unsigned int nb_norm_bp2;
64 unsigned int nb_norm_asm;
65
66 nb_norm_bp1 = 0;
67 nb_norm_bp2 = 0;
68 nb_norm_asm = 0;
69
70 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
71
72 BOOT_PRINTF1("in AVF2 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
73
74 status = get_message_queue_id_prc2( &queue_id_prc2 );
75 if (status != RTEMS_SUCCESSFUL)
76 {
77 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
78 }
79
80 while(1){
81 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
82
83 // compute the average and store it in the averaged_sm_f2 buffer
84 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
85 ring_node_for_averaging_sm_f2,
86 nb_norm_bp1 );
87
88 // update nb_average
89 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
90 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
91 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
92
93 //****************************************
94 // initialize the mesage for the MATR task
95 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
96 msgForMATR.burst_sbm = NULL;
97 msgForMATR.norm = current_ring_node_asm_norm_f2;
98 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
99 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
100 msgForMATR.coarseTime = time_management_regs->coarse_time;
101 msgForMATR.fineTime = time_management_regs->fine_time;
102
103 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
104 {
105 nb_norm_bp1 = 0;
106 // set another ring for the ASM storage
107 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
108 if ( lfrCurrentMode == LFR_MODE_NORMAL )
109 {
110 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
111 }
112 }
113
114 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
115 {
116 nb_norm_bp2 = 0;
117 if ( lfrCurrentMode == LFR_MODE_NORMAL )
118 {
119 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
120 }
121 }
122
123 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
124 {
125 nb_norm_asm = 0;
126 if ( lfrCurrentMode == LFR_MODE_NORMAL )
127 {
128 // PRINTF1("%lld\n", localTime)
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
130 }
131 }
132
133 //*************************
134 // send the message to MATR
135 if (msgForMATR.event != 0x00)
136 {
137 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
138 }
139
140 if (status != RTEMS_SUCCESSFUL) {
141 printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
142 }
143 }
144 }
145
146 rtems_task prc2_task( rtems_task_argument argument )
147 {
148 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
149 size_t size; // size of the incoming TC packet
150 asm_msg *incomingMsg;
151 //
152 spw_ioctl_pkt_send spw_ioctl_send_ASM;
153 rtems_status_code status;
154 rtems_id queue_id;
155 rtems_id queue_id_q_p2;
156 Header_TM_LFR_SCIENCE_ASM_t headerASM;
157 bp_packet packet_norm_bp1_f2;
158 bp_packet packet_norm_bp2_f2;
159
160 unsigned long long int localTime;
161
162 ASM_init_header( &headerASM );
163
164 //*************
165 // NORM headers
166 BP_init_header( &packet_norm_bp1_f2.header,
167 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
168 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
169 BP_init_header( &packet_norm_bp2_f2.header,
170 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
171 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
172
173 status = get_message_queue_id_send( &queue_id );
174 if (status != RTEMS_SUCCESSFUL)
175 {
176 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
177 }
178 status = get_message_queue_id_prc2( &queue_id_q_p2);
179 if (status != RTEMS_SUCCESSFUL)
180 {
181 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
182 }
183
184 BOOT_PRINTF("in PRC2 ***\n")
185
186 while(1){
187 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
188 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
189
190 incomingMsg = (asm_msg*) incomingData;
191
192 localTime = getTimeAsUnsignedLongLongInt( );
193
194 //*****
195 //*****
196 // NORM
197 //*****
198 //*****
199 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
200 {
201 // 1) compress the matrix for Basic Parameters calculation
202 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
203 nb_sm_before_f2.norm_bp1,
204 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
205 ASM_F2_INDICE_START );
206 // 2) compute the BP1 set
207
208 // 3) send the BP1 set
209 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
210 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
211 BP_send( (char *) &packet_norm_bp1_f2.header, queue_id,
212 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA);
213 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
214 {
215 // 1) compute the BP2 set using the same ASM as the one used for BP1
216
217 // 2) send the BP2 set
218 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
219 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
220 BP_send( (char *) &packet_norm_bp2_f2.header, queue_id,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA);
222 }
223 }
224
225 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
226 {
227 // 1) reorganize the ASM and divide
228 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
229 asm_f2_reorganized,
230 nb_sm_before_f2.norm_bp1 );
231 // 2) convert the float array in a char array
232 ASM_convert( asm_f2_reorganized, asm_f2_char);
233 // 3) send the spectral matrix packets
234 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
235 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
236 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
237 }
238
239 }
240 }
@@ -0,0 +1,24
1 #ifndef AVF2_PRC2_H
2 #define AVF2_PRC2_H
3
4 #include "fsw_processing.h"
5
6 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
10 } nb_sm_before_bp_asm_f2;
11
12 extern struct ring_node_sm *current_ring_node_sm_f2;
13 extern struct ring_node_sm *ring_node_for_averaging_sm_f2;
14
15 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
16
17 void reset_nb_sm_f2(void );
18 void SM_average_f2( float *averaged_spec_mat_f2, ring_node_sm *ring_node, unsigned int nbAverageNormF2 );
19
20 // RTEMS TASKS
21 rtems_task avf2_task( rtems_task_argument lfrRequestedMode );
22 rtems_task prc2_task(rtems_task_argument argument );
23
24 #endif // AVF2_PRC2_H
This diff has been collapsed as it changes many lines, (570 lines changed) Show them Hide them
@@ -0,0 +1,570
1 /** Functions related to data processing.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
8 */
9
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
12
13 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f0_aux_f2;
17
18 //************************
19 // spectral matrices rings
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 ring_node_sm *current_ring_node_sm_f0;
24 ring_node_sm *current_ring_node_sm_f1;
25 ring_node_sm *current_ring_node_sm_f2;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
29
30 //***********************************************************
31 // Interrupt Service Routine for spectral matrices processing
32
33 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
34 {
35 ring_node_sm *previous_ring_node_sm_f0;
36
37 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
38
39 previous_ring_node_sm_f0 = current_ring_node_sm_f0;
40
41 if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
42 {
43 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
44 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
45 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
46 nb_sm_f0 = nb_sm_f0 + 1;
47 }
48
49 //************************
50 // reset status error bits
51 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
52 {
53 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
54 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
55 }
56
57 //**************************************
58 // reset ready matrix bits for f0_0, f1 and f2
59 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
60
61 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
62 {
63 ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
64 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
65 {
66 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
67 }
68 nb_sm_f0 = 0;
69 }
70
71 }
72
73 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
74 {
75 //***
76 // F0
77 nb_sm_f0 = nb_sm_f0 + 1;
78 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
79 {
80 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
81 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
82 {
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
84 }
85 nb_sm_f0 = 0;
86 }
87
88 //***
89 // F1
90 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
91 if (nb_sm_f0_aux_f1 == 6)
92 {
93 nb_sm_f0_aux_f1 = 0;
94 nb_sm_f1 = nb_sm_f1 + 1;
95 }
96 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
97 {
98 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
99 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
100 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
102 }
103 nb_sm_f1 = 0;
104 }
105
106 //***
107 // F2
108 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
109 if (nb_sm_f0_aux_f2 == 96)
110 {
111 nb_sm_f0_aux_f2 = 0;
112 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
113 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
114 {
115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
116 }
117 }
118 }
119
120 //******************
121 // Spectral Matrices
122
123 void reset_nb_sm( void )
124 {
125 nb_sm_f0 = 0;
126 nb_sm_f0_aux_f1 = 0;
127 nb_sm_f0_aux_f2 = 0;
128
129 nb_sm_f1 = 0;
130 }
131
132 void SM_init_rings( void )
133 {
134 unsigned char i;
135
136 // F0 RING
137 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
138 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
139 sm_ring_f0[0].buffer_address =
140 (int) &sm_f0[ 0 ];
141
142 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
143 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
144 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
145 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
146
147 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
148 {
149 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
150 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
151 sm_ring_f0[i].buffer_address =
152 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
153 }
154
155 // F1 RING
156 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
157 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
158 sm_ring_f1[0].buffer_address =
159 (int) &sm_f1[ 0 ];
160
161 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
162 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
163 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
164 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
165
166 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
167 {
168 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
169 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
170 sm_ring_f1[i].buffer_address =
171 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
172 }
173
174 // F2 RING
175 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
176 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
177 sm_ring_f2[0].buffer_address =
178 (int) &sm_f2[ 0 ];
179
180 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
181 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
182 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
183 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
184
185 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
186 {
187 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
188 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
189 sm_ring_f2[i].buffer_address =
190 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
191 }
192
193 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
194 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
195 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
196
197 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
198 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
199 }
200
201 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
202 {
203 unsigned char i;
204
205 ring[ nbNodes - 1 ].next
206 = (ring_node_asm*) &ring[ 0 ];
207
208 for(i=0; i<nbNodes-1; i++)
209 {
210 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
211 }
212 }
213
214 void SM_reset_current_ring_nodes( void )
215 {
216 current_ring_node_sm_f0 = sm_ring_f0;
217 current_ring_node_sm_f1 = sm_ring_f1;
218 current_ring_node_sm_f2 = sm_ring_f2;
219
220 ring_node_for_averaging_sm_f0 = sm_ring_f0;
221 }
222
223 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
224 {
225 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
226 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
227 header->reserved = 0x00;
228 header->userApplication = CCSDS_USER_APP;
229 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
230 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
231 header->packetSequenceControl[0] = 0xc0;
232 header->packetSequenceControl[1] = 0x00;
233 header->packetLength[0] = 0x00;
234 header->packetLength[1] = 0x00;
235 // DATA FIELD HEADER
236 header->spare1_pusVersion_spare2 = 0x10;
237 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
238 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
239 header->destinationID = TM_DESTINATION_ID_GROUND;
240 // AUXILIARY DATA HEADER
241 header->sid = 0x00;
242 header->biaStatusInfo = 0x00;
243 header->pa_lfr_pkt_cnt_asm = 0x00;
244 header->pa_lfr_pkt_nr_asm = 0x00;
245 header->time[0] = 0x00;
246 header->time[0] = 0x00;
247 header->time[0] = 0x00;
248 header->time[0] = 0x00;
249 header->time[0] = 0x00;
250 header->time[0] = 0x00;
251 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
252 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
253 }
254
255 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
256 ring_node_sm *ring_node_tab[],
257 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
258 {
259 float sum;
260 unsigned int i;
261
262 for(i=0; i<TOTAL_SIZE_SM; i++)
263 {
264 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
265 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
266 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
267 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
268 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
269 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
270 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
271 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
272
273 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
274 {
275 averaged_spec_mat_f0[ i ] = sum;
276 averaged_spec_mat_f1[ i ] = sum;
277 }
278 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
279 {
280 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
281 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
282 }
283 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
284 {
285 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
286 averaged_spec_mat_f1[ i ] = sum;
287 }
288 else
289 {
290 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
291 }
292 }
293 }
294
295 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
296 {
297 int frequencyBin;
298 int asmComponent;
299 unsigned int offsetAveragedSpecMatReorganized;
300 unsigned int offsetAveragedSpecMat;
301
302 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
303 {
304 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
305 {
306 offsetAveragedSpecMatReorganized =
307 frequencyBin * NB_VALUES_PER_SM
308 + asmComponent;
309 offsetAveragedSpecMat =
310 asmComponent * NB_BINS_PER_SM
311 + frequencyBin;
312 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
313 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
314 }
315 }
316 }
317
318 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
319 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
320 {
321 int frequencyBin;
322 int asmComponent;
323 int offsetASM;
324 int offsetCompressed;
325 int k;
326
327 // build data
328 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
329 {
330 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
331 {
332 offsetCompressed = // NO TIME OFFSET
333 frequencyBin * NB_VALUES_PER_SM
334 + asmComponent;
335 offsetASM = // NO TIME OFFSET
336 asmComponent * NB_BINS_PER_SM
337 + ASMIndexStart
338 + frequencyBin * nbBinsToAverage;
339 compressed_spec_mat[ offsetCompressed ] = 0;
340 for ( k = 0; k < nbBinsToAverage; k++ )
341 {
342 compressed_spec_mat[offsetCompressed ] =
343 ( compressed_spec_mat[ offsetCompressed ]
344 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
345 }
346 }
347 }
348 }
349
350 void ASM_convert( volatile float *input_matrix, char *output_matrix)
351 {
352 unsigned int frequencyBin;
353 unsigned int asmComponent;
354 char * pt_char_input;
355 char * pt_char_output;
356 unsigned int offsetInput;
357 unsigned int offsetOutput;
358
359 pt_char_input = (char*) &input_matrix;
360 pt_char_output = (char*) &output_matrix;
361
362 // convert all other data
363 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
364 {
365 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
366 {
367 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
368 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
369 pt_char_input = (char*) &input_matrix [ offsetInput ];
370 pt_char_output = (char*) &output_matrix[ offsetOutput ];
371 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
372 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
373 }
374 }
375 }
376
377 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
378 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
379 {
380 unsigned int i;
381 unsigned int length = 0;
382 rtems_status_code status;
383
384 for (i=0; i<2; i++)
385 {
386 // (1) BUILD THE DATA
387 switch(sid)
388 {
389 case SID_NORM_ASM_F0:
390 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
391 spw_ioctl_send->data = &spectral_matrix[
392 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
393 ];
394 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
395 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
396 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
397 break;
398 case SID_NORM_ASM_F1:
399 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
400 spw_ioctl_send->data = &spectral_matrix[
401 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
402 ];
403 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
404 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
405 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
406 break;
407 case SID_NORM_ASM_F2:
408 break;
409 default:
410 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
411 break;
412 }
413 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
414 spw_ioctl_send->hdr = (char *) header;
415 spw_ioctl_send->options = 0;
416
417 // (2) BUILD THE HEADER
418 header->packetLength[0] = (unsigned char) (length>>8);
419 header->packetLength[1] = (unsigned char) (length);
420 header->sid = (unsigned char) sid; // SID
421 header->pa_lfr_pkt_cnt_asm = 2;
422 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
423
424 // (3) SET PACKET TIME
425 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
426 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
427 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
428 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
429 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
430 header->time[5] = (unsigned char) (time_management_regs->fine_time);
431 //
432 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
433 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
434 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
435 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
436 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
437 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
438
439 // (4) SEND PACKET
440 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
441 if (status != RTEMS_SUCCESSFUL) {
442 printf("in ASM_send *** ERR %d\n", (int) status);
443 }
444 }
445 }
446
447 //*****************
448 // Basic Parameters
449
450 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
451 unsigned int apid, unsigned char sid,
452 unsigned int packetLength, unsigned char blkNr )
453 {
454 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
455 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
456 header->reserved = 0x00;
457 header->userApplication = CCSDS_USER_APP;
458 header->packetID[0] = (unsigned char) (apid >> 8);
459 header->packetID[1] = (unsigned char) (apid);
460 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
461 header->packetSequenceControl[1] = 0x00;
462 header->packetLength[0] = (unsigned char) (packetLength >> 8);
463 header->packetLength[1] = (unsigned char) (packetLength);
464 // DATA FIELD HEADER
465 header->spare1_pusVersion_spare2 = 0x10;
466 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
467 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
468 header->destinationID = TM_DESTINATION_ID_GROUND;
469 // AUXILIARY DATA HEADER
470 header->sid = sid;
471 header->biaStatusInfo = 0x00;
472 header->time[0] = 0x00;
473 header->time[0] = 0x00;
474 header->time[0] = 0x00;
475 header->time[0] = 0x00;
476 header->time[0] = 0x00;
477 header->time[0] = 0x00;
478 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
479 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
480 }
481
482 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
483 unsigned int apid, unsigned char sid,
484 unsigned int packetLength , unsigned char blkNr)
485 {
486 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
487 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
488 header->reserved = 0x00;
489 header->userApplication = CCSDS_USER_APP;
490 header->packetID[0] = (unsigned char) (apid >> 8);
491 header->packetID[1] = (unsigned char) (apid);
492 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
493 header->packetSequenceControl[1] = 0x00;
494 header->packetLength[0] = (unsigned char) (packetLength >> 8);
495 header->packetLength[1] = (unsigned char) (packetLength);
496 // DATA FIELD HEADER
497 header->spare1_pusVersion_spare2 = 0x10;
498 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
499 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
500 header->destinationID = TM_DESTINATION_ID_GROUND;
501 // AUXILIARY DATA HEADER
502 header->sid = sid;
503 header->biaStatusInfo = 0x00;
504 header->time[0] = 0x00;
505 header->time[0] = 0x00;
506 header->time[0] = 0x00;
507 header->time[0] = 0x00;
508 header->time[0] = 0x00;
509 header->time[0] = 0x00;
510 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
511 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
512 }
513
514 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
515 {
516 rtems_status_code status;
517
518 // SEND PACKET
519 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
520 if (status != RTEMS_SUCCESSFUL)
521 {
522 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
523 }
524 }
525
526 //******************
527 // general functions
528
529 void reset_spectral_matrix_regs( void )
530 {
531 /** This function resets the spectral matrices module registers.
532 *
533 * The registers affected by this function are located at the following offset addresses:
534 *
535 * - 0x00 config
536 * - 0x04 status
537 * - 0x08 matrixF0_Address0
538 * - 0x10 matrixFO_Address1
539 * - 0x14 matrixF1_Address
540 * - 0x18 matrixF2_Address
541 *
542 */
543
544 spectral_matrix_regs->config = 0x00;
545 spectral_matrix_regs->status = 0x00;
546
547 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
548 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
549 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
550 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
551 }
552
553 void set_time( unsigned char *time, unsigned char * timeInBuffer )
554 {
555 // time[0] = timeInBuffer[2];
556 // time[1] = timeInBuffer[3];
557 // time[2] = timeInBuffer[0];
558 // time[3] = timeInBuffer[1];
559 // time[4] = timeInBuffer[6];
560 // time[5] = timeInBuffer[7];
561
562 time[0] = timeInBuffer[0];
563 time[1] = timeInBuffer[1];
564 time[2] = timeInBuffer[2];
565 time[3] = timeInBuffer[3];
566 time[4] = timeInBuffer[6];
567 time[5] = timeInBuffer[7];
568 }
569
570
@@ -0,0 +1,108
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
4 #include <rtems.h>
5 #include <grspw.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h> // printf()
9 #include <math.h>
10
11 #include "fsw_params.h"
12 #include "fsw_spacewire.h"
13
14 typedef struct ring_node_sm
15 {
16 struct ring_node_sm *previous;
17 struct ring_node_sm *next;
18 int buffer_address;
19 unsigned int status;
20 unsigned int coarseTime;
21 unsigned int fineTime;
22 } ring_node_sm;
23
24 typedef struct ring_node_asm
25 {
26 struct ring_node_asm *next;
27 float matrix[ TOTAL_SIZE_SM ];
28 unsigned int status;
29 } ring_node_asm;
30
31 typedef struct bp_packet
32 {
33 Header_TM_LFR_SCIENCE_BP_t header;
34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
35 } bp_packet;
36
37 typedef struct bp_packet_with_spare
38 {
39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 } bp_packet_with_spare;
42
43 typedef struct asm_msg
44 {
45 ring_node_asm *norm;
46 ring_node_asm *burst_sbm;
47 rtems_event_set event;
48 unsigned int coarseTime;
49 unsigned int fineTime;
50 } asm_msg;
51
52 extern volatile int sm_f0[ ];
53 extern volatile int sm_f1[ ];
54 extern volatile int sm_f2[ ];
55
56 // parameters
57 extern struct param_local_str param_local;
58
59 // registers
60 extern time_management_regs_t *time_management_regs;
61 extern spectral_matrix_regs_t *spectral_matrix_regs;
62
63 extern rtems_name misc_name[5];
64 extern rtems_id Task_id[20]; /* array of task ids */
65
66 // ISR
67 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
68 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
69
70 //******************
71 // Spectral Matrices
72 void reset_nb_sm( void );
73 void SM_init_rings( void );
74 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
75 void SM_reset_current_ring_nodes( void );
76 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
77 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
78 ring_node_sm *ring_node_tab[],
79 unsigned int firstTimeF0, unsigned int firstTimeF1 );
80 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
81 float divider );
82 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
83 float divider,
84 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
85 void ASM_convert(volatile float *input_matrix, char *output_matrix);
86 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
87 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
88
89 //*****************
90 // Basic Parameters
91
92 void BP_reset_current_ring_nodes( void );
93 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
94 unsigned int apid, unsigned char sid,
95 unsigned int packetLength , unsigned char blkNr);
96 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
97 unsigned int apid, unsigned char sid,
98 unsigned int packetLength, unsigned char blkNr );
99 void BP_send(char *data,
100 rtems_id queue_id ,
101 unsigned int nbBytesToSend );
102
103 //******************
104 // general functions
105 void reset_spectral_matrix_regs( void );
106 void set_time(unsigned char *time, unsigned char *timeInBuffer );
107
108 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 24 22:14:00 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Sun Apr 27 14:59:58 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -13,7 +13,7 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DBOOT_MESSAGES
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DBOOT_MESSAGES
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters -I../src/avf_prc
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
@@ -45,7 +45,6 OBJECTS_DIR = obj/
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_processing.c \
49 ../src/fsw_misc.c \
48 ../src/fsw_misc.c \
50 ../src/fsw_init.c \
49 ../src/fsw_init.c \
51 ../src/fsw_globals.c \
50 ../src/fsw_globals.c \
@@ -53,10 +52,13 SOURCES = ../src/wf_handler.c \
53 ../src/tc_load_dump_parameters.c \
52 ../src/tc_load_dump_parameters.c \
54 ../src/tm_lfr_tc_exe.c \
53 ../src/tm_lfr_tc_exe.c \
55 ../src/tc_acceptance.c \
54 ../src/tc_acceptance.c \
56 ../src/basic_parameters/basic_parameters.c
55 ../src/basic_parameters/basic_parameters.c \
56 ../src/avf_prc/fsw_processing.c \
57 ../src/avf_prc/avf0_prc0.c \
58 ../src/avf_prc/avf1_prc1.c \
59 ../src/avf_prc/avf2_prc2.c
57 OBJECTS = obj/wf_handler.o \
60 OBJECTS = obj/wf_handler.o \
58 obj/tc_handler.o \
61 obj/tc_handler.o \
59 obj/fsw_processing.o \
60 obj/fsw_misc.o \
62 obj/fsw_misc.o \
61 obj/fsw_init.o \
63 obj/fsw_init.o \
62 obj/fsw_globals.o \
64 obj/fsw_globals.o \
@@ -64,7 +66,11 OBJECTS = obj/wf_handler.o \
64 obj/tc_load_dump_parameters.o \
66 obj/tc_load_dump_parameters.o \
65 obj/tm_lfr_tc_exe.o \
67 obj/tm_lfr_tc_exe.o \
66 obj/tc_acceptance.o \
68 obj/tc_acceptance.o \
67 obj/basic_parameters.o
69 obj/basic_parameters.o \
70 obj/fsw_processing.o \
71 obj/avf0_prc0.o \
72 obj/avf1_prc1.o \
73 obj/avf2_prc2.o
68 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
74 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
69 /usr/lib64/qt4/mkspecs/common/linux.conf \
75 /usr/lib64/qt4/mkspecs/common/linux.conf \
70 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
@@ -216,9 +222,6 obj/wf_handler.o: ../src/wf_handler.c
216 obj/tc_handler.o: ../src/tc_handler.c
222 obj/tc_handler.o: ../src/tc_handler.c
217 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
218
224
219 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
221
222 obj/fsw_misc.o: ../src/fsw_misc.c
225 obj/fsw_misc.o: ../src/fsw_misc.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
224
227
@@ -243,6 +246,21 obj/tc_acceptance.o: ../src/tc_acceptanc
243 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
245
248
249 obj/fsw_processing.o: ../src/avf_prc/fsw_processing.c ../src/avf_prc/fsw_processing.h
250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/avf_prc/fsw_processing.c
251
252 obj/avf0_prc0.o: ../src/avf_prc/avf0_prc0.c ../src/avf_prc/avf0_prc0.h \
253 ../src/avf_prc/fsw_processing.h
254 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/avf_prc/avf0_prc0.c
255
256 obj/avf1_prc1.o: ../src/avf_prc/avf1_prc1.c ../src/avf_prc/avf1_prc1.h \
257 ../src/avf_prc/fsw_processing.h
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/avf_prc/avf1_prc1.c
259
260 obj/avf2_prc2.o: ../src/avf_prc/avf2_prc2.c ../src/avf_prc/avf2_prc2.h \
261 ../src/avf_prc/fsw_processing.h
262 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/avf_prc/avf2_prc2.c
263
246 ####### Install
264 ####### Install
247
265
248 install: FORCE
266 install: FORCE
@@ -50,12 +50,12 TARGET = fsw
50 INCLUDEPATH += \
50 INCLUDEPATH += \
51 ../src \
51 ../src \
52 ../header \
52 ../header \
53 ../src/basic_parameters
53 ../src/basic_parameters \
54 ../src/avf_prc
54
55
55 SOURCES += \
56 SOURCES += \
56 ../src/wf_handler.c \
57 ../src/wf_handler.c \
57 ../src/tc_handler.c \
58 ../src/tc_handler.c \
58 ../src/fsw_processing.c \
59 ../src/fsw_misc.c \
59 ../src/fsw_misc.c \
60 ../src/fsw_init.c \
60 ../src/fsw_init.c \
61 ../src/fsw_globals.c \
61 ../src/fsw_globals.c \
@@ -63,14 +63,17 SOURCES += \
63 ../src/tc_load_dump_parameters.c \
63 ../src/tc_load_dump_parameters.c \
64 ../src/tm_lfr_tc_exe.c \
64 ../src/tm_lfr_tc_exe.c \
65 ../src/tc_acceptance.c \
65 ../src/tc_acceptance.c \
66 ../src/basic_parameters/basic_parameters.c
66 ../src/basic_parameters/basic_parameters.c \
67 ../src/avf_prc/fsw_processing.c \
68 ../src/avf_prc/avf0_prc0.c \
69 ../src/avf_prc/avf1_prc1.c \
70 ../src/avf_prc/avf2_prc2.c
67
71
68
72
69 HEADERS += \
73 HEADERS += \
70 ../header/wf_handler.h \
74 ../header/wf_handler.h \
71 ../header/tc_handler.h \
75 ../header/tc_handler.h \
72 ../header/grlib_regs.h \
76 ../header/grlib_regs.h \
73 ../header/fsw_processing.h \
74 ../header/fsw_params.h \
77 ../header/fsw_params.h \
75 ../header/fsw_misc.h \
78 ../header/fsw_misc.h \
76 ../header/fsw_init.h \
79 ../header/fsw_init.h \
@@ -81,5 +84,9 HEADERS += \
81 ../header/tm_lfr_tc_exe.h \
84 ../header/tm_lfr_tc_exe.h \
82 ../header/tc_acceptance.h \
85 ../header/tc_acceptance.h \
83 ../header/fsw_params_nb_bytes.h \
86 ../header/fsw_params_nb_bytes.h \
84 ../src/basic_parameters/basic_parameters.h
87 ../src/basic_parameters/basic_parameters.h \
88 ../src/avf_prc/fsw_processing.h \
89 ../src/avf_prc/avf0_prc0.h \
90 ../src/avf_prc/avf1_prc1.h \
91 ../src/avf_prc/avf2_prc2.h
85
92
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-24T22:30:22. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-27T15:09:47. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -210,6 +210,8 enum apid_destid{
210 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 26
210 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 26
211 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 (144 - CCSDS_TC_TM_PACKET_OFFSET) // 13 * 9 + 27
211 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 (144 - CCSDS_TC_TM_PACKET_OFFSET) // 13 * 9 + 27
212 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 (416 - CCSDS_TC_TM_PACKET_OFFSET) // 13 * 30 + 26
212 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 (416 - CCSDS_TC_TM_PACKET_OFFSET) // 13 * 30 + 26
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 (134 - CCSDS_TC_TM_PACKET_OFFSET) // 12 * 9 + 26
214 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 (386 - CCSDS_TC_TM_PACKET_OFFSET) // 12 * 30 + 26
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26
215 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26
214 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26
216 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26
215 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 (260 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 9 + 26
217 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 (260 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 9 + 26
@@ -7,9 +7,12
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
9 #include "fsw_processing.h"
10 #include "avf0_prc0.h"
11 #include "avf1_prc1.h"
12 #include "avf2_prc2.h"
13
10 #include "tc_handler.h"
14 #include "tc_handler.h"
11 #include "wf_handler.h"
15 #include "wf_handler.h"
12
13 #include "fsw_spacewire.h"
16 #include "fsw_spacewire.h"
14
17
15 extern rtems_name Task_name[20]; /* array of task names */
18 extern rtems_name Task_name[20]; /* array of task names */
@@ -28,6 +31,7 rtems_status_code get_message_queue_id_s
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
31 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
29 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
32 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
30 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
33 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
34 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
31 //
35 //
32 int start_recv_send_tasks( void );
36 int start_recv_send_tasks( void );
33 //
37 //
@@ -18,44 +18,6 typedef struct ring_node
18 unsigned int status;
18 unsigned int status;
19 } ring_node;
19 } ring_node;
20
20
21 typedef struct {
22 unsigned int norm_bp1;
23 unsigned int norm_bp2;
24 unsigned int norm_asm;
25 unsigned int burst_sbm_bp1;
26 unsigned int burst_sbm_bp2;
27 unsigned int burst_bp1;
28 unsigned int burst_bp2;
29 unsigned int sbm1_bp1;
30 unsigned int sbm1_bp2;
31 unsigned int sbm2_bp1;
32 unsigned int sbm2_bp2;
33 } nb_sm_before_bp_asm_f0;
34
35 typedef struct {
36 unsigned int norm_bp1;
37 unsigned int norm_bp2;
38 unsigned int norm_asm;
39 unsigned int burst_sbm_bp1;
40 unsigned int burst_sbm_bp2;
41 unsigned int burst_bp1;
42 unsigned int burst_bp2;
43 unsigned int sbm2_bp1;
44 unsigned int sbm2_bp2;
45 } nb_sm_before_bp_asm_f1;
46
47 typedef struct {
48 unsigned int norm_bp1_f2;
49 unsigned int norm_bp2_f2;
50 unsigned int norm_asm_f2;
51 unsigned int burst_sbm_bp1_f2;
52 unsigned int burst_sbm_bp2_f2;
53 unsigned int burst_bp1_f2;
54 unsigned int burst_bp2_f2;
55 unsigned int sbm2_bp1_f2;
56 unsigned int sbm2_bp2_f2;
57 } nb_sm_before_bp_asm_f2;
58
59 //************************
21 //************************
60 // flight software version
22 // flight software version
61 // this parameters is handled by the Qt project options
23 // this parameters is handled by the Qt project options
@@ -101,19 +63,17 typedef struct {
101 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
102 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
64 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
103 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
65 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
104 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
66 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
105 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
67 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
106 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
68 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
107 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11
69 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
108 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
70 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
109 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
71 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
110 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14
72 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
111 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
73 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
112 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
74 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
113 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
75 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
114 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
76 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
115 #define RTEMS_EVENT_BURST_SBM_BP1_F2 RTEMS_EVENT_19
116 #define RTEMS_EVENT_BURST_SBM_BP2_F2 RTEMS_EVENT_20
117
77
118 //****************************
78 //****************************
119 // LFR DEFAULT MODE PARAMETERS
79 // LFR DEFAULT MODE PARAMETERS
@@ -205,6 +165,8 typedef struct {
205 #define TASKID_WTDG 15
165 #define TASKID_WTDG 15
206 #define TASKID_AVF1 16
166 #define TASKID_AVF1 16
207 #define TASKID_PRC1 17
167 #define TASKID_PRC1 17
168 #define TASKID_AVF2 18
169 #define TASKID_PRC2 19
208
170
209 #define TASK_PRIORITY_SPIQ 5
171 #define TASK_PRIORITY_SPIQ 5
210 #define TASK_PRIORITY_WTDG 20
172 #define TASK_PRIORITY_WTDG 20
@@ -221,6 +183,8 typedef struct {
221 #define TASK_PRIORITY_AVF1 70
183 #define TASK_PRIORITY_AVF1 70
222 #define TASK_PRIORITY_PRC0 100
184 #define TASK_PRIORITY_PRC0 100
223 #define TASK_PRIORITY_PRC1 100
185 #define TASK_PRIORITY_PRC1 100
186 #define TASK_PRIORITY_AVF2 110
187 #define TASK_PRIORITY_PRC2 110
224 #define TASK_PRIORITY_STAT 200
188 #define TASK_PRIORITY_STAT 200
225 #define TASK_PRIORITY_DUMB 200
189 #define TASK_PRIORITY_DUMB 200
226
190
@@ -228,15 +192,18 typedef struct {
228 #define MSG_QUEUE_COUNT_SEND 50
192 #define MSG_QUEUE_COUNT_SEND 50
229 #define MSG_QUEUE_COUNT_PRC0 10
193 #define MSG_QUEUE_COUNT_PRC0 10
230 #define MSG_QUEUE_COUNT_PRC1 10
194 #define MSG_QUEUE_COUNT_PRC1 10
195 #define MSG_QUEUE_COUNT_PRC2 5
231 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
196 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
232 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
197 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
233 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
198 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
234 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
199 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
200 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
235
201
236 #define QUEUE_RECV 0
202 #define QUEUE_RECV 0
237 #define QUEUE_SEND 1
203 #define QUEUE_SEND 1
238 #define QUEUE_PRC0 2
204 #define QUEUE_PRC0 2
239 #define QUEUE_PRC1 3
205 #define QUEUE_PRC1 3
206 #define QUEUE_PRC2 4
240
207
241 //*******
208 //*******
242 // MACROS
209 // MACROS
@@ -14,8 +14,10
14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
15 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
15 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
16 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
16 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
18 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
18 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
19 #define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3
20 #define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3
19 //
21 //
20 #define NB_BINS_PER_ASM_F0 88
22 #define NB_BINS_PER_ASM_F0 88
21 #define NB_BINS_PER_PKT_ASM_F0 44
23 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -49,15 +51,15
49 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
51 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
50 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
52 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
51 //
53 //
52 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
54 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
53 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
55 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
54 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
56 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS
55 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
57 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
56 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
58 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
57 // NORM
59 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS
58 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
59 // GENERAL
60 // GENERAL
60 #define NB_SM_BEFORE_AVF0 8
61 #define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function
61 #define NB_SM_BEFORE_AVF1 8
62 #define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function
63 #define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function
62
64
63 #endif // FSW_PARAMS_PROCESSING_H
65 #endif // FSW_PARAMS_PROCESSING_H
@@ -9,10 +9,6
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "fsw_misc.h"
10 #include "fsw_misc.h"
11
11
12 extern nb_sm_before_bp_asm_f0 nb_sm_before_f0;
13 extern nb_sm_before_bp_asm_f1 nb_sm_before_f1;
14 extern nb_sm_before_bp_asm_f2 nb_sm_before_f2;
15
16 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
12 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
17 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
13 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
18 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
14 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
@@ -48,10 +48,6 char wf_cont_f3_light[ (NB_SAMPL
48 //***********************************
48 //***********************************
49 // SPECTRAL MATRICES GLOBAL VARIABLES
49 // SPECTRAL MATRICES GLOBAL VARIABLES
50
50
51 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
52 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
53 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
54
55 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
51 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
56 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
57 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
@@ -35,7 +35,7
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 4
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #ifdef PRINT_STACK_REPORT
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
41 #endif
@@ -98,7 +98,6 rtems_task Init( rtems_task_argument ign
98
98
99 init_waveform_rings(); // initialize the waveform rings
99 init_waveform_rings(); // initialize the waveform rings
100 SM_init_rings(); // initialize spectral matrices rings
100 SM_init_rings(); // initialize spectral matrices rings
101 ASM_init_rings(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage)
102
101
103 reset_wfp_burst_enable();
102 reset_wfp_burst_enable();
104 reset_wfp_status();
103 reset_wfp_status();
@@ -119,7 +118,7 rtems_task Init( rtems_task_argument ign
119 status = create_all_tasks(); // create all tasks
118 status = create_all_tasks(); // create all tasks
120 if (status != RTEMS_SUCCESSFUL)
119 if (status != RTEMS_SUCCESSFUL)
121 {
120 {
122 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
121 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
123 }
122 }
124
123
125 // **************************
124 // **************************
@@ -263,6 +262,8 void create_names( void ) // create all
263 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
262 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
264 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
263 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
265 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
264 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
265 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
266 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
266
267
267 // rate monotonic period names
268 // rate monotonic period names
268 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
269 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
@@ -271,6 +272,7 void create_names( void ) // create all
271 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
272 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
272 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
273 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
273 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
274 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
275 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
274 }
276 }
275
277
276 int create_all_tasks( void ) // create all tasks which run in the software
278 int create_all_tasks( void ) // create all tasks which run in the software
@@ -366,6 +368,22 int create_all_tasks( void ) // create a
366 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
368 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
367 );
369 );
368 }
370 }
371 if (status == RTEMS_SUCCESSFUL) // AVF2
372 {
373 status = rtems_task_create(
374 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
375 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
376 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
377 );
378 }
379 if (status == RTEMS_SUCCESSFUL) // PRC2
380 {
381 status = rtems_task_create(
382 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
383 RTEMS_DEFAULT_MODES,
384 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
385 );
386 }
369
387
370 //****************
388 //****************
371 // WAVEFORM PICKER
389 // WAVEFORM PICKER
@@ -529,6 +547,20 int start_all_tasks( void ) // start all
529 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
547 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
530 }
548 }
531 }
549 }
550 if (status == RTEMS_SUCCESSFUL) // AVF2
551 {
552 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
553 if (status!=RTEMS_SUCCESSFUL) {
554 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
555 }
556 }
557 if (status == RTEMS_SUCCESSFUL) // PRC2
558 {
559 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
560 if (status!=RTEMS_SUCCESSFUL) {
561 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
562 }
563 }
532
564
533 //****************
565 //****************
534 // WAVEFORM PICKER
566 // WAVEFORM PICKER
@@ -601,6 +633,7 rtems_status_code create_message_queues(
601 rtems_status_code status_send;
633 rtems_status_code status_send;
602 rtems_status_code status_q_p0;
634 rtems_status_code status_q_p0;
603 rtems_status_code status_q_p1;
635 rtems_status_code status_q_p1;
636 rtems_status_code status_q_p2;
604 rtems_status_code ret;
637 rtems_status_code ret;
605 rtems_id queue_id;
638 rtems_id queue_id;
606
639
@@ -640,6 +673,15 rtems_status_code create_message_queues(
640 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
673 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
641 }
674 }
642
675
676 //*****************************************************************************
677 // create the queue for handling averaged spectral matrices for processing @ f2
678 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
679 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
680 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
681 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
682 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
683 }
684
643 if ( status_recv != RTEMS_SUCCESSFUL )
685 if ( status_recv != RTEMS_SUCCESSFUL )
644 {
686 {
645 ret = status_recv;
687 ret = status_recv;
@@ -652,9 +694,13 rtems_status_code create_message_queues(
652 {
694 {
653 ret = status_q_p0;
695 ret = status_q_p0;
654 }
696 }
697 else if( status_q_p1 != RTEMS_SUCCESSFUL )
698 {
699 ret = status_q_p1;
700 }
655 else
701 else
656 {
702 {
657 ret = status_q_p1;
703 ret = status_q_p2;
658 }
704 }
659
705
660 return ret;
706 return ret;
@@ -707,3 +753,15 rtems_status_code get_message_queue_id_p
707
753
708 return status;
754 return status;
709 }
755 }
756
757 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
758 {
759 rtems_status_code status;
760 rtems_name queue_name;
761
762 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
763
764 status = rtems_message_queue_ident( queue_name, 0, queue_id );
765
766 return status;
767 }
@@ -575,7 +575,7 int restart_science_tasks(unsigned char
575 *
575 *
576 */
576 */
577
577
578 rtems_status_code status[8];
578 rtems_status_code status[10];
579 rtems_status_code ret;
579 rtems_status_code ret;
580
580
581 ret = RTEMS_SUCCESSFUL;
581 ret = RTEMS_SUCCESSFUL;
@@ -628,10 +628,23 int restart_science_tasks(unsigned char
628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
629 }
629 }
630
630
631 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
632 if (status[8] != RTEMS_SUCCESSFUL)
633 {
634 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
635 }
636
637 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
638 if (status[9] != RTEMS_SUCCESSFUL)
639 {
640 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
641 }
642
631 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
643 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
632 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
644 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
633 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
645 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
634 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) )
646 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
647 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL))
635 {
648 {
636 ret = RTEMS_UNSATISFIED;
649 ret = RTEMS_UNSATISFIED;
637 }
650 }
@@ -681,6 +694,22 int suspend_science_tasks()
681 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
682 }
695 }
683 }
696 }
697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
698 {
699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
700 if (status != RTEMS_SUCCESSFUL)
701 {
702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
703 }
704 }
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
706 {
707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
708 if (status != RTEMS_SUCCESSFUL)
709 {
710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
711 }
712 }
684 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
685 {
714 {
686 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
@@ -740,8 +769,8 void launch_waveform_picker( unsigned ch
740 void launch_spectral_matrix( void )
769 void launch_spectral_matrix( void )
741 {
770 {
742 SM_reset_current_ring_nodes();
771 SM_reset_current_ring_nodes();
743 ASM_reset_current_ring_nodes();
744 reset_spectral_matrix_regs();
772 reset_spectral_matrix_regs();
773 reset_nb_sm();
745
774
746 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
747 grgpio_regs->io_port_direction_register =
776 grgpio_regs->io_port_direction_register =
@@ -757,8 +786,8 void launch_spectral_matrix( void )
757 void launch_spectral_matrix_simu( void )
786 void launch_spectral_matrix_simu( void )
758 {
787 {
759 SM_reset_current_ring_nodes();
788 SM_reset_current_ring_nodes();
760 ASM_reset_current_ring_nodes();
761 reset_spectral_matrix_regs();
789 reset_spectral_matrix_regs();
790 reset_nb_sm();
762
791
763 // Spectral Matrices simulator
792 // Spectral Matrices simulator
764 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (1273 lines changed) Show them Hide them
General Comments 0
You need to be logged in to leave comments. Login now