##// END OF EJS Templates
Minor changes before going back to VHDLib206
paul -
r72:890d9198a9aa nov2013
parent child
Show More
@@ -1,1227 +1,1224
1 /** Functions and tasks related to waveform packet generation.
1 /** Functions and tasks related to waveform packet generation.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
7 *
8 */
8 */
9
9
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 // SWF
12 // SWF
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 // CWF
16 // CWF
17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22
22
23 unsigned char doubleSendCWF1 = 0;
23 unsigned char doubleSendCWF1 = 0;
24 unsigned char doubleSendCWF2 = 0;
24 unsigned char doubleSendCWF2 = 0;
25
25
26 rtems_isr waveforms_isr( rtems_vector_number vector )
26 rtems_isr waveforms_isr( rtems_vector_number vector )
27 {
27 {
28 /** This is the interrupt sub routine called by the waveform picker core.
28 /** This is the interrupt sub routine called by the waveform picker core.
29 *
29 *
30 * This ISR launch different actions depending mainly on two pieces of information:
30 * This ISR launch different actions depending mainly on two pieces of information:
31 * 1. the values read in the registers of the waveform picker.
31 * 1. the values read in the registers of the waveform picker.
32 * 2. the current LFR mode.
32 * 2. the current LFR mode.
33 *
33 *
34 */
34 */
35
35
36 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
36 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
37 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff00f; // clear new_err and full_err
37 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff00f; // clear new_err and full_err
38
38
39 #ifdef GSA
39 #ifdef GSA
40 #else
40 #else
41 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
41 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
42 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
42 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
43 { // in modes other than STANDBY and BURST, send the CWF_F3 data
43 { // in modes other than STANDBY and BURST, send the CWF_F3 data
44 if ((new_waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
44 if ((new_waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
45 // (1) change the receiving buffer for the waveform picker
45 // (1) change the receiving buffer for the waveform picker
46 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
46 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
47 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
47 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
48 }
48 }
49 else {
49 else {
50 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
50 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
51 }
51 }
52 // (2) send an event for the waveforms transmission
52 // (2) send an event for the waveforms transmission
53 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
53 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
54 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
54 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
55 }
55 }
56 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
56 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
57 }
57 }
58 }
58 }
59 #endif
59 #endif
60
60
61 switch(lfrCurrentMode)
61 switch(lfrCurrentMode)
62 {
62 {
63 //********
63 //********
64 // STANDBY
64 // STANDBY
65 case(LFR_MODE_STANDBY):
65 case(LFR_MODE_STANDBY):
66 break;
66 break;
67
67
68 //******
68 //******
69 // NORMAL
69 // NORMAL
70 case(LFR_MODE_NORMAL):
70 case(LFR_MODE_NORMAL):
71 #ifdef GSA
71 #ifdef GSA
72 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
72 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
73 #else
73 #else
74 if ( (new_waveform_picker_regs->run_burst_enable & 0x7) == 0x0 ){ // if no channel is enable
74 if ( (new_waveform_picker_regs->run_burst_enable & 0x7) == 0x0 ){ // if no channel is enable
75 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
75 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
76 }
76 }
77 else {
77 else {
78 if ( (new_waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
78 if ( (new_waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
79 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable & 0x08;
80 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
79 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
81 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
80 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
82 }
81 }
83 // new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0x00;
84 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
82 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
85 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x07; // [0111] enable f2 f1 f0
86 }
83 }
87 }
84 }
88 #endif
85 #endif
89 break;
86 break;
90
87
91 //******
88 //******
92 // BURST
89 // BURST
93 case(LFR_MODE_BURST):
90 case(LFR_MODE_BURST):
94 #ifdef GSA
91 #ifdef GSA
95 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
96 #else
93 #else
97 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
94 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
98 // (1) change the receiving buffer for the waveform picker
95 // (1) change the receiving buffer for the waveform picker
99 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
96 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
100 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
97 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
101 }
98 }
102 else {
99 else {
103 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
100 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
104 }
101 }
105 // (2) send an event for the waveforms transmission
102 // (2) send an event for the waveforms transmission
106 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
107 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
108 }
105 }
109 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
106 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
110 }
107 }
111 #endif
108 #endif
112 break;
109 break;
113
110
114 //*****
111 //*****
115 // SBM1
112 // SBM1
116 case(LFR_MODE_SBM1):
113 case(LFR_MODE_SBM1):
117 #ifdef GSA
114 #ifdef GSA
118 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
119 #else
116 #else
120 if ((new_waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
117 if ((new_waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
121 // (1) change the receiving buffer for the waveform picker
118 // (1) change the receiving buffer for the waveform picker
122 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
123 {
120 {
124 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
121 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
125 }
122 }
126 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
123 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
127 {
124 {
128 doubleSendCWF1 = 1;
125 doubleSendCWF1 = 1;
129 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
126 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
130 }
127 }
131 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
128 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
132 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
129 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
133 }
130 }
134 else {
131 else {
135 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
132 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
136 }
133 }
137 // (2) send an event for the waveforms transmission
134 // (2) send an event for the waveforms transmission
138 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
139 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
140 }
137 }
141 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
138 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
142 }
139 }
143 if ( ( (new_waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
140 if ( ( (new_waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
144 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
145 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
146 }
143 }
147 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
144 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
148 reset_local_sbm1_nb_cwf_sent();
145 reset_local_sbm1_nb_cwf_sent();
149 }
146 }
150
147
151 #endif
148 #endif
152 break;
149 break;
153
150
154 //*****
151 //*****
155 // SBM2
152 // SBM2
156 case(LFR_MODE_SBM2):
153 case(LFR_MODE_SBM2):
157 #ifdef GSA
154 #ifdef GSA
158 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
159 #else
156 #else
160 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
157 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
161 // (1) change the receiving buffer for the waveform picker
158 // (1) change the receiving buffer for the waveform picker
162 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
163 {
160 {
164 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
161 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
165 }
162 }
166 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
163 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
167 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
164 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
168 doubleSendCWF2 = 1;
165 doubleSendCWF2 = 1;
169 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
170 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
171 }
168 }
172 reset_local_sbm2_nb_cwf_sent();
169 reset_local_sbm2_nb_cwf_sent();
173 }
170 }
174 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
171 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
175 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
172 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
176 }
173 }
177 else {
174 else {
178 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
175 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
179 }
176 }
180 // (2) send an event for the waveforms transmission
177 // (2) send an event for the waveforms transmission
181 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
182 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
183 }
180 }
184 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
181 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
185 }
182 }
186 if ( ( (new_waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
183 if ( ( (new_waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
187 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
188 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
189 }
186 }
190 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
187 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
191 }
188 }
192 #endif
189 #endif
193 break;
190 break;
194
191
195 //********
192 //********
196 // DEFAULT
193 // DEFAULT
197 default:
194 default:
198 break;
195 break;
199 }
196 }
200 }
197 }
201
198
202 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
203 {
200 {
204 /** This is the interrupt sub routine called by the waveform picker simulator.
201 /** This is the interrupt sub routine called by the waveform picker simulator.
205 *
202 *
206 * This ISR is for debug purpose only.
203 * This ISR is for debug purpose only.
207 *
204 *
208 */
205 */
209
206
210 unsigned char lfrMode;
207 unsigned char lfrMode;
211 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
212
209
213 switch(lfrMode) {
210 switch(lfrMode) {
214 case (LFR_MODE_STANDBY):
211 case (LFR_MODE_STANDBY):
215 break;
212 break;
216 case (LFR_MODE_NORMAL):
213 case (LFR_MODE_NORMAL):
217 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
218 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
219 }
216 }
220 break;
217 break;
221 case (LFR_MODE_BURST):
218 case (LFR_MODE_BURST):
222 break;
219 break;
223 case (LFR_MODE_SBM1):
220 case (LFR_MODE_SBM1):
224 break;
221 break;
225 case (LFR_MODE_SBM2):
222 case (LFR_MODE_SBM2):
226 break;
223 break;
227 }
224 }
228 }
225 }
229
226
230 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
231 {
228 {
232 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
233 *
230 *
234 * @param unused is the starting argument of the RTEMS task
231 * @param unused is the starting argument of the RTEMS task
235 *
232 *
236 * The following data packets are sent by this task:
233 * The following data packets are sent by this task:
237 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
238 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
239 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
240 *
237 *
241 */
238 */
242
239
243 rtems_event_set event_out;
240 rtems_event_set event_out;
244 rtems_id queue_id;
241 rtems_id queue_id;
245
242
246 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
243 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
247 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
244 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
248 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
245 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
249
246
250 init_waveforms();
247 init_waveforms();
251
248
252 queue_id = get_pkts_queue_id();
249 queue_id = get_pkts_queue_id();
253
250
254 BOOT_PRINTF("in WFRM ***\n")
251 BOOT_PRINTF("in WFRM ***\n")
255
252
256 while(1){
253 while(1){
257 // wait for an RTEMS_EVENT
254 // wait for an RTEMS_EVENT
258 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
255 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
259 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
256 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
260 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
257 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
261
258
262 if (event_out == RTEMS_EVENT_MODE_NORMAL)
259 if (event_out == RTEMS_EVENT_MODE_NORMAL)
263 {
260 {
264 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
261 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
265 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
262 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
266 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
263 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
267 #ifdef GSA
264 #ifdef GSA
268 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
265 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
269 #endif
266 #endif
270 }
267 }
271 else if (event_out == RTEMS_EVENT_MODE_SBM1)
268 else if (event_out == RTEMS_EVENT_MODE_SBM1)
272 {
269 {
273 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
270 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
274 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
271 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
275 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
272 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
276 #ifdef GSA
273 #ifdef GSA
277 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
274 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
278 #endif
275 #endif
279 }
276 }
280 else if (event_out == RTEMS_EVENT_MODE_SBM2)
277 else if (event_out == RTEMS_EVENT_MODE_SBM2)
281 {
278 {
282 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
279 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
283 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
280 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
284 #ifdef GSA
281 #ifdef GSA
285 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
282 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
286 #endif
283 #endif
287 }
284 }
288 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
285 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
289 {
286 {
290 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
287 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
291 }
288 }
292 else
289 else
293 {
290 {
294 PRINTF("in WFRM *** unexpected event")
291 PRINTF("in WFRM *** unexpected event")
295 }
292 }
296
293
297
294
298 #ifdef GSA
295 #ifdef GSA
299 // irq processed, reset the related register of the timer unit
296 // irq processed, reset the related register of the timer unit
300 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
297 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
301 // clear the interruption
298 // clear the interruption
302 LEON_Unmask_interrupt( IRQ_WF );
299 LEON_Unmask_interrupt( IRQ_WF );
303 #endif
300 #endif
304 }
301 }
305 }
302 }
306
303
307 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
308 {
305 {
309 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
310 *
307 *
311 * @param unused is the starting argument of the RTEMS task
308 * @param unused is the starting argument of the RTEMS task
312 *
309 *
313 * The following data packet is sent by this task:
310 * The following data packet is sent by this task:
314 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
315 *
312 *
316 */
313 */
317
314
318 rtems_event_set event_out;
315 rtems_event_set event_out;
319 rtems_id queue_id;
316 rtems_id queue_id;
320
317
321 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
318 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
322 init_header_continuous_wf3_light_table( headerCWF_F3_light );
319 init_header_continuous_wf3_light_table( headerCWF_F3_light );
323
320
324 queue_id = get_pkts_queue_id();
321 queue_id = get_pkts_queue_id();
325
322
326 BOOT_PRINTF("in CWF3 ***\n")
323 BOOT_PRINTF("in CWF3 ***\n")
327
324
328 while(1){
325 while(1){
329 // wait for an RTEMS_EVENT
326 // wait for an RTEMS_EVENT
330 rtems_event_receive( RTEMS_EVENT_0,
327 rtems_event_receive( RTEMS_EVENT_0,
331 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
328 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
332 PRINTF("send CWF F3 \n")
329 PRINTF("send CWF F3 \n")
333 #ifdef GSA
330 #ifdef GSA
334 #else
331 #else
335 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
332 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
336 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
333 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
337 }
334 }
338 else {
335 else {
339 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
336 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
340 }
337 }
341 #endif
338 #endif
342 }
339 }
343 }
340 }
344
341
345 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
342 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
346 {
343 {
347 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
344 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
348 *
345 *
349 * @param unused is the starting argument of the RTEMS task
346 * @param unused is the starting argument of the RTEMS task
350 *
347 *
351 * The following data packet is sent by this function:
348 * The following data packet is sent by this function:
352 * - TM_LFR_SCIENCE_BURST_CWF_F2
349 * - TM_LFR_SCIENCE_BURST_CWF_F2
353 * - TM_LFR_SCIENCE_SBM2_CWF_F2
350 * - TM_LFR_SCIENCE_SBM2_CWF_F2
354 *
351 *
355 */
352 */
356
353
357 rtems_event_set event_out;
354 rtems_event_set event_out;
358 rtems_id queue_id;
355 rtems_id queue_id;
359
356
360 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
357 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
361 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
358 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
362
359
363 queue_id = get_pkts_queue_id();
360 queue_id = get_pkts_queue_id();
364
361
365 BOOT_PRINTF("in CWF2 ***\n")
362 BOOT_PRINTF("in CWF2 ***\n")
366
363
367 while(1){
364 while(1){
368 // wait for an RTEMS_EVENT
365 // wait for an RTEMS_EVENT
369 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
366 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
370 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
371
368
372 if (event_out == RTEMS_EVENT_MODE_BURST)
369 if (event_out == RTEMS_EVENT_MODE_BURST)
373 {
370 {
374 // F2
371 // F2
375 #ifdef GSA
372 #ifdef GSA
376 #else
373 #else
377 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
374 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
378 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
375 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
379 }
376 }
380 else {
377 else {
381 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
378 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
382 }
379 }
383 #endif
380 #endif
384 }
381 }
385
382
386 else if (event_out == RTEMS_EVENT_MODE_SBM2)
383 else if (event_out == RTEMS_EVENT_MODE_SBM2)
387 {
384 {
388 #ifdef GSA
385 #ifdef GSA
389 #else
386 #else
390 if (doubleSendCWF2 == 1)
387 if (doubleSendCWF2 == 1)
391 {
388 {
392 doubleSendCWF2 = 0;
389 doubleSendCWF2 = 0;
393 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
390 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
394 }
391 }
395 else if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
392 else if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
396 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
393 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
397 }
394 }
398 else {
395 else {
399 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
396 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
400 }
397 }
401 param_local.local_sbm2_nb_cwf_sent ++;
398 param_local.local_sbm2_nb_cwf_sent ++;
402 #endif
399 #endif
403 }
400 }
404 else
401 else
405 {
402 {
406 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
403 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
407 }
404 }
408 }
405 }
409 }
406 }
410
407
411 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
408 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
412 {
409 {
413 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
410 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
414 *
411 *
415 * @param unused is the starting argument of the RTEMS task
412 * @param unused is the starting argument of the RTEMS task
416 *
413 *
417 * The following data packet is sent by this function:
414 * The following data packet is sent by this function:
418 * - TM_LFR_SCIENCE_SBM1_CWF_F1
415 * - TM_LFR_SCIENCE_SBM1_CWF_F1
419 *
416 *
420 */
417 */
421
418
422 rtems_event_set event_out;
419 rtems_event_set event_out;
423 rtems_id queue_id;
420 rtems_id queue_id;
424
421
425 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
422 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
426
423
427 queue_id = get_pkts_queue_id();
424 queue_id = get_pkts_queue_id();
428
425
429 BOOT_PRINTF("in CWF1 ***\n")
426 BOOT_PRINTF("in CWF1 ***\n")
430
427
431 while(1){
428 while(1){
432 // wait for an RTEMS_EVENT
429 // wait for an RTEMS_EVENT
433 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
430 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
434 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
431 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
435 if (event_out == RTEMS_EVENT_MODE_SBM1)
432 if (event_out == RTEMS_EVENT_MODE_SBM1)
436 {
433 {
437 #ifdef GSA
434 #ifdef GSA
438 #else
435 #else
439 if (doubleSendCWF1 == 1)
436 if (doubleSendCWF1 == 1)
440 {
437 {
441 doubleSendCWF1 = 0;
438 doubleSendCWF1 = 0;
442 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
439 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
443 }
440 }
444 else if (new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
441 else if (new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
445 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
442 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
446 }
443 }
447 else {
444 else {
448 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
445 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
449 }
446 }
450 param_local.local_sbm1_nb_cwf_sent ++;
447 param_local.local_sbm1_nb_cwf_sent ++;
451 #endif
448 #endif
452 }
449 }
453 else
450 else
454 {
451 {
455 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
452 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
456 }
453 }
457 }
454 }
458 }
455 }
459
456
460 //******************
457 //******************
461 // general functions
458 // general functions
462 void init_waveforms( void )
459 void init_waveforms( void )
463 {
460 {
464 int i = 0;
461 int i = 0;
465
462
466 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
463 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
467 {
464 {
468 //***
465 //***
469 // F0
466 // F0
470 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
467 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
471 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
468 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
472 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
469 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
473
470
474 //***
471 //***
475 // F1
472 // F1
476 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
473 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
477 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
474 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
478 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
475 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
479
476
480 //***
477 //***
481 // F2
478 // F2
482 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
479 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
483 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
480 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
484 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
481 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
485
482
486 //***
483 //***
487 // F3
484 // F3
488 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
485 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
489 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
486 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
490 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
487 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
491 }
488 }
492 }
489 }
493
490
494 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
491 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
495 {
492 {
496 unsigned char i;
493 unsigned char i;
497
494
498 for (i=0; i<7; i++)
495 for (i=0; i<7; i++)
499 {
496 {
500 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
497 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
501 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
498 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
502 headerSWF[ i ].reserved = DEFAULT_RESERVED;
499 headerSWF[ i ].reserved = DEFAULT_RESERVED;
503 headerSWF[ i ].userApplication = CCSDS_USER_APP;
500 headerSWF[ i ].userApplication = CCSDS_USER_APP;
504 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
501 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
505 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
502 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
506 if (i == 0)
503 if (i == 0)
507 {
504 {
508 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
505 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
509 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
506 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
510 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
507 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
511 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
508 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
512 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
509 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
513 }
510 }
514 else if (i == 6)
511 else if (i == 6)
515 {
512 {
516 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
513 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
517 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
514 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
518 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
515 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
519 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
516 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
520 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
517 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
521 }
518 }
522 else
519 else
523 {
520 {
524 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
521 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
525 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
522 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
526 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
523 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
527 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
524 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
528 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
525 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
529 }
526 }
530 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
527 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
531 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
528 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
532 headerSWF[ i ].pktNr = i+1; // PKT_NR
529 headerSWF[ i ].pktNr = i+1; // PKT_NR
533 // DATA FIELD HEADER
530 // DATA FIELD HEADER
534 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
531 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
535 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
532 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
536 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
533 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
537 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
534 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
538 // AUXILIARY DATA HEADER
535 // AUXILIARY DATA HEADER
539 headerSWF[ i ].sid = sid;
536 headerSWF[ i ].sid = sid;
540 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
537 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
541 headerSWF[ i ].time[0] = 0x00;
538 headerSWF[ i ].time[0] = 0x00;
542 headerSWF[ i ].time[0] = 0x00;
539 headerSWF[ i ].time[0] = 0x00;
543 headerSWF[ i ].time[0] = 0x00;
540 headerSWF[ i ].time[0] = 0x00;
544 headerSWF[ i ].time[0] = 0x00;
541 headerSWF[ i ].time[0] = 0x00;
545 headerSWF[ i ].time[0] = 0x00;
542 headerSWF[ i ].time[0] = 0x00;
546 headerSWF[ i ].time[0] = 0x00;
543 headerSWF[ i ].time[0] = 0x00;
547 }
544 }
548 return LFR_SUCCESSFUL;
545 return LFR_SUCCESSFUL;
549 }
546 }
550
547
551 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
548 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
552 {
549 {
553 unsigned int i;
550 unsigned int i;
554
551
555 for (i=0; i<7; i++)
552 for (i=0; i<7; i++)
556 {
553 {
557 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
554 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
558 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
555 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
559 headerCWF[ i ].reserved = DEFAULT_RESERVED;
556 headerCWF[ i ].reserved = DEFAULT_RESERVED;
560 headerCWF[ i ].userApplication = CCSDS_USER_APP;
557 headerCWF[ i ].userApplication = CCSDS_USER_APP;
561 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
558 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
562 {
559 {
563 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
560 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
564 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
561 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
565 }
562 }
566 else
563 else
567 {
564 {
568 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
565 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
569 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
566 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
570 }
567 }
571 if (i == 0)
568 if (i == 0)
572 {
569 {
573 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
570 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
574 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
571 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
575 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
572 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
576 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
573 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
577 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
574 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
578 }
575 }
579 else if (i == 6)
576 else if (i == 6)
580 {
577 {
581 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
578 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
582 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
579 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
583 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
580 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
584 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
581 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
585 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
582 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
586 }
583 }
587 else
584 else
588 {
585 {
589 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
586 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
590 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
587 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
591 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
588 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
592 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
589 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
593 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
590 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
594 }
591 }
595 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
592 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
596 // PKT_CNT
593 // PKT_CNT
597 // PKT_NR
594 // PKT_NR
598 // DATA FIELD HEADER
595 // DATA FIELD HEADER
599 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
596 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
600 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
597 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
601 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
598 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
602 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
599 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
603 // AUXILIARY DATA HEADER
600 // AUXILIARY DATA HEADER
604 headerCWF[ i ].sid = sid;
601 headerCWF[ i ].sid = sid;
605 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
602 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
606 headerCWF[ i ].time[0] = 0x00;
603 headerCWF[ i ].time[0] = 0x00;
607 headerCWF[ i ].time[0] = 0x00;
604 headerCWF[ i ].time[0] = 0x00;
608 headerCWF[ i ].time[0] = 0x00;
605 headerCWF[ i ].time[0] = 0x00;
609 headerCWF[ i ].time[0] = 0x00;
606 headerCWF[ i ].time[0] = 0x00;
610 headerCWF[ i ].time[0] = 0x00;
607 headerCWF[ i ].time[0] = 0x00;
611 headerCWF[ i ].time[0] = 0x00;
608 headerCWF[ i ].time[0] = 0x00;
612 }
609 }
613 return LFR_SUCCESSFUL;
610 return LFR_SUCCESSFUL;
614 }
611 }
615
612
616 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
613 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
617 {
614 {
618 unsigned int i;
615 unsigned int i;
619
616
620 for (i=0; i<7; i++)
617 for (i=0; i<7; i++)
621 {
618 {
622 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
619 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
623 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
620 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
624 headerCWF[ i ].reserved = DEFAULT_RESERVED;
621 headerCWF[ i ].reserved = DEFAULT_RESERVED;
625 headerCWF[ i ].userApplication = CCSDS_USER_APP;
622 headerCWF[ i ].userApplication = CCSDS_USER_APP;
626
623
627 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
624 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
628 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
625 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
629 if (i == 0)
626 if (i == 0)
630 {
627 {
631 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
628 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
632 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
629 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
633 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
630 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
634 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
631 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
635 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
632 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
636 }
633 }
637 else if (i == 6)
634 else if (i == 6)
638 {
635 {
639 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
636 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
640 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
637 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
641 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
638 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
642 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
639 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
643 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
640 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
644 }
641 }
645 else
642 else
646 {
643 {
647 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
648 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
649 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
650 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
651 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
652 }
649 }
653 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
654 // DATA FIELD HEADER
651 // DATA FIELD HEADER
655 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
656 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
657 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
658 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
659 // AUXILIARY DATA HEADER
656 // AUXILIARY DATA HEADER
660 headerCWF[ i ].sid = SID_NORM_CWF_F3;
657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
661 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
662 headerCWF[ i ].time[0] = 0x00;
659 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
660 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
661 headerCWF[ i ].time[0] = 0x00;
665 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
666 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
667 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
668 }
665 }
669 return LFR_SUCCESSFUL;
666 return LFR_SUCCESSFUL;
670 }
667 }
671
668
672 void reset_waveforms( void )
669 void reset_waveforms( void )
673 {
670 {
674 int i = 0;
671 int i = 0;
675
672
676 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
673 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
677 {
674 {
678 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
675 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
679 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
676 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
680 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
677 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
681
678
682 //***
679 //***
683 // F1
680 // F1
684 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
681 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
685 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
682 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
686 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
683 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
687
684
688 //***
685 //***
689 // F2
686 // F2
690 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
687 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
691 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
688 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
692 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
689 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
693
690
694 //***
691 //***
695 // F3
692 // F3
696 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
693 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
697 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
694 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
698 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
695 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
699 }
696 }
700 }
697 }
701
698
702 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
699 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
703 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
700 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
704 {
701 {
705 /** This function sends SWF CCSDS packets (F2, F1 or F0).
702 /** This function sends SWF CCSDS packets (F2, F1 or F0).
706 *
703 *
707 * @param waveform points to the buffer containing the data that will be send.
704 * @param waveform points to the buffer containing the data that will be send.
708 * @param sid is the source identifier of the data that will be sent.
705 * @param sid is the source identifier of the data that will be sent.
709 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
706 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
710 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
707 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
711 * contain information to setup the transmission of the data packets.
708 * contain information to setup the transmission of the data packets.
712 *
709 *
713 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
710 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
714 *
711 *
715 */
712 */
716
713
717 unsigned int i;
714 unsigned int i;
718 int ret;
715 int ret;
719 rtems_status_code status;
716 rtems_status_code status;
720 spw_ioctl_pkt_send spw_ioctl_send_SWF;
717 spw_ioctl_pkt_send spw_ioctl_send_SWF;
721
718
722 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
719 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
723 spw_ioctl_send_SWF.options = 0;
720 spw_ioctl_send_SWF.options = 0;
724
721
725 ret = LFR_DEFAULT;
722 ret = LFR_DEFAULT;
726
723
727 for (i=0; i<7; i++) // send waveform
724 for (i=0; i<7; i++) // send waveform
728 {
725 {
729 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
726 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
730 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
727 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
731 // BUILD THE DATA
728 // BUILD THE DATA
732 if (i==6) {
729 if (i==6) {
733 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
730 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
734 }
731 }
735 else {
732 else {
736 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
733 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
737 }
734 }
738 // SET PACKET SEQUENCE COUNTER
735 // SET PACKET SEQUENCE COUNTER
739 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
736 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
740 // SET PACKET TIME
737 // SET PACKET TIME
741 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
738 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
742 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
739 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
743 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
740 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
744 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
741 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
745 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
742 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
746 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
743 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
747 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
744 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
748 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
745 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
749 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
746 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
750 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
747 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
751 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
748 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
752 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
749 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
753 // SEND PACKET
750 // SEND PACKET
754 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
751 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
755 if (status != RTEMS_SUCCESSFUL) {
752 if (status != RTEMS_SUCCESSFUL) {
756 printf("%d-%d, ERR %d\n", sid, i, (int) status);
753 printf("%d-%d, ERR %d\n", sid, i, (int) status);
757 ret = LFR_DEFAULT;
754 ret = LFR_DEFAULT;
758 }
755 }
759 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
756 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
760 }
757 }
761
758
762 return ret;
759 return ret;
763 }
760 }
764
761
765 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
762 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
766 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
763 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
767 {
764 {
768 /** This function sends CWF CCSDS packets (F2, F1 or F0).
765 /** This function sends CWF CCSDS packets (F2, F1 or F0).
769 *
766 *
770 * @param waveform points to the buffer containing the data that will be send.
767 * @param waveform points to the buffer containing the data that will be send.
771 * @param sid is the source identifier of the data that will be sent.
768 * @param sid is the source identifier of the data that will be sent.
772 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
769 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
773 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
770 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
774 * contain information to setup the transmission of the data packets.
771 * contain information to setup the transmission of the data packets.
775 *
772 *
776 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
773 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
777 *
774 *
778 */
775 */
779
776
780 unsigned int i;
777 unsigned int i;
781 int ret;
778 int ret;
782 rtems_status_code status;
779 rtems_status_code status;
783 spw_ioctl_pkt_send spw_ioctl_send_CWF;
780 spw_ioctl_pkt_send spw_ioctl_send_CWF;
784
781
785 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
782 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
786 spw_ioctl_send_CWF.options = 0;
783 spw_ioctl_send_CWF.options = 0;
787
784
788 ret = LFR_DEFAULT;
785 ret = LFR_DEFAULT;
789
786
790 for (i=0; i<7; i++) // send waveform
787 for (i=0; i<7; i++) // send waveform
791 {
788 {
792 int coarseTime = 0x00;
789 int coarseTime = 0x00;
793 int fineTime = 0x00;
790 int fineTime = 0x00;
794 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
791 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
795 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
792 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
796 // BUILD THE DATA
793 // BUILD THE DATA
797 if (i==6) {
794 if (i==6) {
798 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
795 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
799 }
796 }
800 else {
797 else {
801 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
798 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
802 }
799 }
803 // SET PACKET SEQUENCE COUNTER
800 // SET PACKET SEQUENCE COUNTER
804 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
801 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
805 // SET PACKET TIME
802 // SET PACKET TIME
806 coarseTime = time_management_regs->coarse_time;
803 coarseTime = time_management_regs->coarse_time;
807 fineTime = time_management_regs->fine_time;
804 fineTime = time_management_regs->fine_time;
808 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
805 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
809 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
806 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
810 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
807 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
811 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
808 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
812 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
809 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
813 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
810 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
814 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
811 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
815 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
812 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
816 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
813 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
817 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
814 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
818 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
815 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
819 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
816 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
820 // SEND PACKET
817 // SEND PACKET
821 if (sid == SID_NORM_CWF_F3)
818 if (sid == SID_NORM_CWF_F3)
822 {
819 {
823 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
820 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
824 if (status != RTEMS_SUCCESSFUL) {
821 if (status != RTEMS_SUCCESSFUL) {
825 printf("%d-%d, ERR %d\n", sid, i, (int) status);
822 printf("%d-%d, ERR %d\n", sid, i, (int) status);
826 ret = LFR_DEFAULT;
823 ret = LFR_DEFAULT;
827 }
824 }
828 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
825 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
829 }
826 }
830 else
827 else
831 {
828 {
832 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
829 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
833 if (status != RTEMS_SUCCESSFUL) {
830 if (status != RTEMS_SUCCESSFUL) {
834 printf("%d-%d, ERR %d\n", sid, i, (int) status);
831 printf("%d-%d, ERR %d\n", sid, i, (int) status);
835 ret = LFR_DEFAULT;
832 ret = LFR_DEFAULT;
836 }
833 }
837 }
834 }
838 }
835 }
839
836
840 return ret;
837 return ret;
841 }
838 }
842
839
843 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
840 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
844 {
841 {
845 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
842 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
846 *
843 *
847 * @param waveform points to the buffer containing the data that will be send.
844 * @param waveform points to the buffer containing the data that will be send.
848 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
845 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
849 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
846 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
850 * contain information to setup the transmission of the data packets.
847 * contain information to setup the transmission of the data packets.
851 *
848 *
852 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
849 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
853 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
850 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
854 *
851 *
855 */
852 */
856
853
857 unsigned int i;
854 unsigned int i;
858 int ret;
855 int ret;
859 rtems_status_code status;
856 rtems_status_code status;
860 spw_ioctl_pkt_send spw_ioctl_send_CWF;
857 spw_ioctl_pkt_send spw_ioctl_send_CWF;
861 char *sample;
858 char *sample;
862
859
863 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
860 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
864 spw_ioctl_send_CWF.options = 0;
861 spw_ioctl_send_CWF.options = 0;
865
862
866 ret = LFR_DEFAULT;
863 ret = LFR_DEFAULT;
867
864
868 //**********************
865 //**********************
869 // BUILD CWF3_light DATA
866 // BUILD CWF3_light DATA
870 for ( i=0; i< 2048; i++)
867 for ( i=0; i< 2048; i++)
871 {
868 {
872 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
869 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
876 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
877 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
878 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
879 }
876 }
880
877
881 //*********************
878 //*********************
882 // SEND CWF3_light DATA
879 // SEND CWF3_light DATA
883
880
884 for (i=0; i<7; i++) // send waveform
881 for (i=0; i<7; i++) // send waveform
885 {
882 {
886 int coarseTime = 0x00;
883 int coarseTime = 0x00;
887 int fineTime = 0x00;
884 int fineTime = 0x00;
888 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
885 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
889 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
886 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
890 // BUILD THE DATA
887 // BUILD THE DATA
891 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
888 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
892 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
889 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
893 }
890 }
894 else {
891 else {
895 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
892 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
896 }
893 }
897 // SET PACKET SEQUENCE COUNTER
894 // SET PACKET SEQUENCE COUNTER
898 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
895 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
899 // SET PACKET TIME
896 // SET PACKET TIME
900 coarseTime = time_management_regs->coarse_time;
897 coarseTime = time_management_regs->coarse_time;
901 fineTime = time_management_regs->fine_time;
898 fineTime = time_management_regs->fine_time;
902 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
899 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
903 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
900 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
904 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
901 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
905 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
902 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
906 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
903 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
907 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
904 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
908 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
905 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
909 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
906 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
910 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
907 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
911 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
908 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
912 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
909 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
913 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
910 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
914 // SEND PACKET
911 // SEND PACKET
915 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
912 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
916 if (status != RTEMS_SUCCESSFUL) {
913 if (status != RTEMS_SUCCESSFUL) {
917 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
914 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
918 ret = LFR_DEFAULT;
915 ret = LFR_DEFAULT;
919 }
916 }
920 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
917 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
921 }
918 }
922
919
923 return ret;
920 return ret;
924 }
921 }
925
922
926
923
927 //**************
924 //**************
928 // wfp registers
925 // wfp registers
929 void set_wfp_data_shaping()
926 void set_wfp_data_shaping()
930 {
927 {
931 /** This function sets the data_shaping register of the waveform picker module.
928 /** This function sets the data_shaping register of the waveform picker module.
932 *
929 *
933 * The value is read from one field of the parameter_dump_packet structure:\n
930 * The value is read from one field of the parameter_dump_packet structure:\n
934 * bw_sp0_sp1_r0_r1
931 * bw_sp0_sp1_r0_r1
935 *
932 *
936 */
933 */
937
934
938 unsigned char data_shaping;
935 unsigned char data_shaping;
939
936
940 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
937 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
941 // waveform picker : [R1 R0 SP1 SP0 BW]
938 // waveform picker : [R1 R0 SP1 SP0 BW]
942
939
943 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
940 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
944
941
945 #ifdef GSA
942 #ifdef GSA
946 #else
943 #else
947 new_waveform_picker_regs->data_shaping =
944 new_waveform_picker_regs->data_shaping =
948 ( (data_shaping & 0x10) >> 4 ) // BW
945 ( (data_shaping & 0x10) >> 4 ) // BW
949 + ( (data_shaping & 0x08) >> 2 ) // SP0
946 + ( (data_shaping & 0x08) >> 2 ) // SP0
950 + ( (data_shaping & 0x04) ) // SP1
947 + ( (data_shaping & 0x04) ) // SP1
951 + ( (data_shaping & 0x02) << 2 ) // R0
948 + ( (data_shaping & 0x02) << 2 ) // R0
952 + ( (data_shaping & 0x01) << 4 ); // R1
949 + ( (data_shaping & 0x01) << 4 ); // R1
953 #endif
950 #endif
954 }
951 }
955
952
956 char set_wfp_delta_snapshot()
953 char set_wfp_delta_snapshot()
957 {
954 {
958 /** This function sets the delta_snapshot register of the waveform picker module.
955 /** This function sets the delta_snapshot register of the waveform picker module.
959 *
956 *
960 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
957 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
961 * - sy_lfr_n_swf_p[0]
958 * - sy_lfr_n_swf_p[0]
962 * - sy_lfr_n_swf_p[1]
959 * - sy_lfr_n_swf_p[1]
963 *
960 *
964 */
961 */
965
962
966 char ret;
963 char ret;
967 unsigned int delta_snapshot;
964 unsigned int delta_snapshot;
968 unsigned int aux;
965 unsigned int aux;
969
966
970 aux = 0;
967 aux = 0;
971 ret = LFR_DEFAULT;
968 ret = LFR_DEFAULT;
972
969
973 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
970 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
974 + parameter_dump_packet.sy_lfr_n_swf_p[1];
971 + parameter_dump_packet.sy_lfr_n_swf_p[1];
975
972
976 #ifdef GSA
973 #ifdef GSA
977 #else
974 #else
978 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
975 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
979 {
976 {
980 aux = MIN_DELTA_SNAPSHOT;
977 aux = MIN_DELTA_SNAPSHOT;
981 ret = LFR_DEFAULT;
978 ret = LFR_DEFAULT;
982 }
979 }
983 else
980 else
984 {
981 {
985 aux = delta_snapshot ;
982 aux = delta_snapshot ;
986 ret = LFR_SUCCESSFUL;
983 ret = LFR_SUCCESSFUL;
987 }
984 }
988 new_waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
985 new_waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
989 #endif
986 #endif
990
987
991 return ret;
988 return ret;
992 }
989 }
993
990
994 void set_wfp_burst_enable_register( unsigned char mode)
991 void set_wfp_burst_enable_register( unsigned char mode)
995 {
992 {
996 /** This function sets the waveform picker burst_enable register depending on the mode.
993 /** This function sets the waveform picker burst_enable register depending on the mode.
997 *
994 *
998 * @param mode is the LFR mode to launch.
995 * @param mode is the LFR mode to launch.
999 *
996 *
1000 * The burst bits shall be before the enable bits.
997 * The burst bits shall be before the enable bits.
1001 *
998 *
1002 */
999 */
1003
1000
1004 #ifdef GSA
1001 #ifdef GSA
1005 #else
1002 #else
1006 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1003 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1007 // the burst bits shall be set first, before the enable bits
1004 // the burst bits shall be set first, before the enable bits
1008 switch(mode) {
1005 switch(mode) {
1009 case(LFR_MODE_NORMAL):
1006 case(LFR_MODE_NORMAL):
1010 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1007 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1011 // new_waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1008 // new_waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1012 new_waveform_picker_regs->run_burst_enable = 0x07; // [0000 0111] enable f2 f1 f0
1009 new_waveform_picker_regs->run_burst_enable = 0x07; // [0000 0111] enable f2 f1 f0
1013 break;
1010 break;
1014 case(LFR_MODE_BURST):
1011 case(LFR_MODE_BURST):
1015 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1012 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1016 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1013 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1017 break;
1014 break;
1018 case(LFR_MODE_SBM1):
1015 case(LFR_MODE_SBM1):
1019 new_waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1016 new_waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1020 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1017 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1021 break;
1018 break;
1022 case(LFR_MODE_SBM2):
1019 case(LFR_MODE_SBM2):
1023 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1020 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1024 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1021 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1025 break;
1022 break;
1026 default:
1023 default:
1027 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1024 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1028 break;
1025 break;
1029 }
1026 }
1030 #endif
1027 #endif
1031 }
1028 }
1032
1029
1033 void reset_wfp_run_burst_enable()
1030 void reset_wfp_run_burst_enable()
1034 {
1031 {
1035 /** This function resets the waveform picker burst_enable register.
1032 /** This function resets the waveform picker burst_enable register.
1036 *
1033 *
1037 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1034 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1038 *
1035 *
1039 */
1036 */
1040
1037
1041 #ifdef GSA
1038 #ifdef GSA
1042 #else
1039 #else
1043 new_waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1040 new_waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1044 #endif
1041 #endif
1045 }
1042 }
1046
1043
1047 void reset_wfp_status()
1044 void reset_wfp_status()
1048 {
1045 {
1049 /** This function resets the waveform picker status register.
1046 /** This function resets the waveform picker status register.
1050 *
1047 *
1051 * All status bits are set to 0 [new_err full_err full].
1048 * All status bits are set to 0 [new_err full_err full].
1052 *
1049 *
1053 */
1050 */
1054
1051
1055 #ifdef GSA
1052 #ifdef GSA
1056 #else
1053 #else
1057 new_waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1054 new_waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1058 #endif
1055 #endif
1059 }
1056 }
1060
1057
1061 void reset_new_waveform_picker_regs()
1058 void reset_new_waveform_picker_regs()
1062 {
1059 {
1063 /** This function resets the waveform picker module registers.
1060 /** This function resets the waveform picker module registers.
1064 *
1061 *
1065 * The registers affected by this function are located at the following offset addresses:
1062 * The registers affected by this function are located at the following offset addresses:
1066 * - 0x00 data_shaping
1063 * - 0x00 data_shaping
1067 * - 0x04 run_burst_enable
1064 * - 0x04 run_burst_enable
1068 * - 0x08 addr_data_f0
1065 * - 0x08 addr_data_f0
1069 * - 0x0C addr_data_f1
1066 * - 0x0C addr_data_f1
1070 * - 0x10 addr_data_f2
1067 * - 0x10 addr_data_f2
1071 * - 0x14 addr_data_f3
1068 * - 0x14 addr_data_f3
1072 * - 0x18 status
1069 * - 0x18 status
1073 * - 0x1C delta_snapshot
1070 * - 0x1C delta_snapshot
1074 * - 0x20 delta_f0
1071 * - 0x20 delta_f0
1075 * - 0x24 delta_f0_2
1072 * - 0x24 delta_f0_2
1076 * - 0x28 delta_f1
1073 * - 0x28 delta_f1
1077 * - 0x2c delta_f2
1074 * - 0x2c delta_f2
1078 * - 0x30 nb_data_by_buffer
1075 * - 0x30 nb_data_by_buffer
1079 * - 0x34 nb_snapshot_param
1076 * - 0x34 nb_snapshot_param
1080 * - 0x38 start_date
1077 * - 0x38 start_date
1081 * - 0x3c nb_word_in_buffer
1078 * - 0x3c nb_word_in_buffer
1082 *
1079 *
1083 */
1080 */
1084
1081
1085 new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1082 new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1086 new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1083 new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1087 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1084 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1088 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // 0x0c
1085 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // 0x0c
1089 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // 0x10
1086 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // 0x10
1090 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // 0x14
1087 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // 0x14
1091 new_waveform_picker_regs->status = 0x00; // 0x18
1088 new_waveform_picker_regs->status = 0x00; // 0x18
1092 // new_waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1089 // new_waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1093 new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1090 new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1094 new_waveform_picker_regs->delta_f0 = 0x3f5; // 0x20 *** 1013
1091 new_waveform_picker_regs->delta_f0 = 0x3f5; // 0x20 *** 1013
1095 new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7
1092 new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7
1096 new_waveform_picker_regs->delta_f1 = 0x3c0; // 0x28 *** 960
1093 new_waveform_picker_regs->delta_f1 = 0x3c0; // 0x28 *** 960
1097 // new_waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 74240
1094 // new_waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 74240
1098 new_waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 2048
1095 new_waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 2048
1099 new_waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1
1096 new_waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1
1100 new_waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048
1097 new_waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048
1101 new_waveform_picker_regs->start_date = 0x00; // 0x38
1098 new_waveform_picker_regs->start_date = 0x00; // 0x38
1102 new_waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146
1099 new_waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146
1103 }
1100 }
1104
1101
1105 //*****************
1102 //*****************
1106 // local parameters
1103 // local parameters
1107 void set_local_sbm1_nb_cwf_max()
1104 void set_local_sbm1_nb_cwf_max()
1108 {
1105 {
1109 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1106 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1110 *
1107 *
1111 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1108 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1112 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1109 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1113 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1110 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1114 *
1111 *
1115 */
1112 */
1116 param_local.local_sbm1_nb_cwf_max = 2 *
1113 param_local.local_sbm1_nb_cwf_max = 2 *
1117 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1114 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1118 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1115 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1119 }
1116 }
1120
1117
1121 void set_local_sbm2_nb_cwf_max()
1118 void set_local_sbm2_nb_cwf_max()
1122 {
1119 {
1123 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1120 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1124 *
1121 *
1125 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1122 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1126 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1123 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1127 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1124 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1128 *
1125 *
1129 */
1126 */
1130
1127
1131 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1128 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1132 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1129 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1133 }
1130 }
1134
1131
1135 void set_local_nb_interrupt_f0_MAX()
1132 void set_local_nb_interrupt_f0_MAX()
1136 {
1133 {
1137 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1134 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1138 *
1135 *
1139 * This parameter is used for the SM validation only.\n
1136 * This parameter is used for the SM validation only.\n
1140 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1137 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1141 * module before launching a basic processing.
1138 * module before launching a basic processing.
1142 *
1139 *
1143 */
1140 */
1144
1141
1145 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1142 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1146 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1143 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1147 }
1144 }
1148
1145
1149 void reset_local_sbm1_nb_cwf_sent()
1146 void reset_local_sbm1_nb_cwf_sent()
1150 {
1147 {
1151 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1148 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1152 *
1149 *
1153 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1150 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1154 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1151 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1155 *
1152 *
1156 */
1153 */
1157
1154
1158 param_local.local_sbm1_nb_cwf_sent = 0;
1155 param_local.local_sbm1_nb_cwf_sent = 0;
1159 }
1156 }
1160
1157
1161 void reset_local_sbm2_nb_cwf_sent()
1158 void reset_local_sbm2_nb_cwf_sent()
1162 {
1159 {
1163 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1160 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1164 *
1161 *
1165 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1162 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1166 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1163 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1167 *
1164 *
1168 */
1165 */
1169
1166
1170 param_local.local_sbm2_nb_cwf_sent = 0;
1167 param_local.local_sbm2_nb_cwf_sent = 0;
1171 }
1168 }
1172
1169
1173 rtems_id get_pkts_queue_id( void )
1170 rtems_id get_pkts_queue_id( void )
1174 {
1171 {
1175 rtems_id queue_id;
1172 rtems_id queue_id;
1176 rtems_status_code status;
1173 rtems_status_code status;
1177 rtems_name queue_send_name;
1174 rtems_name queue_send_name;
1178
1175
1179 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1176 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1180
1177
1181 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1178 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1182 if (status != RTEMS_SUCCESSFUL)
1179 if (status != RTEMS_SUCCESSFUL)
1183 {
1180 {
1184 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1181 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1185 }
1182 }
1186 return queue_id;
1183 return queue_id;
1187 }
1184 }
1188
1185
1189 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1186 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1190 {
1187 {
1191 unsigned short *sequence_cnt;
1188 unsigned short *sequence_cnt;
1192 unsigned short segmentation_grouping_flag;
1189 unsigned short segmentation_grouping_flag;
1193 unsigned short new_packet_sequence_control;
1190 unsigned short new_packet_sequence_control;
1194
1191
1195 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1192 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1196 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1193 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1197 {
1194 {
1198 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1195 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1199 }
1196 }
1200 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1197 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1201 {
1198 {
1202 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1199 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1203 }
1200 }
1204 else
1201 else
1205 {
1202 {
1206 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1203 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1207 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1204 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1208 }
1205 }
1209
1206
1210 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1207 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1211 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1208 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1212
1209
1213 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1210 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1214
1211
1215 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1212 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1216 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1213 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1217
1214
1218 // increment the sequence counter for the next packet
1215 // increment the sequence counter for the next packet
1219 if ( *sequence_cnt < SEQ_CNT_MAX)
1216 if ( *sequence_cnt < SEQ_CNT_MAX)
1220 {
1217 {
1221 *sequence_cnt = *sequence_cnt + 1;
1218 *sequence_cnt = *sequence_cnt + 1;
1222 }
1219 }
1223 else
1220 else
1224 {
1221 {
1225 *sequence_cnt = 0;
1222 *sequence_cnt = 0;
1226 }
1223 }
1227 }
1224 }
General Comments 0
You need to be logged in to leave comments. Login now