##// END OF EJS Templates
little modification on delta_f2 (influence on the first snapshot at f0)
paul -
r260:629526138b27 R3a
parent child
Show More
@@ -1,1294 +1,1293
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 //***************
12 //***************
13 // waveform rings
13 // waveform rings
14 // F0
14 // F0
15 ring_node waveform_ring_f0[NB_RING_NODES_F0];
15 ring_node waveform_ring_f0[NB_RING_NODES_F0];
16 ring_node *current_ring_node_f0;
16 ring_node *current_ring_node_f0;
17 ring_node *ring_node_to_send_swf_f0;
17 ring_node *ring_node_to_send_swf_f0;
18 // F1
18 // F1
19 ring_node waveform_ring_f1[NB_RING_NODES_F1];
19 ring_node waveform_ring_f1[NB_RING_NODES_F1];
20 ring_node *current_ring_node_f1;
20 ring_node *current_ring_node_f1;
21 ring_node *ring_node_to_send_swf_f1;
21 ring_node *ring_node_to_send_swf_f1;
22 ring_node *ring_node_to_send_cwf_f1;
22 ring_node *ring_node_to_send_cwf_f1;
23 // F2
23 // F2
24 ring_node waveform_ring_f2[NB_RING_NODES_F2];
24 ring_node waveform_ring_f2[NB_RING_NODES_F2];
25 ring_node *current_ring_node_f2;
25 ring_node *current_ring_node_f2;
26 ring_node *ring_node_to_send_swf_f2;
26 ring_node *ring_node_to_send_swf_f2;
27 ring_node *ring_node_to_send_cwf_f2;
27 ring_node *ring_node_to_send_cwf_f2;
28 // F3
28 // F3
29 ring_node waveform_ring_f3[NB_RING_NODES_F3];
29 ring_node waveform_ring_f3[NB_RING_NODES_F3];
30 ring_node *current_ring_node_f3;
30 ring_node *current_ring_node_f3;
31 ring_node *ring_node_to_send_cwf_f3;
31 ring_node *ring_node_to_send_cwf_f3;
32 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ];
32 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ];
33
33
34 bool extractSWF1 = false;
34 bool extractSWF1 = false;
35 bool extractSWF2 = false;
35 bool extractSWF2 = false;
36 bool swf0_ready_flag_f1 = false;
36 bool swf0_ready_flag_f1 = false;
37 bool swf0_ready_flag_f2 = false;
37 bool swf0_ready_flag_f2 = false;
38 bool swf1_ready = false;
38 bool swf1_ready = false;
39 bool swf2_ready = false;
39 bool swf2_ready = false;
40
40
41 int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
41 int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
42 int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
42 int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
43 ring_node ring_node_swf1_extracted;
43 ring_node ring_node_swf1_extracted;
44 ring_node ring_node_swf2_extracted;
44 ring_node ring_node_swf2_extracted;
45
45
46 typedef enum resynchro_state_t
46 typedef enum resynchro_state_t
47 {
47 {
48 MEASURE_0,
48 MEASURE_0,
49 MEASURE_1,
49 MEASURE_1,
50 CORRECTION_0,
50 CORRECTION_0,
51 CORRECTION_1
51 CORRECTION_1
52 } resynchro_state;
52 } resynchro_state;
53
53
54 //*********************
54 //*********************
55 // Interrupt SubRoutine
55 // Interrupt SubRoutine
56
56
57 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
57 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
58 {
58 {
59 ring_node *node;
59 ring_node *node;
60
60
61 node = NULL;
61 node = NULL;
62 switch ( frequencyChannel ) {
62 switch ( frequencyChannel ) {
63 case 1:
63 case 1:
64 node = ring_node_to_send_cwf_f1;
64 node = ring_node_to_send_cwf_f1;
65 break;
65 break;
66 case 2:
66 case 2:
67 node = ring_node_to_send_cwf_f2;
67 node = ring_node_to_send_cwf_f2;
68 break;
68 break;
69 case 3:
69 case 3:
70 node = ring_node_to_send_cwf_f3;
70 node = ring_node_to_send_cwf_f3;
71 break;
71 break;
72 default:
72 default:
73 break;
73 break;
74 }
74 }
75
75
76 return node;
76 return node;
77 }
77 }
78
78
79 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
79 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
80 {
80 {
81 ring_node *node;
81 ring_node *node;
82
82
83 node = NULL;
83 node = NULL;
84 switch ( frequencyChannel ) {
84 switch ( frequencyChannel ) {
85 case 0:
85 case 0:
86 node = ring_node_to_send_swf_f0;
86 node = ring_node_to_send_swf_f0;
87 break;
87 break;
88 case 1:
88 case 1:
89 node = ring_node_to_send_swf_f1;
89 node = ring_node_to_send_swf_f1;
90 break;
90 break;
91 case 2:
91 case 2:
92 node = ring_node_to_send_swf_f2;
92 node = ring_node_to_send_swf_f2;
93 break;
93 break;
94 default:
94 default:
95 break;
95 break;
96 }
96 }
97
97
98 return node;
98 return node;
99 }
99 }
100
100
101 void reset_extractSWF( void )
101 void reset_extractSWF( void )
102 {
102 {
103 extractSWF1 = false;
103 extractSWF1 = false;
104 extractSWF2 = false;
104 extractSWF2 = false;
105 swf0_ready_flag_f1 = false;
105 swf0_ready_flag_f1 = false;
106 swf0_ready_flag_f2 = false;
106 swf0_ready_flag_f2 = false;
107 swf1_ready = false;
107 swf1_ready = false;
108 swf2_ready = false;
108 swf2_ready = false;
109 }
109 }
110
110
111 inline void waveforms_isr_f3( void )
111 inline void waveforms_isr_f3( void )
112 {
112 {
113 rtems_status_code spare_status;
113 rtems_status_code spare_status;
114
114
115 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
115 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
117 { // in modes other than STANDBY and BURST, send the CWF_F3 data
117 { // in modes other than STANDBY and BURST, send the CWF_F3 data
118 //***
118 //***
119 // F3
119 // F3
120 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
120 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
121 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
121 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
122 current_ring_node_f3 = current_ring_node_f3->next;
122 current_ring_node_f3 = current_ring_node_f3->next;
123 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
123 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
124 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
124 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
125 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
125 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
126 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
126 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
127 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
127 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
128 }
128 }
129 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
129 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
130 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
130 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
131 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
131 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
132 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
132 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
133 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
133 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
134 }
134 }
135 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
135 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
136 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
136 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
137 }
137 }
138 }
138 }
139 }
139 }
140 }
140 }
141
141
142 inline void waveforms_isr_burst( void )
142 inline void waveforms_isr_burst( void )
143 {
143 {
144 unsigned char status;
144 unsigned char status;
145 rtems_status_code spare_status;
145 rtems_status_code spare_status;
146
146
147 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
147 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
148
148
149
149
150 switch(status)
150 switch(status)
151 {
151 {
152 case 1:
152 case 1:
153 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
153 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
154 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
154 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
155 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
155 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
156 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
156 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
157 current_ring_node_f2 = current_ring_node_f2->next;
157 current_ring_node_f2 = current_ring_node_f2->next;
158 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
158 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
159 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
159 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
160 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
160 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
161 }
161 }
162 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
162 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
163 break;
163 break;
164 case 2:
164 case 2:
165 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
165 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
166 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
166 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
167 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
167 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
168 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
168 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
169 current_ring_node_f2 = current_ring_node_f2->next;
169 current_ring_node_f2 = current_ring_node_f2->next;
170 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
170 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
171 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
171 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
172 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
172 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
173 }
173 }
174 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
174 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
175 break;
175 break;
176 default:
176 default:
177 break;
177 break;
178 }
178 }
179 }
179 }
180
180
181 inline void waveform_isr_normal_sbm1_sbm2( void )
181 inline void waveform_isr_normal_sbm1_sbm2( void )
182 {
182 {
183 rtems_status_code status;
183 rtems_status_code status;
184
184
185 //***
185 //***
186 // F0
186 // F0
187 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits
187 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits
188 {
188 {
189 swf0_ready_flag_f1 = true;
189 swf0_ready_flag_f1 = true;
190 swf0_ready_flag_f2 = true;
190 swf0_ready_flag_f2 = true;
191 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
191 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
192 current_ring_node_f0 = current_ring_node_f0->next;
192 current_ring_node_f0 = current_ring_node_f0->next;
193 if ( (waveform_picker_regs->status & 0x01) == 0x01)
193 if ( (waveform_picker_regs->status & 0x01) == 0x01)
194 {
194 {
195
195
196 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
196 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
197 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
197 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
198 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
198 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
199 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
199 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
200 }
200 }
201 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
201 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
202 {
202 {
203 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
203 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
204 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
204 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
205 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
205 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
206 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
206 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
207 }
207 }
208 }
208 }
209
209
210 //***
210 //***
211 // F1
211 // F1
212 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
212 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
213 // (1) change the receiving buffer for the waveform picker
213 // (1) change the receiving buffer for the waveform picker
214 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
214 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
215 current_ring_node_f1 = current_ring_node_f1->next;
215 current_ring_node_f1 = current_ring_node_f1->next;
216 if ( (waveform_picker_regs->status & 0x04) == 0x04)
216 if ( (waveform_picker_regs->status & 0x04) == 0x04)
217 {
217 {
218 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
218 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
219 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
219 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
220 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
220 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
221 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
221 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
222 }
222 }
223 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
223 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
224 {
224 {
225 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
225 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
226 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
226 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
227 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
227 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
229 }
229 }
230 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
230 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
231 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 );
231 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 );
232 }
232 }
233
233
234 //***
234 //***
235 // F2
235 // F2
236 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
236 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
237 // (1) change the receiving buffer for the waveform picker
237 // (1) change the receiving buffer for the waveform picker
238 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
238 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
239 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
239 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
240 current_ring_node_f2 = current_ring_node_f2->next;
240 current_ring_node_f2 = current_ring_node_f2->next;
241 if ( (waveform_picker_regs->status & 0x10) == 0x10)
241 if ( (waveform_picker_regs->status & 0x10) == 0x10)
242 {
242 {
243 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
243 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
244 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
244 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
245 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
245 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
246 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
246 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
247 }
247 }
248 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
248 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
249 {
249 {
250 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
250 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
251 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
251 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
252 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
252 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
253 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
253 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
254 }
254 }
255 // (2) send an event for the waveforms transmission
255 // (2) send an event for the waveforms transmission
256 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 );
256 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 );
257 }
257 }
258 }
258 }
259
259
260 rtems_isr waveforms_isr( rtems_vector_number vector )
260 rtems_isr waveforms_isr( rtems_vector_number vector )
261 {
261 {
262 /** This is the interrupt sub routine called by the waveform picker core.
262 /** This is the interrupt sub routine called by the waveform picker core.
263 *
263 *
264 * This ISR launch different actions depending mainly on two pieces of information:
264 * This ISR launch different actions depending mainly on two pieces of information:
265 * 1. the values read in the registers of the waveform picker.
265 * 1. the values read in the registers of the waveform picker.
266 * 2. the current LFR mode.
266 * 2. the current LFR mode.
267 *
267 *
268 */
268 */
269
269
270 // STATUS
270 // STATUS
271 // new error error buffer full
271 // new error error buffer full
272 // 15 14 13 12 11 10 9 8
272 // 15 14 13 12 11 10 9 8
273 // f3 f2 f1 f0 f3 f2 f1 f0
273 // f3 f2 f1 f0 f3 f2 f1 f0
274 //
274 //
275 // ready buffer
275 // ready buffer
276 // 7 6 5 4 3 2 1 0
276 // 7 6 5 4 3 2 1 0
277 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
277 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
278
278
279 rtems_status_code spare_status;
279 rtems_status_code spare_status;
280
280
281 waveforms_isr_f3();
281 waveforms_isr_f3();
282
282
283 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
283 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
284 {
284 {
285 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
285 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
286 }
286 }
287
287
288 switch(lfrCurrentMode)
288 switch(lfrCurrentMode)
289 {
289 {
290 //********
290 //********
291 // STANDBY
291 // STANDBY
292 case LFR_MODE_STANDBY:
292 case LFR_MODE_STANDBY:
293 break;
293 break;
294 //**************************
294 //**************************
295 // LFR NORMAL, SBM1 and SBM2
295 // LFR NORMAL, SBM1 and SBM2
296 case LFR_MODE_NORMAL:
296 case LFR_MODE_NORMAL:
297 case LFR_MODE_SBM1:
297 case LFR_MODE_SBM1:
298 case LFR_MODE_SBM2:
298 case LFR_MODE_SBM2:
299 waveform_isr_normal_sbm1_sbm2();
299 waveform_isr_normal_sbm1_sbm2();
300 break;
300 break;
301 //******
301 //******
302 // BURST
302 // BURST
303 case LFR_MODE_BURST:
303 case LFR_MODE_BURST:
304 waveforms_isr_burst();
304 waveforms_isr_burst();
305 break;
305 break;
306 //********
306 //********
307 // DEFAULT
307 // DEFAULT
308 default:
308 default:
309 break;
309 break;
310 }
310 }
311 }
311 }
312
312
313 //************
313 //************
314 // RTEMS TASKS
314 // RTEMS TASKS
315
315
316 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
316 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
317 {
317 {
318 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
318 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
319 *
319 *
320 * @param unused is the starting argument of the RTEMS task
320 * @param unused is the starting argument of the RTEMS task
321 *
321 *
322 * The following data packets are sent by this task:
322 * The following data packets are sent by this task:
323 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
323 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
324 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
324 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
325 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
325 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
326 *
326 *
327 */
327 */
328
328
329 rtems_event_set event_out;
329 rtems_event_set event_out;
330 rtems_id queue_id;
330 rtems_id queue_id;
331 rtems_status_code status;
331 rtems_status_code status;
332 ring_node *ring_node_swf1_extracted_ptr;
332 ring_node *ring_node_swf1_extracted_ptr;
333 ring_node *ring_node_swf2_extracted_ptr;
333 ring_node *ring_node_swf2_extracted_ptr;
334
334
335 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
335 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
336 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
336 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
337
337
338 status = get_message_queue_id_send( &queue_id );
338 status = get_message_queue_id_send( &queue_id );
339 if (status != RTEMS_SUCCESSFUL)
339 if (status != RTEMS_SUCCESSFUL)
340 {
340 {
341 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
341 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
342 }
342 }
343
343
344 BOOT_PRINTF("in WFRM ***\n");
344 BOOT_PRINTF("in WFRM ***\n");
345
345
346 while(1){
346 while(1){
347 // wait for an RTEMS_EVENT
347 // wait for an RTEMS_EVENT
348 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL,
348 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL,
349 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
349 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
350
350
351 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
351 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
352
352
353 if (event_out == RTEMS_EVENT_MODE_NORMAL)
353 if (event_out == RTEMS_EVENT_MODE_NORMAL)
354 {
354 {
355 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
355 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
356 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
356 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
357 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
357 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
358 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
358 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
359 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
359 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
360 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
360 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
361 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
361 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
362 }
362 }
363 }
363 }
364 }
364 }
365
365
366 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
366 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
367 {
367 {
368 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
368 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
369 *
369 *
370 * @param unused is the starting argument of the RTEMS task
370 * @param unused is the starting argument of the RTEMS task
371 *
371 *
372 * The following data packet is sent by this task:
372 * The following data packet is sent by this task:
373 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
373 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
374 *
374 *
375 */
375 */
376
376
377 rtems_event_set event_out;
377 rtems_event_set event_out;
378 rtems_id queue_id;
378 rtems_id queue_id;
379 rtems_status_code status;
379 rtems_status_code status;
380 ring_node ring_node_cwf3_light;
380 ring_node ring_node_cwf3_light;
381 ring_node *ring_node_to_send_cwf;
381 ring_node *ring_node_to_send_cwf;
382
382
383 status = get_message_queue_id_send( &queue_id );
383 status = get_message_queue_id_send( &queue_id );
384 if (status != RTEMS_SUCCESSFUL)
384 if (status != RTEMS_SUCCESSFUL)
385 {
385 {
386 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
386 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
387 }
387 }
388
388
389 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
389 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
390
390
391 // init the ring_node_cwf3_light structure
391 // init the ring_node_cwf3_light structure
392 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
392 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
393 ring_node_cwf3_light.coarseTime = 0x00;
393 ring_node_cwf3_light.coarseTime = 0x00;
394 ring_node_cwf3_light.fineTime = 0x00;
394 ring_node_cwf3_light.fineTime = 0x00;
395 ring_node_cwf3_light.next = NULL;
395 ring_node_cwf3_light.next = NULL;
396 ring_node_cwf3_light.previous = NULL;
396 ring_node_cwf3_light.previous = NULL;
397 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
397 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
398 ring_node_cwf3_light.status = 0x00;
398 ring_node_cwf3_light.status = 0x00;
399
399
400 BOOT_PRINTF("in CWF3 ***\n")
400 BOOT_PRINTF("in CWF3 ***\n")
401
401
402 while(1){
402 while(1){
403 // wait for an RTEMS_EVENT
403 // wait for an RTEMS_EVENT
404 rtems_event_receive( RTEMS_EVENT_0,
404 rtems_event_receive( RTEMS_EVENT_0,
405 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
405 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
406 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
406 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
407 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
407 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
408 {
408 {
409 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
409 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
410 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
410 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
411 {
411 {
412 PRINTF("send CWF_LONG_F3\n")
412 PRINTF("send CWF_LONG_F3\n")
413 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
413 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
414 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
414 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
415 }
415 }
416 else
416 else
417 {
417 {
418 PRINTF("send CWF_F3 (light)\n")
418 PRINTF("send CWF_F3 (light)\n")
419 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
419 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
420 }
420 }
421
421
422 }
422 }
423 else
423 else
424 {
424 {
425 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
425 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
426 }
426 }
427 }
427 }
428 }
428 }
429
429
430 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
430 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
431 {
431 {
432 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
432 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
433 *
433 *
434 * @param unused is the starting argument of the RTEMS task
434 * @param unused is the starting argument of the RTEMS task
435 *
435 *
436 * The following data packet is sent by this function:
436 * The following data packet is sent by this function:
437 * - TM_LFR_SCIENCE_BURST_CWF_F2
437 * - TM_LFR_SCIENCE_BURST_CWF_F2
438 * - TM_LFR_SCIENCE_SBM2_CWF_F2
438 * - TM_LFR_SCIENCE_SBM2_CWF_F2
439 *
439 *
440 */
440 */
441
441
442 rtems_event_set event_out;
442 rtems_event_set event_out;
443 rtems_id queue_id;
443 rtems_id queue_id;
444 rtems_status_code status;
444 rtems_status_code status;
445 ring_node *ring_node_to_send;
445 ring_node *ring_node_to_send;
446 unsigned long long int acquisitionTimeF0_asLong;
446 unsigned long long int acquisitionTimeF0_asLong;
447
447
448 acquisitionTimeF0_asLong = 0x00;
448 acquisitionTimeF0_asLong = 0x00;
449
449
450 status = get_message_queue_id_send( &queue_id );
450 status = get_message_queue_id_send( &queue_id );
451 if (status != RTEMS_SUCCESSFUL)
451 if (status != RTEMS_SUCCESSFUL)
452 {
452 {
453 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
453 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
454 }
454 }
455
455
456 BOOT_PRINTF("in CWF2 ***\n")
456 BOOT_PRINTF("in CWF2 ***\n")
457
457
458 while(1){
458 while(1){
459 // wait for an RTEMS_EVENT
459 // wait for an RTEMS_EVENT
460 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
460 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
461 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
461 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
462 ring_node_to_send = getRingNodeToSendCWF( 2 );
462 ring_node_to_send = getRingNodeToSendCWF( 2 );
463 if (event_out == RTEMS_EVENT_MODE_BURST)
463 if (event_out == RTEMS_EVENT_MODE_BURST)
464 {
464 {
465 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
465 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
466 }
466 }
467 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
467 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
468 {
468 {
469 if ( lfrCurrentMode == LFR_MODE_SBM2 )
469 if ( lfrCurrentMode == LFR_MODE_SBM2 )
470 {
470 {
471 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
471 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
472 }
472 }
473 // launch snapshot extraction if needed
473 // launch snapshot extraction if needed
474 if (extractSWF2 == true)
474 if (extractSWF2 == true)
475 {
475 {
476 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
476 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
477 // extract the snapshot
477 // extract the snapshot
478 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
478 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
479 &ring_node_swf2_extracted, swf2_extracted );
479 &ring_node_swf2_extracted, swf2_extracted );
480 // send the snapshot when built
480 // send the snapshot when built
481 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
481 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
482 extractSWF2 = false;
482 extractSWF2 = false;
483 swf2_ready = true;
483 swf2_ready = true;
484 }
484 }
485 if (swf0_ready_flag_f2 == true)
485 if (swf0_ready_flag_f2 == true)
486 {
486 {
487 extractSWF2 = true;
487 extractSWF2 = true;
488 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
488 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
489 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
489 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
490 swf0_ready_flag_f2 = false;
490 swf0_ready_flag_f2 = false;
491 }
491 }
492 }
492 }
493 }
493 }
494 }
494 }
495
495
496 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
496 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
497 {
497 {
498 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
498 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
499 *
499 *
500 * @param unused is the starting argument of the RTEMS task
500 * @param unused is the starting argument of the RTEMS task
501 *
501 *
502 * The following data packet is sent by this function:
502 * The following data packet is sent by this function:
503 * - TM_LFR_SCIENCE_SBM1_CWF_F1
503 * - TM_LFR_SCIENCE_SBM1_CWF_F1
504 *
504 *
505 */
505 */
506
506
507 rtems_event_set event_out;
507 rtems_event_set event_out;
508 rtems_id queue_id;
508 rtems_id queue_id;
509 rtems_status_code status;
509 rtems_status_code status;
510
510
511 ring_node *ring_node_to_send_cwf;
511 ring_node *ring_node_to_send_cwf;
512
512
513 status = get_message_queue_id_send( &queue_id );
513 status = get_message_queue_id_send( &queue_id );
514 if (status != RTEMS_SUCCESSFUL)
514 if (status != RTEMS_SUCCESSFUL)
515 {
515 {
516 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
516 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
517 }
517 }
518
518
519 BOOT_PRINTF("in CWF1 ***\n");
519 BOOT_PRINTF("in CWF1 ***\n");
520
520
521 while(1){
521 while(1){
522 // wait for an RTEMS_EVENT
522 // wait for an RTEMS_EVENT
523 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
523 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
524 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
524 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
525 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
525 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
526 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
526 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
527 if (lfrCurrentMode == LFR_MODE_SBM1)
527 if (lfrCurrentMode == LFR_MODE_SBM1)
528 {
528 {
529 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
529 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
530 if (status != 0)
530 if (status != 0)
531 {
531 {
532 PRINTF("cwf sending failed\n")
532 PRINTF("cwf sending failed\n")
533 }
533 }
534 }
534 }
535 // launch snapshot extraction if needed
535 // launch snapshot extraction if needed
536 if (extractSWF1 == true)
536 if (extractSWF1 == true)
537 {
537 {
538 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
538 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
539 // launch the snapshot extraction
539 // launch the snapshot extraction
540 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
540 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
541 extractSWF1 = false;
541 extractSWF1 = false;
542 }
542 }
543 if (swf0_ready_flag_f1 == true)
543 if (swf0_ready_flag_f1 == true)
544 {
544 {
545 extractSWF1 = true;
545 extractSWF1 = true;
546 swf0_ready_flag_f1 = false; // this step shall be executed only one time
546 swf0_ready_flag_f1 = false; // this step shall be executed only one time
547 }
547 }
548 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
548 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
549 {
549 {
550 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
550 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
551 swf1_ready = false;
551 swf1_ready = false;
552 swf2_ready = false;
552 swf2_ready = false;
553 }
553 }
554 }
554 }
555 }
555 }
556
556
557 rtems_task swbd_task(rtems_task_argument argument)
557 rtems_task swbd_task(rtems_task_argument argument)
558 {
558 {
559 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
559 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
560 *
560 *
561 * @param unused is the starting argument of the RTEMS task
561 * @param unused is the starting argument of the RTEMS task
562 *
562 *
563 */
563 */
564
564
565 rtems_event_set event_out;
565 rtems_event_set event_out;
566 unsigned long long int acquisitionTimeF0_asLong;
566 unsigned long long int acquisitionTimeF0_asLong;
567
567
568 acquisitionTimeF0_asLong = 0x00;
568 acquisitionTimeF0_asLong = 0x00;
569
569
570 BOOT_PRINTF("in SWBD ***\n")
570 BOOT_PRINTF("in SWBD ***\n")
571
571
572 while(1){
572 while(1){
573 // wait for an RTEMS_EVENT
573 // wait for an RTEMS_EVENT
574 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
574 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
575 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
575 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
576 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
576 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
577 {
577 {
578 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
578 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
579 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong,
579 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong,
580 &ring_node_swf1_extracted, swf1_extracted );
580 &ring_node_swf1_extracted, swf1_extracted );
581 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
581 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
582 }
582 }
583 else
583 else
584 {
584 {
585 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
585 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
586 }
586 }
587 }
587 }
588 }
588 }
589
589
590 //******************
590 //******************
591 // general functions
591 // general functions
592
592
593 void WFP_init_rings( void )
593 void WFP_init_rings( void )
594 {
594 {
595 // F0 RING
595 // F0 RING
596 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
596 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
597 // F1 RING
597 // F1 RING
598 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
598 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
599 // F2 RING
599 // F2 RING
600 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
600 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
601 // F3 RING
601 // F3 RING
602 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
602 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_