##// END OF EJS Templates
Sync...
paul -
r116:4710a866a7d2 VHDLib206
parent child
Show More
@@ -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-04-03T15:58:50. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-07T06:54:09. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -4,12 +4,12
4 4 #include "fsw_params_processing.h"
5 5
6 6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
7 #define CCSDS_TC_TM_PACKET_OFFSET 7
7 8 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
8 9 #define CCSDS_TM_PKT_MAX_SIZE 4412
9 10 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
10 11 #define CCSDS_TC_PKT_MAX_SIZE 256
11 12 #define CCSDS_TC_PKT_MIN_SIZE 16
12 #define CCSDS_TC_TM_PACKET_OFFSET 7
13 13 #define CCSDS_PROCESS_ID 76
14 14 #define CCSDS_PACKET_CATEGORY 12
15 15 #define CCSDS_NODE_ADDRESS 0xfe
@@ -20,18 +20,18
20 20 #define DEFAULT_HKBIA 0x1e // 0001 1110
21 21
22 22 // PACKET ID
23 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
24 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
25 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
28 #define TM_PACKET_PID_DEFAULT 76
29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
30 #define TM_PACKET_CAT_TC_EXE 1
31 #define TM_PACKET_CAT_HK 4
32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
33 #define TM_PACKET_CAT_SCIENCE 12
34 #define TC_PACKET_CAT 12
23 #define APID_TM_TC_EXE 0x0cc1 // PID 76 CAT 1
24 #define APID_TM_HK 0x0cc4 // PID 76 CAT 4
25 #define APID_TM_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 #define APID_TM_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 #define APID_TM_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
28 #define TM_PACKET_PID_DEFAULT 76
29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
30 #define TM_PACKET_CAT_TC_EXE 1
31 #define TM_PACKET_CAT_HK 4
32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
33 #define TM_PACKET_CAT_SCIENCE 12
34 #define TC_PACKET_CAT 12
35 35
36 36 // PACKET SEQUENCE CONTROL
37 37 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
@@ -207,7 +207,12 enum apid_destid{
207 207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 (2628 - CCSDS_TC_TM_PACKET_OFFSET) // 52 * 25 * 2 + 28 - 7
208 208 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 (2428 - CCSDS_TC_TM_PACKET_OFFSET) // 48 * 25 * 2 + 28 - 7
209 209 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 (126 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 9 + 27 - 7
210 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 25 - 7
211 #define PACKET_LENGTH_TM_LFR_SCIENCE_BURST_BP2_F1 (806 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 30 + 26 - 7
210 212 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26 - 7
214
215 #define PACKET_LENGTH_DELTA 11 // 7 + 4
211 216
212 217 #define SPARE1_PUSVERSION_SPARE2 0x10
213 218
@@ -466,9 +471,9 typedef struct {
466 471 unsigned char sid;
467 472 unsigned char biaStatusInfo;
468 473 unsigned char acquisitionTime[6];
469 unsigned char spare_source_data;
474 unsigned char source_data_spare[2];
470 475 unsigned char pa_lfr_bp_blk_nr[2];
471 } Header_TM_LFR_SCIENCE_BP_NORM_t;
476 } Header_TM_LFR_SCIENCE_BP_with_spare_t;
472 477
473 478 typedef struct {
474 479 unsigned char targetLogicalAddress;
@@ -489,7 +494,7 typedef struct {
489 494 unsigned char biaStatusInfo;
490 495 unsigned char acquisitionTime[6];
491 496 unsigned char pa_lfr_bp_blk_nr[2];
492 } Header_TM_LFR_SCIENCE_BP_SBM_t;
497 } Header_TM_LFR_SCIENCE_BP_t;
493 498
494 499 typedef struct {
495 500 //targetLogicalAddress is removed by the grspw module
@@ -18,36 +18,6 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
31 typedef struct ring_node_bp
32 {
33 struct ring_node_bp *previous;
34 struct ring_node_bp *next;
35 unsigned int status;
36 unsigned int coarseTime;
37 unsigned int fineTime;
38 Header_TM_LFR_SCIENCE_BP_SBM_t header;
39 unsigned char data[ 9 * 22 ];
40 } ring_node_bp;
41
42 typedef struct
43 {
44 unsigned int status;
45 unsigned int coarseTime;
46 unsigned int fineTime;
47 Header_TM_LFR_SCIENCE_BP_NORM_t header;
48 unsigned char data[ 9 * 22 ];
49 } ring_node_norm_bp;
50
51 21 //************************
52 22 // flight software version
53 23 // this parameters is handled by the Qt project options
@@ -85,15 +55,17 typedef struct
85 55 #define THR_MODE_NORMAL 1
86 56 #define THR_MODE_BURST 2
87 57
88 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
89 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
90 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
91 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
92 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
93 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
94 #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6
95 #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7
96 #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8
58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
64 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
65 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
66 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
67 #define RTEMS_EVENT_SBM1_BP1_F0 RTEMS_EVENT_9
68 #define RTEMS_EVENT_SBM1_BP2_F0 RTEMS_EVENT_10
97 69
98 70 //****************************
99 71 // LFR DEFAULT MODE PARAMETERS
@@ -203,11 +175,11 typedef struct
203 175 #define TASK_PRIORITY_STAT 200
204 176 #define TASK_PRIORITY_DUMB 200
205 177
206 #define ACTION_MSG_QUEUE_COUNT 10
207 #define ACTION_MSG_PKTS_COUNT 50
178 #define ACTION_MSG_QUEUE_COUNT 10
179 #define ACTION_MSG_PKTS_COUNT 50
208 180 //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
209 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
210 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
181 #define ACTION_MSG_PKTS_MAX_SIZE 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
182 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
211 183
212 184 #define QUEUE_RECV 0
213 185 #define QUEUE_SEND 1
@@ -12,7 +12,8
12 12 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
13 13 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
14 14 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
15 #define NB_RING_NODES_BP1_SBM1 10 // AT LEAST 3
15 #define NB_RING_NODES_SBM1_BP1 10 // AT LEAST 3
16 #define NB_RING_NODES_SBM1_BP2 5 // AT LEAST 3
16 17 //
17 18 #define NB_BINS_PER_ASM_F0 88
18 19 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -42,12 +43,15
42 43 #define NB_BINS_TO_AVERAGE_ASM_F2 8
43 44 #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4
44 45 //
45 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
46 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
47 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
48 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
49 #define NB_AVERAGE_NORMAL_F0 384 // 96 * 4
50 #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second
51 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
46 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
47 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
48 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
49 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
50 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
51 #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20
52 #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second
53 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
54 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
55 #define NB_SM_BEFORE_AVF0 8
52 56
53 57 #endif // FSW_PARAMS_PROCESSING_H
@@ -11,6 +11,38
11 11 #include "fsw_params.h"
12 12 #include "fsw_spacewire.h"
13 13
14 typedef struct ring_node_sm
15 {
16 struct ring_node_sm *previous;
17 int buffer_address;
18 struct ring_node_sm *next;
19 unsigned int status;
20 unsigned int coarseTime;
21 unsigned int fineTime;
22 } ring_node_sm;
23
24 typedef struct ring_node_bp
25 {
26 struct ring_node_bp *previous;
27 struct ring_node_bp *next;
28 unsigned int status;
29 unsigned int coarseTime;
30 unsigned int fineTime;
31 Header_TM_LFR_SCIENCE_BP_t header;
32 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 TM_LFR_SCIENCE_BURST_BP2_F1
33 } ring_node_bp;
34
35 typedef struct ring_node_bp_with_spare
36 {
37 struct ring_node_bp_with_spare *previous;
38 struct ring_node_bp_with_spare *next;
39 unsigned int status;
40 unsigned int coarseTime;
41 unsigned int fineTime;
42 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
43 unsigned char data[ 9 * 22 ];
44 } ring_node_bp_with_spare;
45
14 46 extern volatile int sm_f0[ ];
15 47 extern volatile int sm_f1[ ];
16 48 extern volatile int sm_f2[ ];
@@ -27,6 +59,7 extern rtems_id Task_id[20];
27 59
28 60 void init_sm_rings( void );
29 61 void reset_current_sm_ring_nodes( void );
62 void reset_current_bp_ring_nodes( void );
30 63
31 64 // ISR
32 65 void reset_nb_sm_f0( void );
@@ -41,7 +74,7 rtems_task matr_task(rtems_task_argument
41 74 //*****************************
42 75 // Spectral matrices processing
43 76
44 void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
77 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
45 78 ring_node_sm *ring_node_tab[],
46 79 unsigned int firstTimeF0, unsigned int firstTimeF1 );
47 80 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
@@ -53,12 +86,23 void ASM_convert(volatile float *input_m
53 86 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
54 87 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
55 88
56 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id );
89 void BP_send(char *data,
90 rtems_id queue_id ,
91 unsigned int nbBytesToSend );
57 92
58 93 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
59 void init_headers_bp_ring_sbm1();
60 void init_header_bp( Header_TM_LFR_SCIENCE_BP_SBM_t *header);
94 void init_bp_ring_sbm1_bp1( void );
95 void init_bp_ring_sbm1_bp2( void );
96 void init_headers_bp_ring_sbm1_bp1();
97 void init_header_bp(Header_TM_LFR_SCIENCE_BP_t *header,
98 unsigned int apid, unsigned char sid,
99 unsigned int packetLength , unsigned char blkNr);
100 void init_header_bp_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
101 unsigned int apid, unsigned char sid,
102 unsigned int packetLength, unsigned char blkNr );
61 103
62 104 void reset_spectral_matrix_regs( void );
63 105
106 void set_time( unsigned char *time, unsigned int coarseTime, unsigned int fineTime );
107
64 108 #endif // FSW_PROCESSING_H_INCLUDED
@@ -96,8 +96,10 rtems_task Init( rtems_task_argument ign
96 96 init_local_mode_parameters();
97 97 init_housekeeping_parameters();
98 98
99 init_waveform_rings(); // initialize the waveform rings
100 init_sm_rings(); // initialize spectral matrices rings
99 init_waveform_rings(); // initialize the waveform rings
100 init_sm_rings(); // initialize spectral matrices rings
101 init_bp_ring_sbm1_bp1(); // initialize basic parameter ring for SBM1 BP1 set
102 init_bp_ring_sbm1_bp2(); // initialize basic parameter ring for SBM1 BP2 set
101 103
102 104 reset_wfp_burst_enable();
103 105 reset_wfp_status();
@@ -164,8 +164,8 rtems_task hous_task(rtems_task_argument
164 164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
@@ -374,8 +374,8 void send_dumb_hk( void )
374 374 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
375 375 dummy_hk_packet.reserved = DEFAULT_RESERVED;
376 376 dummy_hk_packet.userApplication = CCSDS_USER_APP;
377 dummy_hk_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
378 dummy_hk_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
377 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
378 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
379 379 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
380 380 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
381 381 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
@@ -24,20 +24,22 ring_node_sm *current_ring_node_sm_f2;
24 24 //**********************
25 25 // basic parameter rings
26 26 ring_node_bp *current_node_sbm1_bp1_f0;
27 ring_node_bp bp_ring_sbm1[ NB_RING_NODES_BP1_SBM1 ];
27 ring_node_bp *current_node_sbm1_bp2_f0;
28 ring_node_bp bp_ring_sbm1_bp1[ NB_RING_NODES_SBM1_BP1 ];
29 ring_node_bp bp_ring_sbm1_bp2[ NB_RING_NODES_SBM1_BP2 ];
28 30
29 31 //*****
30 32 // NORM
31 33 // F0
32 float asm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
33 float asm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
34 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
35 float compressed_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
34 float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
35 float asm_f0_reorganized [ TIME_OFFSET + TOTAL_SIZE_SM ];
36 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
37 float compressed_sm_norm_f0[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
36 38
37 39 //*****
38 40 // SBM1
39 float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ];
40 float compressed_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
41 float asm_sbm1_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
42 float compressed_sm_sbm1[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
41 43
42 44 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
43 45 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
@@ -123,9 +125,10 void reset_current_sm_ring_nodes( void )
123 125 ring_node_for_averaging_sm_f0 = sm_ring_f0;
124 126 }
125 127
126 void reset_current_node_sbm1_bp1_f0( void )
128 void reset_current_bp_ring_nodes( void )
127 129 {
128 current_node_sbm1_bp1_f0 = bp_ring_sbm1;
130 current_node_sbm1_bp1_f0 = bp_ring_sbm1_bp1;
131 current_node_sbm1_bp2_f0 = bp_ring_sbm1_bp2;
129 132 }
130 133
131 134 //***********************************************************
@@ -162,7 +165,7 rtems_isr spectral_matrices_isr( rtems_v
162 165
163 166 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
164 167
165 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
168 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
166 169 {
167 170 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
168 171 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -179,7 +182,7 rtems_isr spectral_matrices_isr( rtems_v
179 182
180 183 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
181 184 {
182 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
185 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
183 186 {
184 187 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
185 188 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -211,64 +214,103 rtems_task smiq_task(rtems_task_argument
211 214 rtems_task avf0_task(rtems_task_argument argument)
212 215 {
213 216 int i;
214 static unsigned int nb_average_norm_f0;
215 static unsigned int nb_average_sbm1_f0;
217 static unsigned int nb_sm_norm_bp1_f0;
218 static unsigned int nb_sm_norm_bp2_f0;
219 static unsigned int nb_sm_norm_asm_f0;
220 static unsigned int nb_sm_sbm1_bp1_f0;
221 static unsigned int nb_sm_sbm1_bp2_f0;
216 222 rtems_event_set event_out;
223 rtems_event_set event_for_matr;
217 224 rtems_status_code status;
218 225 ring_node_sm *ring_node_tab[8];
219 226
220 nb_average_norm_f0 = 0;
221 nb_average_sbm1_f0 = 0;
227 nb_sm_norm_bp1_f0 = 0;
228 nb_sm_norm_bp2_f0 = 0;
229 nb_sm_norm_asm_f0 = 0;
230 nb_sm_sbm1_bp1_f0 = 0;
231 nb_sm_sbm1_bp2_f0 = 0;
222 232
223 233 BOOT_PRINTF("in AVFO *** \n")
224 234
225 235 while(1){
226 236 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
227 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
228 for ( i = 2; i < (NB_SM_TO_RECEIVE_BEFORE_AVF0+1); i++ )
237 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
238 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
229 239 {
230 240 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
231 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
241 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
232 242 }
233 243
234 244 // copy time information in the asm_f0 buffer
235 asm_f0[0] = ring_node_tab[7]->coarseTime;
236 asm_f0[1] = ring_node_tab[7]->fineTime;
237 averaged_sm_sbm1[0] = ring_node_tab[7]->coarseTime;
238 averaged_sm_sbm1[1] = ring_node_tab[7]->fineTime;
245 asm_norm_f0[0] = ring_node_tab[7]->coarseTime;
246 asm_norm_f0[1] = ring_node_tab[7]->fineTime;
247 asm_sbm1_f0[0] = ring_node_tab[7]->coarseTime;
248 asm_sbm1_f0[1] = ring_node_tab[7]->fineTime;
239 249
240 250 // compute the average and store it in the averaged_sm_f1 buffer
241 ASM_average( asm_f0, averaged_sm_sbm1,
251 SM_average( asm_norm_f0, asm_sbm1_f0,
242 252 ring_node_tab,
243 nb_average_norm_f0, nb_average_sbm1_f0 );
244
253 nb_sm_norm_bp1_f0, nb_sm_sbm1_bp1_f0 );
245 254
246 255 // update nb_average
247 nb_average_norm_f0 = nb_average_norm_f0 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
248 nb_average_sbm1_f0 = nb_average_sbm1_f0 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
256 nb_sm_norm_bp1_f0 = nb_sm_norm_bp1_f0 + NB_SM_BEFORE_AVF0;
257 nb_sm_norm_bp2_f0 = nb_sm_norm_bp2_f0 + NB_SM_BEFORE_AVF0;
258 nb_sm_norm_asm_f0 = nb_sm_norm_asm_f0 + NB_SM_BEFORE_AVF0;
259 nb_sm_sbm1_bp1_f0 = nb_sm_sbm1_bp1_f0 + NB_SM_BEFORE_AVF0;
260 nb_sm_sbm1_bp2_f0 = nb_sm_sbm1_bp2_f0 + NB_SM_BEFORE_AVF0;
249 261
250 // launch actions depending on the current mode
262 //***********************************************************
263 // build a composite event that will be sent to the MATR task
264 event_for_matr = 0x00;
251 265
252 if (nb_average_sbm1_f0 == NB_AVERAGE_SBM1_F0)
266 if (nb_sm_sbm1_bp1_f0 == NB_SM_BEFORE_SBM1_BP1_F0)
253 267 {
254 nb_average_sbm1_f0 = 0;
268 nb_sm_sbm1_bp1_f0 = 0;
255 269 if (lfrCurrentMode == LFR_MODE_SBM1)
256 270 {
257 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_SBM1 ); // sending an event to the task 7, BPF0
258 if (status != RTEMS_SUCCESSFUL)
259 {
260 printf("in AVF0 *** Error sending RTEMS_EVENT_MODE_SBM1, code %d\n", status);
261 }
271 event_for_matr = event_for_matr | RTEMS_EVENT_SBM1_BP1_F0;
262 272 }
263 273 }
264 274
265 if (nb_average_norm_f0 == NB_AVERAGE_NORMAL_F0) {
266 nb_average_norm_f0 = 0;
267 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_NORMAL ); // sending an event to the task 7, BPF0
268 if (status != RTEMS_SUCCESSFUL) {
269 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
275 if (nb_sm_sbm1_bp2_f0 == NB_SM_BEFORE_SBM1_BP2_F0)
276 {
277 nb_sm_sbm1_bp2_f0 = 0;
278 if (lfrCurrentMode == LFR_MODE_SBM1)
279 {
280 event_for_matr = event_for_matr | RTEMS_EVENT_SBM1_BP2_F0;
281 }
282 }
283
284 if (nb_sm_norm_bp1_f0 == NB_SM_BEFORE_NORM_BP1_F0) {
285 nb_sm_norm_bp1_f0 = 0;
286 if (lfrCurrentMode == LFR_MODE_NORMAL)
287 {
288 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP1_F0;
270 289 }
271 290 }
291
292 if (nb_sm_norm_bp2_f0 == NB_SM_BEFORE_NORM_BP2_F0) {
293 nb_sm_norm_bp2_f0 = 0;
294 if (lfrCurrentMode == LFR_MODE_NORMAL)
295 {
296 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP2_F0;
297 }
298 }
299
300 if (nb_sm_norm_asm_f0 == NB_SM_BEFORE_NORM_ASM_F0) {
301 nb_sm_norm_asm_f0 = 0;
302 if (lfrCurrentMode == LFR_MODE_NORMAL)
303 {
304 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_ASM_F0;
305 }
306 }
307
308 //*********************************
309 // send the composite event to MATR
310 status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr );
311 if (status != RTEMS_SUCCESSFUL) {
312 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
313 }
272 314 }
273 315 }
274 316
@@ -279,10 +321,16 rtems_task matr_task(rtems_task_argument
279 321 rtems_status_code status;
280 322 rtems_id queue_id;
281 323 Header_TM_LFR_SCIENCE_ASM_t headerASM;
282 ring_node_norm_bp current_node_norm_bp1_f0;
324 ring_node_bp_with_spare current_node_norm_bp1_f0;
325 ring_node_bp current_node_norm_bp2_f0;
283 326
284 327 init_header_asm( &headerASM );
285 // init_header_bp( &current_node_norm_bp1_f0.header );
328 init_header_bp_with_spare( &current_node_norm_bp1_f0.header,
329 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
331 init_header_bp( &current_node_norm_bp2_f0.header,
332 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
333 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
286 334
287 335 status = get_message_queue_id_send( &queue_id );
288 336 if (status != RTEMS_SUCCESSFUL)
@@ -293,51 +341,98 rtems_task matr_task(rtems_task_argument
293 341 BOOT_PRINTF("in MATR *** \n")
294 342
295 343 while(1){
296 rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1,
344 rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0
345 | RTEMS_EVENT_SBM1_BP1_F0 | RTEMS_EVENT_SBM1_BP2_F0,
297 346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
298 if (event_out==RTEMS_EVENT_MODE_NORMAL)
347 //*****
348 //*****
349 // SBM1
350 //*****
351 //*****
352 if (event_out & RTEMS_EVENT_SBM1_BP1_F0)
299 353 {
300 354 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( asm_f0, compressed_sm_f0,
302 NB_AVERAGE_NORMAL_F0,
355 ASM_compress_reorganize_and_divide( asm_sbm1_f0, compressed_sm_sbm1,
356 NB_SM_BEFORE_SBM1_BP1_F0,
357 NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0,
358 ASM_F0_INDICE_START);
359 // 2) compute the BP1 set
360
361 // 3) send the BP1 set
362 set_time( current_node_sbm1_bp1_f0->header.time,
363 current_node_sbm1_bp1_f0->coarseTime, current_node_sbm1_bp1_f0->fineTime);
364 set_time( current_node_sbm1_bp1_f0->header.acquisitionTime,
365 current_node_sbm1_bp1_f0->coarseTime, current_node_sbm1_bp1_f0->fineTime);
366 BP_send( (char *) &current_node_sbm1_bp1_f0->header, queue_id,
367 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + PACKET_LENGTH_DELTA);
368 // 4) update current_node_sbm1_bp1_f0
369 current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next;
370 if (event_out & RTEMS_EVENT_SBM1_BP2_F0)
371 {
372 // 1) compute the BP2 set
373
374 // 2) send the BP2 set
375 set_time( current_node_sbm1_bp2_f0->header.time,
376 current_node_sbm1_bp2_f0->coarseTime, current_node_sbm1_bp2_f0->fineTime);
377 set_time( current_node_sbm1_bp2_f0->header.acquisitionTime,
378 current_node_sbm1_bp2_f0->coarseTime, current_node_sbm1_bp2_f0->fineTime);
379 BP_send( (char *) &current_node_sbm1_bp2_f0->header, queue_id,
380 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + PACKET_LENGTH_DELTA);
381 }
382 }
383
384 //*****
385 //*****
386 // NORM
387 //*****
388 //*****
389 if (event_out & RTEMS_EVENT_NORM_BP1_F0)
390 {
391 // 1) compress the matrix for Basic Parameters calculation
392 ASM_compress_reorganize_and_divide( asm_norm_f0, compressed_sm_norm_f0,
393 NB_SM_BEFORE_NORM_BP1_F0,
303 394 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 395 ASM_F0_INDICE_START );
305 396 // 2) compute the BP1 set
306 397
307 398 // 3) send the BP1 set
308 BP1_send( &current_node_norm_bp1_f0, SID_NORM_BP1_F0, queue_id );
309 // 4) reorganize the ASM and divide
310 ASM_reorganize_and_divide( asm_f0, asm_f0_reorganized, NB_AVERAGE_NORMAL_F0 );
311 // 5) convert the float array in a char array
399 set_time( current_node_norm_bp1_f0.header.time,
400 current_node_norm_bp1_f0.coarseTime, current_node_norm_bp1_f0.fineTime);
401 set_time( current_node_norm_bp1_f0.header.acquisitionTime,
402 current_node_norm_bp1_f0.coarseTime, current_node_norm_bp1_f0.fineTime);
403 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
404 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
405 if (event_out & RTEMS_EVENT_NORM_BP2_F0)
406 {
407 // 1) compute the BP2 set
408
409 // 2) send the BP2 set
410 set_time( current_node_norm_bp2_f0.header.time,
411 current_node_norm_bp2_f0.coarseTime, current_node_norm_bp2_f0.fineTime);
412 set_time( current_node_norm_bp2_f0.header.acquisitionTime,
413 current_node_norm_bp2_f0.coarseTime, current_node_norm_bp2_f0.fineTime);
414 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
415 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
416 }
417 }
418
419 if (event_out & RTEMS_EVENT_NORM_ASM_F0)
420 {
421 // 1) reorganize the ASM and divide
422 ASM_reorganize_and_divide( asm_norm_f0, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
423 // 2) convert the float array in a char array
312 424 ASM_convert( asm_f0_reorganized, asm_f0_char);
313 // 6) send the spectral matrix packets
425 // 3) send the spectral matrix packets
314 426 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
315 427 }
316 else if (event_out==RTEMS_EVENT_MODE_SBM1)
317 {
318 // 1) compress the matrix for Basic Parameters calculation
319 ASM_compress_reorganize_and_divide( averaged_sm_sbm1, compressed_sm_sbm1,
320 NB_AVERAGE_SBM1_F0,
321 NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0,
322 ASM_F0_INDICE_START);
323 // 2) compute the BP1 set
324 428
325 // 3) send the basic parameters set 1 packet
326 BP1_send( current_node_sbm1_bp1_f0, SID_SBM1_BP1_F0, queue_id );
327 // 4) update current_node_sbm1_bp1_f0
328 current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next;
329 }
330 else
331 {
332 PRINTF1("ERR *** in MATR *** unexect event = %x\n", (unsigned int) event_out)
333 }
334 429 }
335 430 }
336 431
337 432 //*****************************
338 433 // Spectral matrices processing
339 434
340 void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
435 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
341 436 ring_node_sm *ring_node_tab[],
342 437 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
343 438 {
@@ -372,7 +467,7 void ASM_average( float *averaged_spec_m
372 467 }
373 468 else
374 469 {
375 PRINTF2("ERR *** in ASM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
470 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
376 471 }
377 472 }
378 473 }
@@ -521,65 +616,15 void ASM_send(Header_TM_LFR_SCIENCE_ASM_
521 616 }
522 617 }
523 618
524 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id )
619 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
525 620 {
526 unsigned int length = 0;
527 621 rtems_status_code status;
528 unsigned char nbBytesTosend;
529 622
530 // (1) BUILD THE DATA
531 switch(sid)
532 {
533 case SID_NORM_BP1_F0:
534 length = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0;
535 ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
536 ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
537 ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_F0) >> 8 ); // BLK_NR MSB
538 ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_F0); // BLK_NR LSB
539 nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0
540 + CCSDS_TC_TM_PACKET_OFFSET
541 + CCSDS_PROTOCOLE_EXTRA_BYTES;
542 case SID_SBM1_BP1_F0:
543 length = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0;
544 ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
545 ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
546 ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_SBM1_F0) >> 8 ); // BLK_NR MSB
547 ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_SBM1_F0); // BLK_NR LSB
548 nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0
549 + CCSDS_TC_TM_PACKET_OFFSET
550 + CCSDS_PROTOCOLE_EXTRA_BYTES;
551 break;
552 default:
553 nbBytesTosend = 0;
554 PRINTF1("ERR *** in BP1_send *** unexpected sid %d\n", sid)
555 break;
556 }
557
558 // (2) BUILD THE HEADER
559 ring_node_to_send->header.packetLength[0] = (unsigned char) (length>>8);
560 ring_node_to_send->header.packetLength[1] = (unsigned char) (length);
561 ring_node_to_send->header.sid = sid;
562
563 // (3) SET PACKET TIME
564 ring_node_to_send->header.time[0] = (unsigned char) (ring_node_to_send->coarseTime>>24);
565 ring_node_to_send->header.time[1] = (unsigned char) (ring_node_to_send->coarseTime>>16);
566 ring_node_to_send->header.time[2] = (unsigned char) (ring_node_to_send->coarseTime>>8);
567 ring_node_to_send->header.time[3] = (unsigned char) (ring_node_to_send->coarseTime);
568 ring_node_to_send->header.time[4] = (unsigned char) (ring_node_to_send->fineTime>>8);
569 ring_node_to_send->header.time[5] = (unsigned char) (ring_node_to_send->fineTime);
570 //
571 ring_node_to_send->header.acquisitionTime[0] = (unsigned char) (ring_node_to_send->coarseTime>>24);
572 ring_node_to_send->header.acquisitionTime[1] = (unsigned char) (ring_node_to_send->coarseTime>>16);
573 ring_node_to_send->header.acquisitionTime[2] = (unsigned char) (ring_node_to_send->coarseTime>>8);
574 ring_node_to_send->header.acquisitionTime[3] = (unsigned char) (ring_node_to_send->coarseTime);
575 ring_node_to_send->header.acquisitionTime[4] = (unsigned char) (ring_node_to_send->fineTime>>8);
576 ring_node_to_send->header.acquisitionTime[5] = (unsigned char) (ring_node_to_send->fineTime);
577
578 // (4) SEND PACKET
579 status = rtems_message_queue_send( queue_id, &ring_node_to_send->header, nbBytesTosend);
623 // SEND PACKET
624 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
580 625 if (status != RTEMS_SUCCESSFUL)
581 626 {
582 printf("ERR *** in BP1_send *** ERR %d\n", (int) status);
627 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
583 628 }
584 629 }
585 630
@@ -589,8 +634,8 void init_header_asm( Header_TM_LFR_SCIE
589 634 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
590 635 header->reserved = 0x00;
591 636 header->userApplication = CCSDS_USER_APP;
592 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
593 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
637 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
638 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
594 639 header->packetSequenceControl[0] = 0xc0;
595 640 header->packetSequenceControl[1] = 0x00;
596 641 header->packetLength[0] = 0x00;
@@ -615,52 +660,87 void init_header_asm( Header_TM_LFR_SCIE
615 660 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
616 661 }
617 662
618 void init_bp_ring_sbm1()
663 void init_bp_ring_sbm1_bp1( void )
664 {
665 unsigned int i;
666
667 //********
668 // F0 RING
669 bp_ring_sbm1_bp1[0].next = (ring_node_bp*) &bp_ring_sbm1_bp1[1];
670 bp_ring_sbm1_bp1[0].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1];
671
672 bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1].next = (ring_node_bp*) &bp_ring_sbm1_bp1[0];
673 bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-2];
674
675 for(i=1; i<NB_RING_NODES_SBM1_BP1-1; i++)
676 {
677 bp_ring_sbm1_bp1[i].next = (ring_node_bp*) &bp_ring_sbm1_bp1[i+1];
678 bp_ring_sbm1_bp1[i].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[i-1];
679 }
680 //
681 //********
682
683 for (i=0; i<NB_RING_NODES_SBM1_BP1; i++)
684 {
685 init_header_bp( &bp_ring_sbm1_bp1[ i ].header,
686 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
687 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0, NB_BINS_COMPRESSED_SM_SBM1_F0
688 );
689 bp_ring_sbm1_bp1[ i ].status = 0;
690 }
691 }
692
693 void init_bp_ring_sbm1_bp2( void )
619 694 {
620 695 unsigned int i;
621 696
622 697 //********
623 698 // F0 RING
624 bp_ring_sbm1[0].next = (ring_node_bp*) &bp_ring_sbm1[1];
625 bp_ring_sbm1[0].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1];
699 bp_ring_sbm1_bp2[0].next = (ring_node_bp*) &bp_ring_sbm1_bp2[1];
700 bp_ring_sbm1_bp2[0].previous = (ring_node_bp*) &bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-1];
626 701
627 bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].next = (ring_node_bp*) &bp_ring_sbm1[0];
628 bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_ASM_F0-2];
702 bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-1].next = (ring_node_bp*) &bp_ring_sbm1_bp2[0];
703 bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-1].previous = (ring_node_bp*) &bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-2];
629 704
630 for(i=1; i<NB_RING_NODES_BP1_SBM1-1; i++)
705 for(i=1; i<NB_RING_NODES_SBM1_BP2-1; i++)
631 706 {
632 bp_ring_sbm1[i].next = (ring_node_bp*) &bp_ring_sbm1[i+1];
633 bp_ring_sbm1[i].previous = (ring_node_bp*) &bp_ring_sbm1[i-1];
707 bp_ring_sbm1_bp2[i].next = (ring_node_bp*) &bp_ring_sbm1_bp2[i+1];
708 bp_ring_sbm1_bp2[i].previous = (ring_node_bp*) &bp_ring_sbm1_bp2[i-1];
634 709 }
635 710 //
636 711 //********
637 712
638 for (i=0; i<NB_RING_NODES_BP1_SBM1; i++)
713 for (i=0; i<NB_RING_NODES_SBM1_BP2; i++)
639 714 {
640 init_header_bp( (Header_TM_LFR_SCIENCE_BP_SBM_t*) &bp_ring_sbm1[ i ] );
641 bp_ring_sbm1[ i ].status = 0;
715 init_header_bp( &bp_ring_sbm1_bp2[ i ].header,
716 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
717 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP2_F0, NB_BINS_COMPRESSED_SM_SBM1_F0
718 );
719 bp_ring_sbm1_bp2[ i ].status = 0;
642 720 }
643 721 }
644 722
645 void init_header_bp(Header_TM_LFR_SCIENCE_BP_SBM_t *header )
723 void init_header_bp( Header_TM_LFR_SCIENCE_BP_t *header,
724 unsigned int apid, unsigned char sid,
725 unsigned int packetLength, unsigned char blkNr )
646 726 {
647 727 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
648 728 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
649 729 header->reserved = 0x00;
650 730 header->userApplication = CCSDS_USER_APP;
651 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
652 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
653 header->packetSequenceControl[0] = 0xc0;
731 header->packetID[0] = (unsigned char) (apid >> 8);
732 header->packetID[1] = (unsigned char) (apid);
733 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
654 734 header->packetSequenceControl[1] = 0x00;
655 header->packetLength[0] = 0x00;
656 header->packetLength[1] = 0x00;
735 header->packetLength[0] = (unsigned char) (packetLength >> 8);
736 header->packetLength[1] = (unsigned char) (packetLength);
657 737 // DATA FIELD HEADER
658 738 header->spare1_pusVersion_spare2 = 0x10;
659 739 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
660 740 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
661 741 header->destinationID = TM_DESTINATION_ID_GROUND;
662 742 // AUXILIARY DATA HEADER
663 header->sid = 0x00;
743 header->sid = sid;
664 744 header->biaStatusInfo = 0x00;
665 745 header->time[0] = 0x00;
666 746 header->time[0] = 0x00;
@@ -669,7 +749,39 void init_header_bp(Header_TM_LFR_SCIENC
669 749 header->time[0] = 0x00;
670 750 header->time[0] = 0x00;
671 751 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
672 header->pa_lfr_bp_blk_nr[1] = 0x00; // BLK_NR LSB
752 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
753 }
754
755 void init_header_bp_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
756 unsigned int apid, unsigned char sid,
757 unsigned int packetLength , unsigned char blkNr)
758 {
759 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
760 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
761 header->reserved = 0x00;
762 header->userApplication = CCSDS_USER_APP;
763 header->packetID[0] = (unsigned char) (apid >> 8);
764 header->packetID[1] = (unsigned char) (apid);
765 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
766 header->packetSequenceControl[1] = 0x00;
767 header->packetLength[0] = (unsigned char) (packetLength >> 8);
768 header->packetLength[1] = (unsigned char) (packetLength);
769 // DATA FIELD HEADER
770 header->spare1_pusVersion_spare2 = 0x10;
771 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
772 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
773 header->destinationID = TM_DESTINATION_ID_GROUND;
774 // AUXILIARY DATA HEADER
775 header->sid = sid;
776 header->biaStatusInfo = 0x00;
777 header->time[0] = 0x00;
778 header->time[0] = 0x00;
779 header->time[0] = 0x00;
780 header->time[0] = 0x00;
781 header->time[0] = 0x00;
782 header->time[0] = 0x00;
783 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
784 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
673 785 }
674 786
675 787 void reset_spectral_matrix_regs( void )
@@ -699,6 +811,14 void reset_spectral_matrix_regs( void )
699 811 //******************
700 812 // general functions
701 813
814 void set_time( unsigned char *time, unsigned int coarseTime, unsigned int fineTime )
815 {
816 time[0] = (unsigned char) (coarseTime>>24);
817 time[1] = (unsigned char) (coarseTime>>16);
818 time[2] = (unsigned char) (coarseTime>>8);
819 time[3] = (unsigned char) (coarseTime);
820 time[4] = (unsigned char) (fineTime>>8);
821 time[5] = (unsigned char) (fineTime);
822 }
702 823
703 824
704
@@ -699,6 +699,7 void launch_spectral_matrix( unsigned ch
699 699 {
700 700 reset_nb_sm_f0();
701 701 reset_current_sm_ring_nodes();
702 reset_current_bp_ring_nodes();
702 703 reset_spectral_matrix_regs();
703 704
704 705 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
@@ -740,6 +741,7 void launch_spectral_matrix_simu( unsign
740 741 {
741 742 reset_nb_sm_f0();
742 743 reset_current_sm_ring_nodes();
744 reset_current_bp_ring_nodes();
743 745 reset_spectral_matrix_regs();
744 746
745 747 // Spectral Matrices simulator
@@ -479,8 +479,8 void init_parameter_dump( void )
479 479 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
480 480 parameter_dump_packet.reserved = CCSDS_RESERVED;
481 481 parameter_dump_packet.userApplication = CCSDS_USER_APP;
482 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
483 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
482 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
483 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
484 484 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
485 485 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
486 486 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
@@ -41,8 +41,8 int send_tm_lfr_tc_exe_success( ccsdsTel
41 41 TM.reserved = DEFAULT_RESERVED;
42 42 TM.userApplication = CCSDS_USER_APP;
43 43 // PACKET HEADER
44 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
45 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
44 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
45 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
46 46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
48 48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
@@ -106,8 +106,8 int send_tm_lfr_tc_exe_inconsistent( ccs
106 106 TM.reserved = DEFAULT_RESERVED;
107 107 TM.userApplication = CCSDS_USER_APP;
108 108 // PACKET HEADER
109 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
110 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
109 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
110 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
111 111 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
112 112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
113 113 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
@@ -174,8 +174,8 int send_tm_lfr_tc_exe_not_executable( c
174 174 TM.reserved = DEFAULT_RESERVED;
175 175 TM.userApplication = CCSDS_USER_APP;
176 176 // PACKET HEADER
177 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
178 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
177 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
178 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
179 179 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
180 180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
181 181 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
@@ -242,8 +242,8 int send_tm_lfr_tc_exe_not_implemented(
242 242 TM.reserved = DEFAULT_RESERVED;
243 243 TM.userApplication = CCSDS_USER_APP;
244 244 // PACKET HEADER
245 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
246 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
245 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
246 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
247 247 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
248 248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
249 249 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
@@ -308,8 +308,8 int send_tm_lfr_tc_exe_error( ccsdsTelec
308 308 TM.reserved = DEFAULT_RESERVED;
309 309 TM.userApplication = CCSDS_USER_APP;
310 310 // PACKET HEADER
311 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
312 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
311 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
312 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
313 313 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
314 314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
315 315 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
@@ -383,8 +383,8 int send_tm_lfr_tc_exe_corrupted(ccsdsTe
383 383 TM.reserved = DEFAULT_RESERVED;
384 384 TM.userApplication = CCSDS_USER_APP;
385 385 // PACKET HEADER
386 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
387 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
386 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
387 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
388 388 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
389 389 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
390 390 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
@@ -581,8 +581,8 int init_header_snapshot_wf_table( unsig
581 581 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
582 582 headerSWF[ i ].reserved = DEFAULT_RESERVED;
583 583 headerSWF[ i ].userApplication = CCSDS_USER_APP;
584 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
585 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
584 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
585 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
586 586 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
587 587 if (i == 6)
588 588 {
@@ -631,13 +631,13 int init_header_continuous_wf_table( uns
631 631 headerCWF[ i ].userApplication = CCSDS_USER_APP;
632 632 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
633 633 {
634 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
635 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
634 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
635 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
636 636 }
637 637 else
638 638 {
639 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
640 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
639 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
640 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
641 641 }
642 642 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
643 643 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
@@ -674,8 +674,8 int init_header_continuous_cwf3_light_ta
674 674 headerCWF[ i ].reserved = DEFAULT_RESERVED;
675 675 headerCWF[ i ].userApplication = CCSDS_USER_APP;
676 676
677 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
678 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
677 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
678 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
679 679
680 680 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
681 681 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
General Comments 0
You need to be logged in to leave comments. Login now