##// END OF EJS Templates
1039 problème de centrage des snapshots avec FSW 3.2.0.12
paul -
r363:071a09d6f71c R3++ draft
parent child
Show More
@@ -1,1343 +1,1343
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]= {0};
15 ring_node waveform_ring_f0[NB_RING_NODES_F0]= {0};
16 ring_node *current_ring_node_f0 = NULL;
16 ring_node *current_ring_node_f0 = NULL;
17 ring_node *ring_node_to_send_swf_f0 = NULL;
17 ring_node *ring_node_to_send_swf_f0 = NULL;
18 // F1
18 // F1
19 ring_node waveform_ring_f1[NB_RING_NODES_F1] = {0};
19 ring_node waveform_ring_f1[NB_RING_NODES_F1] = {0};
20 ring_node *current_ring_node_f1 = NULL;
20 ring_node *current_ring_node_f1 = NULL;
21 ring_node *ring_node_to_send_swf_f1 = NULL;
21 ring_node *ring_node_to_send_swf_f1 = NULL;
22 ring_node *ring_node_to_send_cwf_f1 = NULL;
22 ring_node *ring_node_to_send_cwf_f1 = NULL;
23 // F2
23 // F2
24 ring_node waveform_ring_f2[NB_RING_NODES_F2] = {0};
24 ring_node waveform_ring_f2[NB_RING_NODES_F2] = {0};
25 ring_node *current_ring_node_f2 = NULL;
25 ring_node *current_ring_node_f2 = NULL;
26 ring_node *ring_node_to_send_swf_f2 = NULL;
26 ring_node *ring_node_to_send_swf_f2 = NULL;
27 ring_node *ring_node_to_send_cwf_f2 = NULL;
27 ring_node *ring_node_to_send_cwf_f2 = NULL;
28 // F3
28 // F3
29 ring_node waveform_ring_f3[NB_RING_NODES_F3] = {0};
29 ring_node waveform_ring_f3[NB_RING_NODES_F3] = {0};
30 ring_node *current_ring_node_f3 = NULL;
30 ring_node *current_ring_node_f3 = NULL;
31 ring_node *ring_node_to_send_cwf_f3 = NULL;
31 ring_node *ring_node_to_send_cwf_f3 = NULL;
32 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ] = {0};
32 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ] = {0};
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) ] = {0};
41 int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0};
42 int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0};
42 int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0};
43 ring_node ring_node_swf1_extracted = {0};
43 ring_node ring_node_swf1_extracted = {0};
44 ring_node ring_node_swf2_extracted = {0};
44 ring_node ring_node_swf2_extracted = {0};
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 CHANNELF1:
61 case CHANNELF1:
62 node = ring_node_to_send_cwf_f1;
62 node = ring_node_to_send_cwf_f1;
63 break;
63 break;
64 case CHANNELF2:
64 case CHANNELF2:
65 node = ring_node_to_send_cwf_f2;
65 node = ring_node_to_send_cwf_f2;
66 break;
66 break;
67 case CHANNELF3:
67 case CHANNELF3:
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 CHANNELF0:
83 case CHANNELF0:
84 node = ring_node_to_send_swf_f0;
84 node = ring_node_to_send_swf_f0;
85 break;
85 break;
86 case CHANNELF1:
86 case CHANNELF1:
87 node = ring_node_to_send_swf_f1;
87 node = ring_node_to_send_swf_f1;
88 break;
88 break;
89 case CHANNELF2:
89 case CHANNELF2:
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 & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [1100 0000] check the f3 full bits
118 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [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 & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [0100 0000] f3 buffer 0 is full
121 if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [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 & RST_WFP_F3_0; // [1000 1000 0100 0000]
125 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_0; // [1000 1000 0100 0000]
126 }
126 }
127 else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [1000 0000] f3 buffer 1 is full
127 else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [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 & RST_WFP_F3_1; // [1000 1000 1000 0000]
131 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_1; // [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 & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2
145 status = (waveform_picker_regs->status & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2
146
146
147 switch(status)
147 switch(status)
148 {
148 {
149 case BIT_WFP_BUFFER_0:
149 case BIT_WFP_BUFFER_0:
150 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
150 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
151 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
151 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
152 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
152 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
153 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
153 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
154 current_ring_node_f2 = current_ring_node_f2->next;
154 current_ring_node_f2 = current_ring_node_f2->next;
155 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
155 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
156 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
156 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
157 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
157 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
158 }
158 }
159 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000]
159 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000]
160 break;
160 break;
161 case BIT_WFP_BUFFER_1:
161 case BIT_WFP_BUFFER_1:
162 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
162 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
163 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
163 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
164 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
164 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
165 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
165 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
166 current_ring_node_f2 = current_ring_node_f2->next;
166 current_ring_node_f2 = current_ring_node_f2->next;
167 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
167 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
168 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
168 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
169 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
169 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
170 }
170 }
171 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000]
171 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000]
172 break;
172 break;
173 default:
173 default:
174 break;
174 break;
175 }
175 }
176 }
176 }
177
177
178 inline void waveform_isr_normal_sbm1_sbm2( void )
178 inline void waveform_isr_normal_sbm1_sbm2( void )
179 {
179 {
180 rtems_status_code status;
180 rtems_status_code status;
181
181
182 //***
182 //***
183 // F0
183 // F0
184 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits
184 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits
185 {
185 {
186 swf0_ready_flag_f1 = true;
186 swf0_ready_flag_f1 = true;
187 swf0_ready_flag_f2 = true;
187 swf0_ready_flag_f2 = true;
188 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
188 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
189 current_ring_node_f0 = current_ring_node_f0->next;
189 current_ring_node_f0 = current_ring_node_f0->next;
190 if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0)
190 if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0)
191 {
191 {
192
192
193 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
193 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
194 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
194 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
195 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
195 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
196 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001]
196 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001]
197 }
197 }
198 else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1)
198 else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1)
199 {
199 {
200 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
200 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
201 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
201 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
202 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
202 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
203 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010]
203 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010]
204 }
204 }
205 // send an event to the WFRM task for resynchro activities
205 // send an event to the WFRM task for resynchro activities
206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH );
206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH );
207 }
207 }
208
208
209 //***
209 //***
210 // F1
210 // F1
211 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F1) != INIT_CHAR ) { // [0000 1100] check the f1 full bits
211 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F1) != INIT_CHAR ) { // [0000 1100] check the f1 full bits
212 // (1) change the receiving buffer for the waveform picker
212 // (1) change the receiving buffer for the waveform picker
213 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
213 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
214 current_ring_node_f1 = current_ring_node_f1->next;
214 current_ring_node_f1 = current_ring_node_f1->next;
215 if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0)
215 if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0)
216 {
216 {
217 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
217 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
218 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
218 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
219 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
219 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
220 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0
220 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0
221 }
221 }
222 else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1)
222 else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1)
223 {
223 {
224 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
224 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
225 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
225 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
226 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
226 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
227 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0
227 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0
228 }
228 }
229 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
229 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
230 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 );
230 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 );
231 }
231 }
232
232
233 //***
233 //***
234 // F2
234 // F2
235 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit
235 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit
236 // (1) change the receiving buffer for the waveform picker
236 // (1) change the receiving buffer for the waveform picker
237 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
237 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
238 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
238 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
239 current_ring_node_f2 = current_ring_node_f2->next;
239 current_ring_node_f2 = current_ring_node_f2->next;
240 if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0)
240 if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0)
241 {
241 {
242 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
242 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
243 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
243 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
244 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
244 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
245 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000]
245 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000]
246 }
246 }
247 else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1)
247 else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1)
248 {
248 {
249 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
249 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
250 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
250 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
251 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
251 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
252 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000]
252 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000]
253 }
253 }
254 // (2) send an event for the waveforms transmission
254 // (2) send an event for the waveforms transmission
255 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 );
255 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 );
256 }
256 }
257 }
257 }
258
258
259 rtems_isr waveforms_isr( rtems_vector_number vector )
259 rtems_isr waveforms_isr( rtems_vector_number vector )
260 {
260 {
261 /** This is the interrupt sub routine called by the waveform picker core.
261 /** This is the interrupt sub routine called by the waveform picker core.
262 *
262 *
263 * This ISR launch different actions depending mainly on two pieces of information:
263 * This ISR launch different actions depending mainly on two pieces of information:
264 * 1. the values read in the registers of the waveform picker.
264 * 1. the values read in the registers of the waveform picker.
265 * 2. the current LFR mode.
265 * 2. the current LFR mode.
266 *
266 *
267 */
267 */
268
268
269 // STATUS
269 // STATUS
270 // new error error buffer full
270 // new error error buffer full
271 // 15 14 13 12 11 10 9 8
271 // 15 14 13 12 11 10 9 8
272 // f3 f2 f1 f0 f3 f2 f1 f0
272 // f3 f2 f1 f0 f3 f2 f1 f0
273 //
273 //
274 // ready buffer
274 // ready buffer
275 // 7 6 5 4 3 2 1 0
275 // 7 6 5 4 3 2 1 0
276 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
276 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
277
277
278 rtems_status_code spare_status;
278 rtems_status_code spare_status;
279
279
280 waveforms_isr_f3();
280 waveforms_isr_f3();
281
281
282 //*************************************************
282 //*************************************************
283 // copy the status bits in the housekeeping packets
283 // copy the status bits in the housekeeping packets
284 housekeeping_packet.hk_lfr_vhdl_iir_cal =
284 housekeeping_packet.hk_lfr_vhdl_iir_cal =
285 (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE);
285 (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE);
286
286
287 if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits
287 if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits
288 {
288 {
289 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
289 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
290 }
290 }
291
291
292 switch(lfrCurrentMode)
292 switch(lfrCurrentMode)
293 {
293 {
294 //********
294 //********
295 // STANDBY
295 // STANDBY
296 case LFR_MODE_STANDBY:
296 case LFR_MODE_STANDBY:
297 break;
297 break;
298 //**************************
298 //**************************
299 // LFR NORMAL, SBM1 and SBM2
299 // LFR NORMAL, SBM1 and SBM2
300 case LFR_MODE_NORMAL:
300 case LFR_MODE_NORMAL:
301 case LFR_MODE_SBM1:
301 case LFR_MODE_SBM1:
302 case LFR_MODE_SBM2:
302 case LFR_MODE_SBM2:
303 waveform_isr_normal_sbm1_sbm2();
303 waveform_isr_normal_sbm1_sbm2();
304 break;
304 break;
305 //******
305 //******
306 // BURST
306 // BURST
307 case LFR_MODE_BURST:
307 case LFR_MODE_BURST:
308 waveforms_isr_burst();
308 waveforms_isr_burst();
309 break;
309 break;
310 //********
310 //********
311 // DEFAULT
311 // DEFAULT
312 default:
312 default:
313 break;
313 break;
314 }
314 }
315 }
315 }
316
316
317 //************
317 //************
318 // RTEMS TASKS
318 // RTEMS TASKS
319
319
320 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
320 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
321 {
321 {
322 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
322 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
323 *
323 *
324 * @param unused is the starting argument of the RTEMS task
324 * @param unused is the starting argument of the RTEMS task
325 *
325 *
326 * The following data packets are sent by this task:
326 * The following data packets are sent by this task:
327 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
327 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
328 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
328 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
329 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
329 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
330 *
330 *
331 */
331 */
332
332
333 rtems_event_set event_out;
333 rtems_event_set event_out;
334 rtems_id queue_id;
334 rtems_id queue_id;
335 rtems_status_code status;
335 rtems_status_code status;
336 ring_node *ring_node_swf1_extracted_ptr;
336 ring_node *ring_node_swf1_extracted_ptr;
337 ring_node *ring_node_swf2_extracted_ptr;
337 ring_node *ring_node_swf2_extracted_ptr;
338
338
339 event_out = EVENT_SETS_NONE_PENDING;
339 event_out = EVENT_SETS_NONE_PENDING;
340 queue_id = RTEMS_ID_NONE;
340 queue_id = RTEMS_ID_NONE;
341
341
342 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
342 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
343 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
343 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
344
344
345 status = get_message_queue_id_send( &queue_id );
345 status = get_message_queue_id_send( &queue_id );
346 if (status != RTEMS_SUCCESSFUL)
346 if (status != RTEMS_SUCCESSFUL)
347 {
347 {
348 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
348 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status);
349 }
349 }
350
350
351 BOOT_PRINTF("in WFRM ***\n");
351 BOOT_PRINTF("in WFRM ***\n");
352
352
353 while(1){
353 while(1){
354 // wait for an RTEMS_EVENT
354 // wait for an RTEMS_EVENT
355 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH,
355 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH,
356 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
356 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
357
357
358 if (event_out == RTEMS_EVENT_MODE_NORMAL)
358 if (event_out == RTEMS_EVENT_MODE_NORMAL)
359 {
359 {
360 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
360 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n");
361 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
361 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
362 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
362 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
363 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
363 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
364 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
364 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
365 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
365 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
366 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
366 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
367 }
367 }
368 if (event_out == RTEMS_EVENT_SWF_RESYNCH)
368 if (event_out == RTEMS_EVENT_SWF_RESYNCH)
369 {
369 {
370 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
370 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
371 }
371 }
372 }
372 }
373 }
373 }
374
374
375 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
375 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
376 {
376 {
377 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
377 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
378 *
378 *
379 * @param unused is the starting argument of the RTEMS task
379 * @param unused is the starting argument of the RTEMS task
380 *
380 *
381 * The following data packet is sent by this task:
381 * The following data packet is sent by this task:
382 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
382 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
383 *
383 *
384 */
384 */
385
385
386 rtems_event_set event_out;
386 rtems_event_set event_out;
387 rtems_id queue_id;
387 rtems_id queue_id;
388 rtems_status_code status;
388 rtems_status_code status;
389 ring_node ring_node_cwf3_light;
389 ring_node ring_node_cwf3_light;
390 ring_node *ring_node_to_send_cwf;
390 ring_node *ring_node_to_send_cwf;
391
391
392 event_out = EVENT_SETS_NONE_PENDING;
392 event_out = EVENT_SETS_NONE_PENDING;
393 queue_id = RTEMS_ID_NONE;
393 queue_id = RTEMS_ID_NONE;
394
394
395 status = get_message_queue_id_send( &queue_id );
395 status = get_message_queue_id_send( &queue_id );
396 if (status != RTEMS_SUCCESSFUL)
396 if (status != RTEMS_SUCCESSFUL)
397 {
397 {
398 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
398 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
399 }
399 }
400
400
401 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
401 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
402
402
403 // init the ring_node_cwf3_light structure
403 // init the ring_node_cwf3_light structure
404 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
404 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
405 ring_node_cwf3_light.coarseTime = INIT_CHAR;
405 ring_node_cwf3_light.coarseTime = INIT_CHAR;
406 ring_node_cwf3_light.fineTime = INIT_CHAR;
406 ring_node_cwf3_light.fineTime = INIT_CHAR;
407 ring_node_cwf3_light.next = NULL;
407 ring_node_cwf3_light.next = NULL;
408 ring_node_cwf3_light.previous = NULL;
408 ring_node_cwf3_light.previous = NULL;
409 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
409 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
410 ring_node_cwf3_light.status = INIT_CHAR;
410 ring_node_cwf3_light.status = INIT_CHAR;
411
411
412 BOOT_PRINTF("in CWF3 ***\n");
412 BOOT_PRINTF("in CWF3 ***\n");
413
413
414 while(1){
414 while(1){
415 // wait for an RTEMS_EVENT
415 // wait for an RTEMS_EVENT
416 rtems_event_receive( RTEMS_EVENT_0,
416 rtems_event_receive( RTEMS_EVENT_0,
417 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
417 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
418 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
418 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
419 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
419 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
420 {
420 {
421 ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 );
421 ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 );
422 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3)
422 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3)
423 {
423 {
424 PRINTF("send CWF_LONG_F3\n");
424 PRINTF("send CWF_LONG_F3\n");
425 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
425 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
426 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
426 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
427 }
427 }
428 else
428 else
429 {
429 {
430 PRINTF("send CWF_F3 (light)\n");
430 PRINTF("send CWF_F3 (light)\n");
431 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
431 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
432 }
432 }
433
433
434 }
434 }
435 else
435 else
436 {
436 {
437 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
437 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
438 }
438 }
439 }
439 }
440 }
440 }
441
441
442 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
442 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
443 {
443 {
444 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
444 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
445 *
445 *
446 * @param unused is the starting argument of the RTEMS task
446 * @param unused is the starting argument of the RTEMS task
447 *
447 *
448 * The following data packet is sent by this function:
448 * The following data packet is sent by this function:
449 * - TM_LFR_SCIENCE_BURST_CWF_F2
449 * - TM_LFR_SCIENCE_BURST_CWF_F2
450 * - TM_LFR_SCIENCE_SBM2_CWF_F2
450 * - TM_LFR_SCIENCE_SBM2_CWF_F2
451 *
451 *
452 */
452 */
453
453
454 rtems_event_set event_out;
454 rtems_event_set event_out;
455 rtems_id queue_id;
455 rtems_id queue_id;
456 rtems_status_code status;
456 rtems_status_code status;
457 ring_node *ring_node_to_send;
457 ring_node *ring_node_to_send;
458 unsigned long long int acquisitionTimeF0_asLong;
458 unsigned long long int acquisitionTimeF0_asLong;
459
459
460 event_out = EVENT_SETS_NONE_PENDING;
460 event_out = EVENT_SETS_NONE_PENDING;
461 queue_id = RTEMS_ID_NONE;
461 queue_id = RTEMS_ID_NONE;
462
462
463 acquisitionTimeF0_asLong = INIT_CHAR;
463 acquisitionTimeF0_asLong = INIT_CHAR;
464
464
465 status = get_message_queue_id_send( &queue_id );
465 status = get_message_queue_id_send( &queue_id );
466 if (status != RTEMS_SUCCESSFUL)
466 if (status != RTEMS_SUCCESSFUL)
467 {
467 {
468 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
468 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
469 }
469 }
470
470
471 BOOT_PRINTF("in CWF2 ***\n");
471 BOOT_PRINTF("in CWF2 ***\n");
472
472
473 while(1){
473 while(1){
474 // wait for an RTEMS_EVENT// send the snapshot when built
474 // wait for an RTEMS_EVENT// send the snapshot when built
475 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
475 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
476 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
476 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
477 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
477 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
478 ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 );
478 ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 );
479 if (event_out == RTEMS_EVENT_MODE_BURST)
479 if (event_out == RTEMS_EVENT_MODE_BURST)
480 { // data are sent whatever the transition time
480 { // data are sent whatever the transition time
481 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
481 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
482 }
482 }
483 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
483 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
484 {
484 {
485 if ( lfrCurrentMode == LFR_MODE_SBM2 )
485 if ( lfrCurrentMode == LFR_MODE_SBM2 )
486 {
486 {
487 // data are sent depending on the transition time
487 // data are sent depending on the transition time
488 if ( time_management_regs->coarse_time >= lastValidEnterModeTime)
488 if ( time_management_regs->coarse_time >= lastValidEnterModeTime)
489 {
489 {
490 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
490 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
491 }
491 }
492 }
492 }
493 // launch snapshot extraction if needed
493 // launch snapshot extraction if needed
494 if (extractSWF2 == true)
494 if (extractSWF2 == true)
495 {
495 {
496 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
496 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
497 // extract the snapshot
497 // extract the snapshot
498 build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong,
498 build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong,
499 &ring_node_swf2_extracted, swf2_extracted );
499 &ring_node_swf2_extracted, swf2_extracted );
500 extractSWF2 = false;
500 extractSWF2 = false;
501 swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM
501 swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM
502 }
502 }
503 if (swf0_ready_flag_f2 == true)
503 if (swf0_ready_flag_f2 == true)
504 {
504 {
505 extractSWF2 = true;
505 extractSWF2 = true;
506 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
506 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
507 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
507 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
508 swf0_ready_flag_f2 = false;
508 swf0_ready_flag_f2 = false;
509 }
509 }
510 }
510 }
511 }
511 }
512 }
512 }
513
513
514 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
514 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
515 {
515 {
516 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
516 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
517 *
517 *
518 * @param unused is the starting argument of the RTEMS task
518 * @param unused is the starting argument of the RTEMS task
519 *
519 *
520 * The following data packet is sent by this function:
520 * The following data packet is sent by this function:
521 * - TM_LFR_SCIENCE_SBM1_CWF_F1
521 * - TM_LFR_SCIENCE_SBM1_CWF_F1
522 *
522 *
523 */
523 */
524
524
525 rtems_event_set event_out;
525 rtems_event_set event_out;
526 rtems_id queue_id;
526 rtems_id queue_id;
527 rtems_status_code status;
527 rtems_status_code status;
528
528
529 ring_node *ring_node_to_send_cwf;
529 ring_node *ring_node_to_send_cwf;
530
530
531 event_out = EVENT_SETS_NONE_PENDING;
531 event_out = EVENT_SETS_NONE_PENDING;
532 queue_id = RTEMS_ID_NONE;
532 queue_id = RTEMS_ID_NONE;
533
533
534 status = get_message_queue_id_send( &queue_id );
534 status = get_message_queue_id_send( &queue_id );
535 if (status != RTEMS_SUCCESSFUL)
535 if (status != RTEMS_SUCCESSFUL)
536 {
536 {
537 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
537 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
538 }
538 }
539
539
540 BOOT_PRINTF("in CWF1 ***\n");
540 BOOT_PRINTF("in CWF1 ***\n");
541
541
542 while(1){
542 while(1){
543 // wait for an RTEMS_EVENT
543 // wait for an RTEMS_EVENT
544 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
544 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
545 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
545 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
546 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
546 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
547 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
547 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
548 if (lfrCurrentMode == LFR_MODE_SBM1)
548 if (lfrCurrentMode == LFR_MODE_SBM1)
549 {
549 {
550 // data are sent depending on the transition time
550 // data are sent depending on the transition time
551 if ( time_management_regs->coarse_time >= lastValidEnterModeTime )
551 if ( time_management_regs->coarse_time >= lastValidEnterModeTime )
552 {
552 {
553 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
553 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
554 }
554 }
555 }
555 }
556 // launch snapshot extraction if needed
556 // launch snapshot extraction if needed
557 if (extractSWF1 == true)
557 if (extractSWF1 == true)
558 {
558 {
559 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
559 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
560 // launch the snapshot extraction
560 // launch the snapshot extraction
561 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
561 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
562 extractSWF1 = false;
562 extractSWF1 = false;
563 }
563 }
564 if (swf0_ready_flag_f1 == true)
564 if (swf0_ready_flag_f1 == true)
565 {
565 {
566 extractSWF1 = true;
566 extractSWF1 = true;
567 swf0_ready_flag_f1 = false; // this step shall be executed only one time
567 swf0_ready_flag_f1 = false; // this step shall be executed only one time
568 }
568 }
569 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
569 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
570 {
570 {
571 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
571 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
572 swf1_ready = false;
572 swf1_ready = false;
573 swf2_ready = false;
573 swf2_ready = false;
574 }
574 }
575 }
575 }
576 }
576 }
577
577
578 rtems_task swbd_task(rtems_task_argument argument)
578 rtems_task swbd_task(rtems_task_argument argument)
579 {
579 {
580 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
580 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
581 *
581 *
582 * @param unused is the starting argument of the RTEMS task
582 * @param unused is the starting argument of the RTEMS task
583 *
583 *
584 */
584 */
585
585
586 rtems_event_set event_out;
586 rtems_event_set event_out;
587 unsigned long long int acquisitionTimeF0_asLong;
587 unsigned long long int acquisitionTimeF0_asLong;
588
588
589 event_out = EVENT_SETS_NONE_PENDING;
589 event_out = EVENT_SETS_NONE_PENDING;
590 acquisitionTimeF0_asLong = INIT_CHAR;
590 acquisitionTimeF0_asLong = INIT_CHAR;
591
591
592 BOOT_PRINTF("in SWBD ***\n")
592 BOOT_PRINTF("in SWBD ***\n")
593
593
594 while(1){
594 while(1){
595 // wait for an RTEMS_EVENT
595 // wait for an RTEMS_EVENT
596 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
596 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
597 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
597 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
598 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
598 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)