##// END OF EJS Templates
sync
paul -
r113:693baae2bc2c VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Mar 28 13:24:20 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Apr 1 12:03:12 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,7 +10,7
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -DVHDL_DEV -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters
@@ -1,7 +1,7
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose vhdl_dev
4 CONFIG += console verbose cpu_usage_report
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-03-31T06:56:28. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-01T07:09:49. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -447,6 +447,28 typedef struct {
447 447 } Header_TM_LFR_SCIENCE_ASM_t;
448 448
449 449 typedef struct {
450 unsigned char targetLogicalAddress;
451 unsigned char protocolIdentifier;
452 unsigned char reserved;
453 unsigned char userApplication;
454 unsigned char packetID[2];
455 unsigned char packetSequenceControl[2];
456 unsigned char packetLength[2];
457 // DATA FIELD HEADER
458 unsigned char spare1_pusVersion_spare2;
459 unsigned char serviceType;
460 unsigned char serviceSubType;
461 unsigned char destinationID;
462 unsigned char time[6];
463 // AUXILIARY HEADER
464 unsigned char sid;
465 unsigned char biaStatusInfo;
466 unsigned char acquisitionTime[6];
467 unsigned char spare_source_data;
468 unsigned char pa_lfr_bp_blk_nr[2];
469 } Header_TM_LFR_SCIENCE_BP_t;
470
471 typedef struct {
450 472 //targetLogicalAddress is removed by the grspw module
451 473 unsigned char protocolIdentifier;
452 474 unsigned char reserved;
@@ -18,6 +18,16 typedef struct ring_node
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 typedef struct ring_node_sm
22 {
23 struct ring_node_sm *previous;
24 int buffer_address;
25 struct ring_node_sm *next;
26 unsigned int status;
27 unsigned int coarseTime;
28 unsigned int fineTime;
29 } ring_node_sm;
30
21 31 //************************
22 32 // flight software version
23 33 // this parameters is handled by the Qt project options
@@ -4,12 +4,12
4 4 // TC_LFR_LOAD_COMMON_PAR
5 5
6 6 // TC_LFR_LOAD_NORMAL_PAR
7 #define BYTE_POS_SY_LFR_N_SWF_L 0
8 #define BYTE_POS_SY_LFR_N_SWF_P 2
9 #define BYTE_POS_SY_LFR_N_ASM_P 4
10 #define BYTE_POS_SY_LFR_N_BP_P0 6
11 #define BYTE_POS_SY_LFR_N_BP_P1 7
12 #define BYTE_POS_SY_LFR_N_CWF_LONG_F3 8
7 #define DATAFIELD_POS_SY_LFR_N_SWF_L 0
8 #define DATAFIELD_POS_SY_LFR_N_SWF_P 2
9 #define DATAFIELD_POS_SY_LFR_N_ASM_P 4
10 #define DATAFIELD_POS_SY_LFR_N_BP_P0 6
11 #define DATAFIELD_POS_SY_LFR_N_BP_P1 7
12 #define DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 8
13 13
14 14 // TC_LFR_LOAD_BURST_PAR
15 15
@@ -38,10 +38,12
38 38 #define NB_BINS_TO_AVERAGE_ASM_F1 8
39 39 #define NB_BINS_TO_AVERAGE_ASM_F2 8
40 40 //
41 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25
42 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25
43 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25
44 #define NB_AVERAGE_NORMAL_f0 96*4
41 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
42 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
43 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
44 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
45 #define NB_AVERAGE_NORMAL_f0 384 // 96 * 4
46 #define NB_AVERAGE_SBM1_f0 24 // 24 matrices at f0 = 0.25 second
45 47 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
46 48
47 49 typedef struct {
@@ -38,11 +38,14 rtems_task avf0_task(rtems_task_argument
38 38 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
39 39 rtems_task matr_task(rtems_task_argument argument);
40 40
41 void matrix_reset(volatile float *averaged_spec_mat);
42 41 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
43 42 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
44 43 //
45 44 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
45 void matrix_reset(volatile float *averaged_spec_mat);
46 void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
47 ring_node_sm *ring_node_tab[],
48 unsigned int firstTimeF0, unsigned int firstTimeF1 );
46 49 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized );
47 50 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
48 51 void ASM_convert(volatile float *input_matrix, char *output_matrix);
@@ -232,7 +232,7 void init_local_mode_parameters( void )
232 232
233 233 void reset_local_time( void )
234 234 {
235 time_management_regs->coarse_time_load = 0x80000000;
235 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
236 236 }
237 237
238 238 void create_names( void ) // create all names for tasks and queues
@@ -384,6 +384,12 void send_dumb_hk( void )
384 384 dummy_hk_packet.serviceType = TM_TYPE_HK;
385 385 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
386 386 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
387 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
388 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
389 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
390 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
391 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
392 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
387 393 dummy_hk_packet.sid = SID_HK;
388 394
389 395 // init status word
@@ -13,20 +13,29
13 13
14 14 //************************
15 15 // spectral matrices rings
16 ring_node sm_ring_f0[NB_RING_NODES_ASM_F0];
17 ring_node sm_ring_f1[NB_RING_NODES_ASM_F1];
18 ring_node sm_ring_f2[NB_RING_NODES_ASM_F2];
19 ring_node *current_ring_node_sm_f0;
20 ring_node *ring_node_for_averaging_sm_f0;
21 ring_node *current_ring_node_sm_f1;
22 ring_node *current_ring_node_sm_f2;
16 ring_node_sm sm_ring_f0[NB_RING_NODES_ASM_F0];
17 ring_node_sm sm_ring_f1[NB_RING_NODES_ASM_F1];
18 ring_node_sm sm_ring_f2[NB_RING_NODES_ASM_F2];
19 ring_node_sm *current_ring_node_sm_f0;
20 ring_node_sm *ring_node_for_averaging_sm_f0;
21 ring_node_sm *current_ring_node_sm_f1;
22 ring_node_sm *current_ring_node_sm_f2;
23 23
24 24 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
25
26 //*****
27 // NORM
28 // F0
25 29 float averaged_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
26 30 float averaged_sm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
27 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_SM ];
31 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
28 32 float compressed_sm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
29 33
34 //*****
35 // SBM1
36 float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ];
37 float compressed_sm_sbm1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
38
30 39 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F0 * 2 ];
31 40 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F1 ];
32 41 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_BP1_F2 ];
@@ -38,58 +47,58 void init_sm_rings( void )
38 47 unsigned char i;
39 48
40 49 // F0 RING
41 sm_ring_f0[0].next = (ring_node*) &sm_ring_f0[1];
42 sm_ring_f0[0].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
50 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
51 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
43 52 sm_ring_f0[0].buffer_address =
44 53 (int) &sm_f0[ 0 ];
45 54
46 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node*) &sm_ring_f0[0];
47 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
55 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
56 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
48 57 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address =
49 58 (int) &sm_f0[ (NB_RING_NODES_ASM_F0-1) * TOTAL_SIZE_SM ];
50 59
51 60 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
52 61 {
53 sm_ring_f0[i].next = (ring_node*) &sm_ring_f0[i+1];
54 sm_ring_f0[i].previous = (ring_node*) &sm_ring_f0[i-1];
62 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
63 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
55 64 sm_ring_f0[i].buffer_address =
56 65 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
57 66 }
58 67
59 68 // F1 RING
60 sm_ring_f1[0].next = (ring_node*) &sm_ring_f1[1];
61 sm_ring_f1[0].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
69 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
70 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
62 71 sm_ring_f1[0].buffer_address =
63 72 (int) &sm_f1[ 0 ];
64 73
65 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node*) &sm_ring_f1[0];
66 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
74 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
75 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
67 76 sm_ring_f1[NB_RING_NODES_ASM_F1-1].buffer_address =
68 77 (int) &sm_f1[ (NB_RING_NODES_ASM_F1-1) * TOTAL_SIZE_SM ];
69 78
70 79 for(i=1; i<NB_RING_NODES_ASM_F1-1; i++)
71 80 {
72 sm_ring_f1[i].next = (ring_node*) &sm_ring_f1[i+1];
73 sm_ring_f1[i].previous = (ring_node*) &sm_ring_f1[i-1];
81 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
82 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
74 83 sm_ring_f1[i].buffer_address =
75 84 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
76 85 }
77 86
78 87 // F2 RING
79 sm_ring_f2[0].next = (ring_node*) &sm_ring_f2[1];
80 sm_ring_f2[0].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
88 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
89 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
81 90 sm_ring_f2[0].buffer_address =
82 91 (int) &sm_f2[ 0 ];
83 92
84 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node*) &sm_ring_f2[0];
85 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
93 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
94 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
86 95 sm_ring_f2[NB_RING_NODES_ASM_F2-1].buffer_address =
87 96 (int) &sm_f2[ (NB_RING_NODES_ASM_F2-1) * TOTAL_SIZE_SM ];
88 97
89 98 for(i=1; i<NB_RING_NODES_ASM_F2-1; i++)
90 99 {
91 sm_ring_f2[i].next = (ring_node*) &sm_ring_f2[i+1];
92 sm_ring_f2[i].previous = (ring_node*) &sm_ring_f2[i-1];
100 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
101 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
93 102 sm_ring_f2[i].buffer_address =
94 103 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
95 104 }
@@ -194,44 +203,61 rtems_task smiq_task(rtems_task_argument
194 203 rtems_task avf0_task(rtems_task_argument argument)
195 204 {
196 205 int i;
197 static int nb_average;
206 static unsigned int nb_average_norm;
207 static unsigned int nb_average_sbm1;
198 208 rtems_event_set event_out;
199 209 rtems_status_code status;
200 ring_node *ring_node_tab[8];
210 ring_node_sm *ring_node_tab[8];
201 211
202 nb_average = 0;
212 nb_average_norm = 0;
213 nb_average_sbm1 = 0;
203 214
204 215 BOOT_PRINTF("in AVFO *** \n")
205 216
206 217 while(1){
207 218 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
208 219 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
209 for (i=2; i<NB_SM_TO_RECEIVE_BEFORE_AVF0+1; i++)
220 for ( i = 2; i < (NB_SM_TO_RECEIVE_BEFORE_AVF0+1); i++ )
210 221 {
211 222 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
212 223 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
213 224 }
214 225
215 averaged_sm_f0[0] = ( (int *) (ring_node_tab[7]->buffer_address) ) [0];
216 averaged_sm_f0[1] = ( (int *) (ring_node_tab[7]->buffer_address) ) [1];
217 for(i=0; i<TOTAL_SIZE_SM; i++)
226 // copy time information in the averaged_sm_f0 buffer
227 averaged_sm_f0[0] = ring_node_tab[7]->coarseTime;
228 averaged_sm_f0[1] = ring_node_tab[7]->fineTime;
229 averaged_sm_f1[0] = ring_node_tab[7]->coarseTime;
230 averaged_sm_f1[1] = ring_node_tab[7]->fineTime;
231
232 // compute the average and store it in the averaged_sm_f1 buffer
233 ASM_average( averaged_sm_f0, averaged_sm_f1,
234 ring_node_tab,
235 nb_average_norm, nb_average_sbm1 );
236
237
238 // update nb_average
239 nb_average_norm = nb_average_norm + NB_SM_TO_RECEIVE_BEFORE_AVF0;
240 nb_average_sbm1 = nb_average_sbm1 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
241
242 // launch actions depending on the current mode
243 if (lfrCurrentMode == LFR_MODE_SBM1)
218 244 {
219 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i + TIME_OFFSET]
220 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i + TIME_OFFSET]
221 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i + TIME_OFFSET]
222 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i + TIME_OFFSET]
223 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i + TIME_OFFSET]
224 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i + TIME_OFFSET]
225 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i + TIME_OFFSET]
226 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i + TIME_OFFSET];
245 if (nb_average_sbm1 == NB_AVERAGE_SBM1_f0) {
246 nb_average_sbm1 = 0;
247 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_SBM1 ); // sending an event to the task 7, BPF0
248 if (status != RTEMS_SUCCESSFUL) {
249 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
250 }
251 }
227 252 }
228
229 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
230 if (nb_average == NB_AVERAGE_NORMAL_f0) {
231 nb_average = 0;
232 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
233 if (status != RTEMS_SUCCESSFUL) {
234 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
253 if (lfrCurrentMode == LFR_MODE_NORMAL)
254 {
255 if (nb_average_norm == NB_AVERAGE_NORMAL_f0) {
256 nb_average_norm = 0;
257 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_NORMAL ); // sending an event to the task 7, BPF0
258 if (status != RTEMS_SUCCESSFUL) {
259 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
260 }
235 261 }
236 262 }
237 263 }
@@ -258,16 +284,33 rtems_task matr_task(rtems_task_argument
258 284 fill_averaged_spectral_matrix( );
259 285
260 286 while(1){
261 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
262 // 1) compress the matrix for Basic Parameters calculation
263 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
264 // 2)
265 // BP1_set( (float *) &compressed_sm_f0[TIME_OFFSET], NB_BINS_COMPRESSED_SM_F0, (unsigned char *) &LFR_BP1_F0[TIME_OFFSET_IN_BYTES] );
266 // 3) convert the float array in a char array
267 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
268 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
269 // 4) send the spectral matrix packets
270 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
287 rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1,
288 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
289 if (event_out==RTEMS_EVENT_MODE_NORMAL)
290 {
291 // 1) compress the matrix for Basic Parameters calculation
292 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
293 // 2) compute the BP1 set
294
295 // 3) convert the float array in a char array
296 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
297 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
298 // 4) send the spectral matrix packets
299 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
300 }
301 else if (event_out==RTEMS_EVENT_MODE_SBM1)
302 {
303 // 1) compress the matrix for Basic Parameters calculation
304 ASM_compress( averaged_sm_f1, 0, compressed_sm_f1 );
305 // 2) compute the BP1 set
306
307 // 4) send the basic parameters set 1 packet
308 BP1_send( );
309 }
310 else
311 {
312 PRINTF1("ERR *** in MATR *** unexect event = %x\n", (unsigned int) event_out)
313 }
271 314 }
272 315 }
273 316
@@ -282,6 +325,47 void matrix_reset(volatile float *averag
282 325 }
283 326 }
284 327
328 void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
329 ring_node_sm *ring_node_tab[],
330 unsigned int firstTimeF0, unsigned int firstTimeF1 )
331 {
332 float sum;
333 unsigned int i;
334
335 for(i=0; i<TOTAL_SIZE_SM; i++)
336 {
337 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
338 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
339 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
340 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
341 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
342 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
343 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
344 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
345
346 if ( (firstTimeF0 == 0) && (firstTimeF1 == 0) )
347 {
348 averaged_spec_mat_f0[ i ] = averaged_spec_mat_f0[ i ] + sum;
349 averaged_spec_mat_f1[ i ] = averaged_spec_mat_f1[ i ] + sum;
350 }
351 else if ( (firstTimeF0 == 0) && (firstTimeF1 != 0) )
352 {
353 averaged_spec_mat_f0[ i ] = averaged_spec_mat_f0[ i ] + sum;
354 averaged_spec_mat_f1[ i ] = sum;
355 }
356 else if ( (firstTimeF0 != 0) && (firstTimeF1 == 0) )
357 {
358 averaged_spec_mat_f0[ i ] = sum;
359 averaged_spec_mat_f1[ i ] = averaged_spec_mat_f1[ i ] + sum;
360 }
361 else
362 {
363 averaged_spec_mat_f0[ i ] = sum;
364 averaged_spec_mat_f1[ i ] = sum;
365 }
366 }
367 }
368
285 369 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized )
286 370 {
287 371 int frequencyBin;
@@ -440,6 +524,11 void ASM_send(Header_TM_LFR_SCIENCE_ASM_
440 524 }
441 525 }
442 526
527 void BP1_send()
528 {
529
530 }
531
443 532 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
444 533 int i;
445 534 int j;
@@ -655,6 +744,36 void init_header_asm( Header_TM_LFR_SCIE
655 744 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
656 745 }
657 746
747 void init_header_bp( Header_TM_LFR_SCIENCE_BP_t *header)
748 {
749 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
750 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
751 header->reserved = 0x00;
752 header->userApplication = CCSDS_USER_APP;
753 // header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
754 // header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
755 header->packetSequenceControl[0] = 0xc0;
756 header->packetSequenceControl[1] = 0x00;
757 header->packetLength[0] = 0x00;
758 header->packetLength[1] = 0x00;
759 // DATA FIELD HEADER
760 header->spare1_pusVersion_spare2 = 0x10;
761 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
762 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
763 header->destinationID = TM_DESTINATION_ID_GROUND;
764 // AUXILIARY DATA HEADER
765 header->sid = 0x00;
766 header->biaStatusInfo = 0x00;
767 header->time[0] = 0x00;
768 header->time[0] = 0x00;
769 header->time[0] = 0x00;
770 header->time[0] = 0x00;
771 header->time[0] = 0x00;
772 header->time[0] = 0x00;
773 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
774 header->pa_lfr_bp_blk_nr[1] = 0x00; // BLK_NR LSB
775 }
776
658 777 void fill_averaged_spectral_matrix(void)
659 778 {
660 779 /** This function fills spectral matrices related buffers with arbitrary data.
@@ -532,7 +532,7 int enter_mode( unsigned char mode, unsi
532 532 #endif
533 533 status = restart_science_tasks();
534 534 launch_waveform_picker( mode, transitionCoarseTime );
535 // launch_spectral_matrix( mode );
535 launch_spectral_matrix_simu( mode );
536 536 }
537 537 else if ( mode == LFR_MODE_STANDBY )
538 538 {
@@ -701,7 +701,6 void launch_spectral_matrix( unsigned ch
701 701 reset_current_sm_ring_nodes();
702 702 reset_spectral_matrix_regs();
703 703
704 #ifdef VHDL_DEV
705 704 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
706 705 grgpio_regs->io_port_direction_register =
707 706 grgpio_regs->io_port_direction_register | 0x01; // [0001 1000], 0 = output disabled, 1 = output enabled
@@ -710,12 +709,7 void launch_spectral_matrix( unsigned ch
710 709 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
711 710 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
712 711 set_run_matrix_spectral( 1 );
713 #else
714 // Spectral Matrices simulator
715 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
716 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
717 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
718 #endif
712
719 713 }
720 714
721 715 void set_irq_on_new_ready_matrix( unsigned char value )
@@ -262,8 +262,8 int set_sy_lfr_n_swf_l( ccsdsTelecommand
262 262 unsigned char lsb;
263 263 rtems_status_code status;
264 264
265 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
266 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
265 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
266 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
267 267
268 268 tmp = ( unsigned int ) floor(
269 269 ( ( msb*256 ) + lsb ) / 16
@@ -271,7 +271,7 int set_sy_lfr_n_swf_l( ccsdsTelecommand
271 271
272 272 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
273 273 { // 2048 is the maximum limit due to the size of the buffers
274 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
274 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
275 275 result = WRONG_APP_DATA;
276 276 }
277 277 else if (tmp != 2048)
@@ -304,14 +304,14 int set_sy_lfr_n_swf_p(ccsdsTelecommandP
304 304 unsigned char lsb;
305 305 rtems_status_code status;
306 306
307 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
308 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
307 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
308 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
309 309
310 310 tmp = msb * 256 + lsb;
311 311
312 312 if ( tmp < 16 )
313 313 {
314 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
314 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
315 315 result = WRONG_APP_DATA;
316 316 }
317 317 else
@@ -337,8 +337,8 int set_sy_lfr_n_asm_p( ccsdsTelecommand
337 337 unsigned char msb;
338 338 unsigned char lsb;
339 339
340 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
341 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
340 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
341 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
342 342
343 343 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
344 344 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
@@ -360,7 +360,7 int set_sy_lfr_n_bp_p0( ccsdsTelecommand
360 360
361 361 status = LFR_SUCCESSFUL;
362 362
363 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
363 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
364 364
365 365 return status;
366 366 }
@@ -378,7 +378,7 int set_sy_lfr_n_bp_p1(ccsdsTelecommandP
378 378
379 379 status = LFR_SUCCESSFUL;
380 380
381 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
381 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
382 382
383 383 return status;
384 384 }
@@ -396,7 +396,7 int set_sy_lfr_n_cwf_long_f3(ccsdsTeleco
396 396
397 397 status = LFR_SUCCESSFUL;
398 398
399 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ];
399 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
400 400
401 401 return status;
402 402 }
@@ -748,12 +748,12 int send_waveform_SWF( volatile int *wav
748 748 // SET PACKET TIME
749 749 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
750 750 //
751 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
752 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
753 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
754 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
755 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
756 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
751 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
752 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
753 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
754 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
755 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
756 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
757 757 // SEND PACKET
758 758 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
759 759 if (status != RTEMS_SUCCESSFUL) {
@@ -807,12 +807,12 int send_waveform_CWF(volatile int *wave
807 807 // SET PACKET TIME
808 808 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
809 809 //
810 headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
811 headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
812 headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
813 headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
814 headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
815 headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
810 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
811 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
812 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
813 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
814 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
815 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
816 816 // SEND PACKET
817 817 if (sid == SID_NORM_CWF_LONG_F3)
818 818 {
@@ -892,12 +892,12 int send_waveform_CWF3_light(volatile in
892 892 // SET PACKET TIME
893 893 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
894 894 //
895 headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
896 headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
897 headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
898 headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
899 headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
900 headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
895 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
896 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
897 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
898 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
899 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
900 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
901 901 // SEND PACKET
902 902 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
903 903 if (status != RTEMS_SUCCESSFUL) {
General Comments 0
You need to be logged in to leave comments. Login now