##// END OF EJS Templates
snapshot resynchronisation modified, correction is multiplied by 2 when above 1...
paul -
r274:4b39bb5ceb61 R3a
parent child
Show More
@@ -1,1312 +1,1310
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,
48 MEASURE,
49 CORRECTION
49 CORRECTION
50 } resynchro_state;
50 } resynchro_state;
51
51
52 //*********************
52 //*********************
53 // Interrupt SubRoutine
53 // Interrupt SubRoutine
54
54
55 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
55 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
56 {
56 {
57 ring_node *node;
57 ring_node *node;
58
58
59 node = NULL;
59 node = NULL;
60 switch ( frequencyChannel ) {
60 switch ( frequencyChannel ) {
61 case 1:
61 case 1:
62 node = ring_node_to_send_cwf_f1;
62 node = ring_node_to_send_cwf_f1;
63 break;
63 break;
64 case 2:
64 case 2:
65 node = ring_node_to_send_cwf_f2;
65 node = ring_node_to_send_cwf_f2;
66 break;
66 break;
67 case 3:
67 case 3:
68 node = ring_node_to_send_cwf_f3;
68 node = ring_node_to_send_cwf_f3;
69 break;
69 break;
70 default:
70 default:
71 break;
71 break;
72 }
72 }
73
73
74 return node;
74 return node;
75 }
75 }
76
76
77 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
77 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
78 {
78 {
79 ring_node *node;
79 ring_node *node;
80
80
81 node = NULL;
81 node = NULL;
82 switch ( frequencyChannel ) {
82 switch ( frequencyChannel ) {
83 case 0:
83 case 0:
84 node = ring_node_to_send_swf_f0;
84 node = ring_node_to_send_swf_f0;
85 break;
85 break;
86 case 1:
86 case 1:
87 node = ring_node_to_send_swf_f1;
87 node = ring_node_to_send_swf_f1;
88 break;
88 break;
89 case 2:
89 case 2:
90 node = ring_node_to_send_swf_f2;
90 node = ring_node_to_send_swf_f2;
91 break;
91 break;
92 default:
92 default:
93 break;
93 break;
94 }
94 }
95
95
96 return node;
96 return node;
97 }
97 }
98
98
99 void reset_extractSWF( void )
99 void reset_extractSWF( void )
100 {
100 {
101 extractSWF1 = false;
101 extractSWF1 = false;
102 extractSWF2 = false;
102 extractSWF2 = false;
103 swf0_ready_flag_f1 = false;
103 swf0_ready_flag_f1 = false;
104 swf0_ready_flag_f2 = false;
104 swf0_ready_flag_f2 = false;
105 swf1_ready = false;
105 swf1_ready = false;
106 swf2_ready = false;
106 swf2_ready = false;
107 }
107 }
108
108
109 inline void waveforms_isr_f3( void )
109 inline void waveforms_isr_f3( void )
110 {
110 {
111 rtems_status_code spare_status;
111 rtems_status_code spare_status;
112
112
113 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
113 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
114 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
114 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
115 { // in modes other than STANDBY and BURST, send the CWF_F3 data
115 { // in modes other than STANDBY and BURST, send the CWF_F3 data
116 //***
116 //***
117 // F3
117 // F3
118 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
118 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
119 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
119 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
120 current_ring_node_f3 = current_ring_node_f3->next;
120 current_ring_node_f3 = current_ring_node_f3->next;
121 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
121 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
122 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
122 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
123 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
123 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
124 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
124 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
125 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
125 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
126 }
126 }
127 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
127 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
128 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
128 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
129 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
129 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
130 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
130 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
131 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
131 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
132 }
132 }
133 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
133 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
134 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
134 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
135 }
135 }
136 }
136 }
137 }
137 }
138 }
138 }
139
139
140 inline void waveforms_isr_burst( void )
140 inline void waveforms_isr_burst( void )
141 {
141 {
142 unsigned char status;
142 unsigned char status;
143 rtems_status_code spare_status;
143 rtems_status_code spare_status;
144
144
145 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
145 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
146
146
147
147
148 switch(status)
148 switch(status)
149 {
149 {
150 case 1:
150 case 1:
151 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
151 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
152 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
152 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
153 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
153 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
154 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
154 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
155 current_ring_node_f2 = current_ring_node_f2->next;
155 current_ring_node_f2 = current_ring_node_f2->next;
156 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
156 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
157 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
157 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
158 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
158 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
159 }
159 }
160 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
160 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
161 break;
161 break;
162 case 2:
162 case 2:
163 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
163 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
164 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
164 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
165 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
165 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
166 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
166 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
167 current_ring_node_f2 = current_ring_node_f2->next;
167 current_ring_node_f2 = current_ring_node_f2->next;
168 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
168 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
169 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
169 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
170 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
170 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
171 }
171 }
172 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
172 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
173 break;
173 break;
174 default:
174 default:
175 break;
175 break;
176 }
176 }
177 }
177 }
178
178
179 inline void waveform_isr_normal_sbm1_sbm2( void )
179 inline void waveform_isr_normal_sbm1_sbm2( void )
180 {
180 {
181 rtems_status_code status;
181 rtems_status_code status;
182
182
183 //***
183 //***
184 // F0
184 // F0
185 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits
185 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits
186 {
186 {
187 swf0_ready_flag_f1 = true;
187 swf0_ready_flag_f1 = true;
188 swf0_ready_flag_f2 = true;
188 swf0_ready_flag_f2 = true;
189 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
189 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
190 current_ring_node_f0 = current_ring_node_f0->next;
190 current_ring_node_f0 = current_ring_node_f0->next;
191 if ( (waveform_picker_regs->status & 0x01) == 0x01)
191 if ( (waveform_picker_regs->status & 0x01) == 0x01)
192 {
192 {
193
193
194 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
194 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
195 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
195 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
196 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
196 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
197 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
197 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
198 }
198 }
199 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
199 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
200 {
200 {
201 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
201 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
202 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
202 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
203 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
203 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
204 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
204 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
205 }
205 }
206 // send an event to the WFRM task for resynchro activities
206 // send an event to the WFRM task for resynchro activities
207 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH );
207 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH );
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 //*************************************************
283 //*************************************************
284 // copy the status bits in the housekeeping packets
284 // copy the status bits in the housekeeping packets
285 housekeeping_packet.hk_lfr_vhdl_iir_cal =
285 housekeeping_packet.hk_lfr_vhdl_iir_cal =
286 (unsigned char) ((waveform_picker_regs->status & 0xff00) >> 8);
286 (unsigned char) ((waveform_picker_regs->status & 0xff00) >> 8);
287
287
288 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
288 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
289 {
289 {
290 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
290 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
291 }
291 }
292
292
293 switch(lfrCurrentMode)
293 switch(lfrCurrentMode)
294 {
294 {
295 //********
295 //********
296 // STANDBY
296 // STANDBY
297 case LFR_MODE_STANDBY:
297 case LFR_MODE_STANDBY:
298 break;
298 break;
299 //**************************
299 //**************************
300 // LFR NORMAL, SBM1 and SBM2
300 // LFR NORMAL, SBM1 and SBM2
301 case LFR_MODE_NORMAL:
301 case LFR_MODE_NORMAL:
302 case LFR_MODE_SBM1:
302 case LFR_MODE_SBM1:
303 case LFR_MODE_SBM2:
303 case LFR_MODE_SBM2:
304 waveform_isr_normal_sbm1_sbm2();
304 waveform_isr_normal_sbm1_sbm2();
305 break;
305 break;
306 //******
306 //******
307 // BURST
307 // BURST
308 case LFR_MODE_BURST:
308 case LFR_MODE_BURST:
309 waveforms_isr_burst();
309 waveforms_isr_burst();
310 break;
310 break;
311 //********
311 //********
312 // DEFAULT
312 // DEFAULT
313 default:
313 default:
314 break;
314 break;
315 }
315 }
316 }
316 }
317
317
318 //************
318 //************
319 // RTEMS TASKS
319 // RTEMS TASKS
320
320
321 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
321 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
322 {
322 {
323 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
323 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
324 *
324 *
325 * @param unused is the starting argument of the RTEMS task
325 * @param unused is the starting argument of the RTEMS task
326 *
326 *
327 * The following data packets are sent by this task:
327 * The following data packets are sent by this task:
328 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
328 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
329 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
329 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
330 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
330 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
331 *
331 *
332 */
332 */
333
333
334 rtems_event_set event_out;
334 rtems_event_set event_out;
335 rtems_id queue_id;
335 rtems_id queue_id;
336 rtems_status_code status;
336 rtems_status_code status;
337 ring_node *ring_node_swf1_extracted_ptr;
337 ring_node *ring_node_swf1_extracted_ptr;
338 ring_node *ring_node_swf2_extracted_ptr;
338 ring_node *ring_node_swf2_extracted_ptr;
339
339
340 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
340 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
341 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
341 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
342
342
343 status = get_message_queue_id_send( &queue_id );
343 status = get_message_queue_id_send( &queue_id );
344 if (status != RTEMS_SUCCESSFUL)
344 if (status != RTEMS_SUCCESSFUL)
345 {
345 {
346 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
346 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
347 }
347 }
348
348
349 BOOT_PRINTF("in WFRM ***\n");
349 BOOT_PRINTF("in WFRM ***\n");
350
350
351 while(1){
351 while(1){
352 // wait for an RTEMS_EVENT
352 // wait for an RTEMS_EVENT
353 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH,
353 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH,
354 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
354 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
355
355
356 if (event_out == RTEMS_EVENT_MODE_NORMAL)
356 if (event_out == RTEMS_EVENT_MODE_NORMAL)
357 {
357 {
358 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
358 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
359 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
359 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
360 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
360 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
361 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
361 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
362 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
362 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
363 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
363 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
364 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
364 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
365 }
365 }
366 if (event_out == RTEMS_EVENT_SWF_RESYNCH)
366 if (event_out == RTEMS_EVENT_SWF_RESYNCH)
367 {
367 {
368 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
368 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
369 }
369 }
370 }
370 }
371 }
371 }
372
372
373 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
373 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
374 {
374 {
375 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
375 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
376 *
376 *
377 * @param unused is the starting argument of the RTEMS task
377 * @param unused is the starting argument of the RTEMS task
378 *
378 *
379 * The following data packet is sent by this task:
379 * The following data packet is sent by this task:
380 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
380 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
381 *
381 *
382 */
382 */
383
383
384 rtems_event_set event_out;
384 rtems_event_set event_out;
385 rtems_id queue_id;
385 rtems_id queue_id;
386 rtems_status_code status;
386 rtems_status_code status;
387 ring_node ring_node_cwf3_light;
387 ring_node ring_node_cwf3_light;
388 ring_node *ring_node_to_send_cwf;
388 ring_node *ring_node_to_send_cwf;
389
389
390 status = get_message_queue_id_send( &queue_id );
390 status = get_message_queue_id_send( &queue_id );
391 if (status != RTEMS_SUCCESSFUL)
391 if (status != RTEMS_SUCCESSFUL)
392 {
392 {
393 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
393 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
394 }
394 }
395
395
396 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
396 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
397
397
398 // init the ring_node_cwf3_light structure
398 // init the ring_node_cwf3_light structure
399 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
399 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
400 ring_node_cwf3_light.coarseTime = 0x00;
400 ring_node_cwf3_light.coarseTime = 0x00;
401 ring_node_cwf3_light.fineTime = 0x00;
401 ring_node_cwf3_light.fineTime = 0x00;
402 ring_node_cwf3_light.next = NULL;
402 ring_node_cwf3_light.next = NULL;
403 ring_node_cwf3_light.previous = NULL;
403 ring_node_cwf3_light.previous = NULL;
404 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
404 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
405 ring_node_cwf3_light.status = 0x00;
405 ring_node_cwf3_light.status = 0x00;
406
406
407 BOOT_PRINTF("in CWF3 ***\n")
407 BOOT_PRINTF("in CWF3 ***\n")
408
408
409 while(1){
409 while(1){
410 // wait for an RTEMS_EVENT
410 // wait for an RTEMS_EVENT
411 rtems_event_receive( RTEMS_EVENT_0,
411 rtems_event_receive( RTEMS_EVENT_0,
412 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
412 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
413 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
413 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
414 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
414 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
415 {
415 {
416 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
416 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
417 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
417 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
418 {
418 {
419 PRINTF("send CWF_LONG_F3\n")
419 PRINTF("send CWF_LONG_F3\n")
420 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
420 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
421 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
421 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
422 }
422 }
423 else
423 else
424 {
424 {
425 PRINTF("send CWF_F3 (light)\n")
425 PRINTF("send CWF_F3 (light)\n")
426 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
426 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
427 }
427 }
428
428
429 }
429 }
430 else
430 else
431 {
431 {
432 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
432 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
433 }
433 }
434 }
434 }
435 }
435 }
436
436
437 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
437 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
438 {
438 {
439 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
439 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
440 *
440 *
441 * @param unused is the starting argument of the RTEMS task
441 * @param unused is the starting argument of the RTEMS task
442 *
442 *
443 * The following data packet is sent by this function:
443 * The following data packet is sent by this function:
444 * - TM_LFR_SCIENCE_BURST_CWF_F2
444 * - TM_LFR_SCIENCE_BURST_CWF_F2
445 * - TM_LFR_SCIENCE_SBM2_CWF_F2
445 * - TM_LFR_SCIENCE_SBM2_CWF_F2
446 *
446 *
447 */
447 */
448
448
449 rtems_event_set event_out;
449 rtems_event_set event_out;
450 rtems_id queue_id;
450 rtems_id queue_id;
451 rtems_status_code status;
451 rtems_status_code status;
452 ring_node *ring_node_to_send;
452 ring_node *ring_node_to_send;
453 unsigned long long int acquisitionTimeF0_asLong;
453 unsigned long long int acquisitionTimeF0_asLong;
454
454
455 acquisitionTimeF0_asLong = 0x00;
455 acquisitionTimeF0_asLong = 0x00;
456
456
457 status = get_message_queue_id_send( &queue_id );
457 status = get_message_queue_id_send( &queue_id );
458 if (status != RTEMS_SUCCESSFUL)
458 if (status != RTEMS_SUCCESSFUL)
459 {
459 {
460 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
460 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
461 }
461 }
462
462
463 BOOT_PRINTF("in CWF2 ***\n")
463 BOOT_PRINTF("in CWF2 ***\n")
464
464
465 while(1){
465 while(1){
466 // wait for an RTEMS_EVENT// send the snapshot when built
466 // wait for an RTEMS_EVENT// send the snapshot when built
467 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
467 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
468 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
468 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
469 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
469 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
470 ring_node_to_send = getRingNodeToSendCWF( 2 );
470 ring_node_to_send = getRingNodeToSendCWF( 2 );
471 if (event_out == RTEMS_EVENT_MODE_BURST)
471 if (event_out == RTEMS_EVENT_MODE_BURST)
472 {
472 {
473 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
473 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
474 }
474 }
475 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
475 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
476 {
476 {
477 if ( lfrCurrentMode == LFR_MODE_SBM2 )
477 if ( lfrCurrentMode == LFR_MODE_SBM2 )
478 {
478 {
479 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
479 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
480 }
480 }
481 // launch snapshot extraction if needed
481 // launch snapshot extraction if needed
482 if (extractSWF2 == true)
482 if (extractSWF2 == true)
483 {
483 {
484 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
484 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
485 // extract the snapshot
485 // extract the snapshot
486 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
486 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
487 &ring_node_swf2_extracted, swf2_extracted );
487 &ring_node_swf2_extracted, swf2_extracted );
488 extractSWF2 = false;
488 extractSWF2 = false;
489 swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM
489 swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM
490 }
490 }
491 if (swf0_ready_flag_f2 == true)
491 if (swf0_ready_flag_f2 == true)
492 {
492 {
493 extractSWF2 = true;
493 extractSWF2 = true;
494 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
494 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
495 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
495 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
496 swf0_ready_flag_f2 = false;
496 swf0_ready_flag_f2 = false;
497 }
497 }
498 }
498 }
499 }
499 }
500 }
500 }
501
501
502 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
502 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
503 {
503 {
504 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
504 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
505 *
505 *
506 * @param unused is the starting argument of the RTEMS task
506 * @param unused is the starting argument of the RTEMS task
507 *
507 *
508 * The following data packet is sent by this function:
508 * The following data packet is sent by this function:
509 * - TM_LFR_SCIENCE_SBM1_CWF_F1
509 * - TM_LFR_SCIENCE_SBM1_CWF_F1
510 *
510 *
511 */
511 */
512
512
513 rtems_event_set event_out;
513 rtems_event_set event_out;
514 rtems_id queue_id;
514 rtems_id queue_id;
515 rtems_status_code status;
515 rtems_status_code status;
516
516
517 ring_node *ring_node_to_send_cwf;
517 ring_node *ring_node_to_send_cwf;
518
518
519 status = get_message_queue_id_send( &queue_id );
519 status = get_message_queue_id_send( &queue_id );
520 if (status != RTEMS_SUCCESSFUL)
520 if (status != RTEMS_SUCCESSFUL)
521 {
521 {
522 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
522 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
523 }
523 }
524
524
525 BOOT_PRINTF("in CWF1 ***\n");
525 BOOT_PRINTF("in CWF1 ***\n");
526
526
527 while(1){
527 while(1){
528 // wait for an RTEMS_EVENT
528 // wait for an RTEMS_EVENT
529 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
529 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
530 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
530 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
531 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
531 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
532 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
532 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
533 if (lfrCurrentMode == LFR_MODE_SBM1)
533 if (lfrCurrentMode == LFR_MODE_SBM1)
534 {
534 {
535 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
535 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
536 if (status != 0)
536 if (status != 0)
537 {
537 {
538 PRINTF("cwf sending failed\n")
538 PRINTF("cwf sending failed\n")
539 }
539 }
540 }
540 }
541 // launch snapshot extraction if needed
541 // launch snapshot extraction if needed
542 if (extractSWF1 == true)
542 if (extractSWF1 == true)
543 {
543 {
544 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
544 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
545 // launch the snapshot extraction
545 // launch the snapshot extraction
546 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
546 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
547 extractSWF1 = false;
547 extractSWF1 = false;
548 }
548 }
549 if (swf0_ready_flag_f1 == true)
549 if (swf0_ready_flag_f1 == true)
550 {
550 {
551 extractSWF1 = true;
551 extractSWF1 = true;
552 swf0_ready_flag_f1 = false; // this step shall be executed only one time
552 swf0_ready_flag_f1 = false; // this step shall be executed only one time
553 }
553 }
554 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
554 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
555 {
555 {
556 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
556 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
557 swf1_ready = false;
557 swf1_ready = false;
558 swf2_ready = false;
558 swf2_ready = false;
559 }
559 }
560 }
560 }
561 }
561 }
562
562
563 rtems_task swbd_task(rtems_task_argument argument)
563 rtems_task swbd_task(rtems_task_argument argument)
564 {
564 {
565 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
565 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
566 *
566 *
567 * @param unused is the starting argument of the RTEMS task
567 * @param unused is the starting argument of the RTEMS task
568 *
568 *
569 */
569 */
570
570
571 rtems_event_set event_out;
571 rtems_event_set event_out;
572 unsigned long long int acquisitionTimeF0_asLong;
572 unsigned long long int acquisitionTimeF0_asLong;
573
573
574 acquisitionTimeF0_asLong = 0x00;
574 acquisitionTimeF0_asLong = 0x00;
575
575
576 BOOT_PRINTF("in SWBD ***\n")
576 BOOT_PRINTF("in SWBD ***\n")
577
577
578 while(1){
578 while(1){
579 // wait for an RTEMS_EVENT
579 // wait for an RTEMS_EVENT
580 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
580 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
581 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
581 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
582 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
582 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
583 {
583 {
584 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
584 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
585 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong,
585 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong,
586 &ring_node_swf1_extracted, swf1_extracted );
586 &ring_node_swf1_extracted, swf1_extracted );
587 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
587 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
588 }
588 }
589 else
589 else
590 {
590 {
591 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
591 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
592 }
592 }
593 }
593 }
594 }
594 }
595
595
596 //******************
596 //******************
597 // general functions
597 // general functions
598
598
599 void WFP_init_rings( void )
599 void WFP_init_rings( void )
600 {
600 {
601 // F0 RING
601 // F0 RING
602 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );