##// 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)
599 {
599 {
600 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
600 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
601 build_snapshot_from_ring( ring_node_to_send_swf_f1, CHANNELF1, acquisitionTimeF0_asLong,
601 build_snapshot_from_ring( ring_node_to_send_swf_f1, CHANNELF1, acquisitionTimeF0_asLong,
602 &ring_node_swf1_extracted, swf1_extracted );
602 &ring_node_swf1_extracted, swf1_extracted );
603 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
603 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
604 }
604 }
605 else
605 else
606 {
606 {
607 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
607 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
608 }
608 }
609 }
609 }
610 }
610 }
611
611
612 //******************
612 //******************
613 // general functions
613 // general functions
614
614
615 void WFP_init_rings( void )
615 void WFP_init_rings( void )
616 {
616 {
617 // F0 RING
617 // F0 RING
618 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
618 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
619 // F1 RING
619 // F1 RING
620 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
620 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
621 // F2 RING
621 // F2 RING
622 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
622 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
623 // F3 RING
623 // F3 RING
624 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
624 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
625
625
626 ring_node_swf1_extracted.buffer_address = (int) swf1_extracted;
626 ring_node_swf1_extracted.buffer_address = (int) swf1_extracted;
627 ring_node_swf2_extracted.buffer_address = (int) swf2_extracted;
627 ring_node_swf2_extracted.buffer_address = (int) swf2_extracted;
628
628
629 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
629 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
630 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
630 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
631 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
631 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
632 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
632 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
633 DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0)
633 DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0)
634 DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1)
634 DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1)
635 DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2)
635 DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2)
636 DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3)
636 DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3)
637
637
638 }
638 }
639
639
640 void WFP_reset_current_ring_nodes( void )
640 void WFP_reset_current_ring_nodes( void )
641 {
641 {
642 current_ring_node_f0 = waveform_ring_f0[0].next;
642 current_ring_node_f0 = waveform_ring_f0[0].next;
643 current_ring_node_f1 = waveform_ring_f1[0].next;
643 current_ring_node_f1 = waveform_ring_f1[0].next;
644 current_ring_node_f2 = waveform_ring_f2[0].next;
644 current_ring_node_f2 = waveform_ring_f2[0].next;
645 current_ring_node_f3 = waveform_ring_f3[0].next;
645 current_ring_node_f3 = waveform_ring_f3[0].next;
646
646
647 ring_node_to_send_swf_f0 = waveform_ring_f0;
647 ring_node_to_send_swf_f0 = waveform_ring_f0;
648 ring_node_to_send_swf_f1 = waveform_ring_f1;
648 ring_node_to_send_swf_f1 = waveform_ring_f1;
649 ring_node_to_send_swf_f2 = waveform_ring_f2;
649 ring_node_to_send_swf_f2 = waveform_ring_f2;
650
650
651 ring_node_to_send_cwf_f1 = waveform_ring_f1;
651 ring_node_to_send_cwf_f1 = waveform_ring_f1;
652 ring_node_to_send_cwf_f2 = waveform_ring_f2;
652 ring_node_to_send_cwf_f2 = waveform_ring_f2;
653 ring_node_to_send_cwf_f3 = waveform_ring_f3;
653 ring_node_to_send_cwf_f3 = waveform_ring_f3;
654 }
654 }
655
655
656 int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id )
656 int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id )
657 {
657 {
658 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
658 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
659 *
659 *
660 * @param waveform points to the buffer containing the data that will be send.
660 * @param waveform points to the buffer containing the data that will be send.
661 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
661 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
662 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
662 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
663 * contain information to setup the transmission of the data packets.
663 * contain information to setup the transmission of the data packets.
664 *
664 *
665 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
665 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
666 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
666 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
667 *
667 *
668 */
668 */
669
669
670 unsigned int i;
670 unsigned int i;
671 unsigned int j;
671 unsigned int j;
672 int ret;
672 int ret;
673 rtems_status_code status;
673 rtems_status_code status;
674
674
675 char *sample;
675 char *sample;
676 int *dataPtr;
676 int *dataPtr;
677
677
678 ret = LFR_DEFAULT;
678 ret = LFR_DEFAULT;
679
679
680 dataPtr = (int*) ring_node_to_send->buffer_address;
680 dataPtr = (int*) ring_node_to_send->buffer_address;
681
681
682 ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime;
682 ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime;
683 ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime;
683 ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime;
684
684
685 //**********************
685 //**********************
686 // BUILD CWF3_light DATA
686 // BUILD CWF3_light DATA
687 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
687 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
688 {
688 {
689 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
689 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
690 for (j=0; j < CWF_BLK_SIZE; j++)
690 for (j=0; j < CWF_BLK_SIZE; j++)
691 {
691 {
692 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ];
692 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ];
693 }
693 }
694 }
694 }
695
695
696 // SEND PACKET
696 // SEND PACKET
697 status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) );
697 status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) );
698 if (status != RTEMS_SUCCESSFUL) {
698 if (status != RTEMS_SUCCESSFUL) {
699 ret = LFR_DEFAULT;
699 ret = LFR_DEFAULT;
700 }
700 }
701
701
702 return ret;
702 return ret;
703 }
703 }
704
704
705 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
705 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
706 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
706 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
707 {
707 {
708 unsigned long long int acquisitionTimeAsLong;
708 unsigned long long int acquisitionTimeAsLong;
709 unsigned char localAcquisitionTime[BYTES_PER_TIME];
709 unsigned char localAcquisitionTime[BYTES_PER_TIME];
710 double deltaT;
710 double deltaT;
711
711
712 deltaT = INIT_FLOAT;
712 deltaT = INIT_FLOAT;
713
713
714 localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES );
714 localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES );
715 localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES );
715 localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES );
716 localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE );
716 localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE );
717 localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime );
717 localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime );
718 localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE );
718 localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE );
719 localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime );
719 localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime );
720
720
721 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES )
721 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES )
722 + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES )
722 + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES )
723 + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES )
723 + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES )
724 + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES )
724 + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES )
725 + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE )
725 + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE )
726 + ( (unsigned long long int) localAcquisitionTime[BYTE_5] );
726 + ( (unsigned long long int) localAcquisitionTime[BYTE_5] );
727
727
728 switch( sid )
728 switch( sid )
729 {
729 {
730 case SID_NORM_SWF_F0:
730 case SID_NORM_SWF_F0:
731 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ;
731 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ;
732 break;
732 break;
733
733
734 case SID_NORM_SWF_F1:
734 case SID_NORM_SWF_F1:
735 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ;
735 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ;
736 break;
736 break;
737
737
738 case SID_NORM_SWF_F2:
738 case SID_NORM_SWF_F2:
739 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ;
739 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ;
740 break;
740 break;
741
741
742 case SID_SBM1_CWF_F1:
742 case SID_SBM1_CWF_F1:
743 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ;
743 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ;
744 break;
744 break;
745
745
746 case SID_SBM2_CWF_F2:
746 case SID_SBM2_CWF_F2:
747 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ;
747 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ;
748 break;
748 break;
749
749
750 case SID_BURST_CWF_F2:
750 case SID_BURST_CWF_F2:
751 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ;
751 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ;
752 break;
752 break;
753
753
754 case SID_NORM_CWF_F3:
754 case SID_NORM_CWF_F3:
755 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ;
755 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ;
756 break;
756 break;
757
757
758 case SID_NORM_CWF_LONG_F3:
758 case SID_NORM_CWF_LONG_F3:
759 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ;
759 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ;
760 break;
760 break;
761
761
762 default:
762 default:
763 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid)
763 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid)
764 deltaT = 0.;
764 deltaT = 0.;
765 break;
765 break;
766 }
766 }
767
767
768 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
768 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
769 //
769 //
770 acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES);
770 acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES);
771 acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES);
771 acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES);
772 acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES);
772 acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES);
773 acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES);
773 acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES);
774 acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE );
774 acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE );
775 acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong );
775 acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong );
776
776
777 }
777 }
778
778
779 void build_snapshot_from_ring( ring_node *ring_node_to_send,
779 void build_snapshot_from_ring( ring_node *ring_node_to_send,
780 unsigned char frequencyChannel,
780 unsigned char frequencyChannel,
781 unsigned long long int acquisitionTimeF0_asLong,
781 unsigned long long int acquisitionTimeF0_asLong,
782 ring_node *ring_node_swf_extracted,
782 ring_node *ring_node_swf_extracted,
783 int *swf_extracted)
783 int *swf_extracted)
784 {
784 {
785 unsigned int i;
785 unsigned int i;
786 unsigned int node;
786 unsigned int node;
787 unsigned long long int centerTime_asLong;
787 unsigned long long int centerTime_asLong;
788 unsigned long long int acquisitionTime_asLong;
788 unsigned long long int acquisitionTime_asLong;
789 unsigned long long int bufferAcquisitionTime_asLong;
789 unsigned long long int bufferAcquisitionTime_asLong;
790 unsigned char *ptr1;
790 unsigned char *ptr1;
791 unsigned char *ptr2;
791 unsigned char *ptr2;
792 unsigned char *timeCharPtr;
792 unsigned char *timeCharPtr;
793 unsigned char nb_ring_nodes;
793 unsigned char nb_ring_nodes;
794 unsigned long long int frequency_asLong;
794 unsigned long long int frequency_asLong;
795 unsigned long long int nbTicksPerSample_asLong;
795 unsigned long long int nbTicksPerSample_asLong;
796 unsigned long long int nbSamplesPart1_asLong;
796 unsigned long long int nbSamplesPart1_asLong;
797 unsigned long long int sampleOffset_asLong;
797 unsigned long long int sampleOffset_asLong;
798
798
799 unsigned int deltaT_F0;
799 unsigned int deltaT_F0;
800 unsigned int deltaT_F1;
800 unsigned int deltaT_F1;
801 unsigned long long int deltaT_F2;
801 unsigned long long int deltaT_F2;
802
802
803 deltaT_F0 = DELTAT_F0;
803 deltaT_F0 = DELTAT_F0;
804 deltaT_F1 = DELTAF_F1;
804 deltaT_F1 = DELTAT_F1;
805 deltaT_F2 = DELTAF_F2;
805 deltaT_F2 = DELTAT_F2;
806 sampleOffset_asLong = INIT_CHAR;
806 sampleOffset_asLong = INIT_CHAR;
807
807
808 // (1) get the f0 acquisition time => the value is passed in argument
808 // (1) get the f0 acquisition time => the value is passed in argument
809
809
810 // (2) compute the central reference time
810 // (2) compute the central reference time
811 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
811 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
812 acquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2)
812 acquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2)
813 bufferAcquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2)
813 bufferAcquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2)
814 nbTicksPerSample_asLong = TICKS_PER_T2; //set to default value (Don_Initialisation_P2)
814 nbTicksPerSample_asLong = TICKS_PER_T2; //set to default value (Don_Initialisation_P2)
815
815
816 // (3) compute the acquisition time of the current snapshot
816 // (3) compute the acquisition time of the current snapshot
817 switch(frequencyChannel)
817 switch(frequencyChannel)
818 {
818 {
819 case CHANNELF1: // 1 is for F1 = 4096 Hz
819 case CHANNELF1: // 1 is for F1 = 4096 Hz
820 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
820 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
821 nb_ring_nodes = NB_RING_NODES_F1;
821 nb_ring_nodes = NB_RING_NODES_F1;
822 frequency_asLong = FREQ_F1;
822 frequency_asLong = FREQ_F1;
823 nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096;
823 nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096;
824 break;
824 break;
825 case CHANNELF2: // 2 is for F2 = 256 Hz
825 case CHANNELF2: // 2 is for F2 = 256 Hz
826 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
826 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
827 nb_ring_nodes = NB_RING_NODES_F2;
827 nb_ring_nodes = NB_RING_NODES_F2;
828 frequency_asLong = FREQ_F2;
828 frequency_asLong = FREQ_F2;
829 nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256;
829 nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256;
830 break;
830 break;
831 default:
831 default:
832 acquisitionTime_asLong = centerTime_asLong;
832 acquisitionTime_asLong = centerTime_asLong;
833 nb_ring_nodes = 0;
833 nb_ring_nodes = 0;
834 frequency_asLong = FREQ_F2;
834 frequency_asLong = FREQ_F2;
835 nbTicksPerSample_asLong = TICKS_PER_T2;
835 nbTicksPerSample_asLong = TICKS_PER_T2;
836 break;
836 break;
837 }
837 }
838
838
839 //*****************************************************************************
839 //*****************************************************************************
840 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
840 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
841 node = 0;
841 node = 0;
842 while ( node < nb_ring_nodes)
842 while ( node < nb_ring_nodes)
843 {
843 {
844 //PRINTF1("%d ... ", node);
844 //PRINTF1("%d ... ", node);
845 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
845 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
846 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
846 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
847 {
847 {
848 //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong);
848 //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong);
849 node = nb_ring_nodes;
849 node = nb_ring_nodes;
850 }
850 }
851 else
851 else
852 {
852 {
853 node = node + 1;
853 node = node + 1;
854 ring_node_to_send = ring_node_to_send->previous;
854 ring_node_to_send = ring_node_to_send->previous;
855 }
855 }
856 }
856 }
857
857
858 // (5) compute the number of samples to take in the current buffer
858 // (5) compute the number of samples to take in the current buffer
859 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES;
859 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES;
860 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
860 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
861 //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong);
861 //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong);
862
862
863 // (6) compute the final acquisition time
863 // (6) compute the final acquisition time
864 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
864 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
865 (sampleOffset_asLong * nbTicksPerSample_asLong);
865 (sampleOffset_asLong * nbTicksPerSample_asLong);
866
866
867 // (7) copy the acquisition time at the beginning of the extrated snapshot
867 // (7) copy the acquisition time at the beginning of the extrated snapshot
868 ptr1 = (unsigned char*) &acquisitionTime_asLong;
868 ptr1 = (unsigned char*) &acquisitionTime_asLong;
869 // fine time
869 // fine time
870 ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime;
870 ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime;
871 ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ];
871 ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ];
872 ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ];
872 ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ];
873 // coarse time
873 // coarse time
874 ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime;
874 ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime;
875 ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ];
875 ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ];
876 ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ];
876 ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ];
877 ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ];
877 ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ];
878 ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ];
878 ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ];
879
879
880 // re set the synchronization bit
880 // re set the synchronization bit
881 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
881 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
882 ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000]
882 ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000]
883
883
884 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
884 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
885 {
885 {
886 nbSamplesPart1_asLong = 0;
886 nbSamplesPart1_asLong = 0;
887 }
887 }
888 // copy the part 1 of the snapshot in the extracted buffer
888 // copy the part 1 of the snapshot in the extracted buffer
889 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
889 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
890 {
890 {
891 swf_extracted[i] =
891 swf_extracted[i] =
892 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
892 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
893 }
893 }
894 // copy the part 2 of the snapshot in the extracted buffer
894 // copy the part 2 of the snapshot in the extracted buffer
895 ring_node_to_send = ring_node_to_send->next;
895 ring_node_to_send = ring_node_to_send->next;
896 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
896 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
897 {
897 {
898 swf_extracted[i] =
898 swf_extracted[i] =
899 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
899 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
900 }
900 }
901 }
901 }
902
902
903 double computeCorrection( unsigned char *timePtr )
903 double computeCorrection( unsigned char *timePtr )
904 {
904 {
905 unsigned long long int acquisitionTime;
905 unsigned long long int acquisitionTime;
906 unsigned long long int centerTime;
906 unsigned long long int centerTime;
907 unsigned long long int previousTick;
907 unsigned long long int previousTick;
908 unsigned long long int nextTick;
908 unsigned long long int nextTick;
909 unsigned long long int deltaPreviousTick;
909 unsigned long long int deltaPreviousTick;
910 unsigned long long int deltaNextTick;
910 unsigned long long int deltaNextTick;
911 double deltaPrevious_ms;
911 double deltaPrevious_ms;
912 double deltaNext_ms;
912 double deltaNext_ms;
913 double correctionInF2;
913 double correctionInF2;
914
914
915 correctionInF2 = 0; //set to default value (Don_Initialisation_P2)
915 correctionInF2 = 0; //set to default value (Don_Initialisation_P2)
916
916
917 // get acquisition time in fine time ticks
917 // get acquisition time in fine time ticks
918 acquisitionTime = get_acquisition_time( timePtr );
918 acquisitionTime = get_acquisition_time( timePtr );
919
919
920 // compute center time
920 // compute center time
921 centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667;
921 centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667;
922 previousTick = centerTime - (centerTime & INT16_ALL_F);
922 previousTick = centerTime - (centerTime & INT16_ALL_F);
923 nextTick = previousTick + TICKS_PER_S;
923 nextTick = previousTick + TICKS_PER_S;
924
924
925 deltaPreviousTick = centerTime - previousTick;
925 deltaPreviousTick = centerTime - previousTick;
926 deltaNextTick = nextTick - centerTime;
926 deltaNextTick = nextTick - centerTime;
927
927
928 deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S;
928 deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S;
929 deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S;
929 deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S;
930
930
931 PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms);
931 PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms);
932
932
933 // which tick is the closest?
933 // which tick is the closest?
934 if (deltaPreviousTick > deltaNextTick)
934 if (deltaPreviousTick > deltaNextTick)
935 {
935 {
936 // the snapshot center is just before the second => increase delta_snapshot
936 // the snapshot center is just before the second => increase delta_snapshot
937 correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S );
937 correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S );
938 }
938 }
939 else
939 else
940 {
940 {
941 // the snapshot center is just after the second => decrease delta_snapshot
941 // the snapshot center is just after the second => decrease delta_snapshot
942 correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S );
942 correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S );
943 }
943 }
944
944
945 PRINTF1(" correctionInF2 = %.2f\n", correctionInF2);
945 PRINTF1(" correctionInF2 = %.2f\n", correctionInF2);
946
946
947 return correctionInF2;
947 return correctionInF2;
948 }
948 }
949
949
950 void applyCorrection( double correction )
950 void applyCorrection( double correction )
951 {
951 {
952 int correctionInt;
952 int correctionInt;
953
953
954 correctionInt = 0;
954 correctionInt = 0;
955
955
956 if (correction >= 0.)
956 if (correction >= 0.)
957 {
957 {
958 if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) )
958 if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) )
959 {
959 {
960 correctionInt = ONE_TICK_CORR;
960 correctionInt = ONE_TICK_CORR;
961 }
961 }
962 else
962 else
963 {
963 {
964 correctionInt = CORR_MULT * floor(correction);
964 correctionInt = CORR_MULT * floor(correction);
965 }
965 }
966 }
966 }
967 else
967 else
968 {
968 {
969 if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) )
969 if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) )
970 {
970 {
971 correctionInt = -ONE_TICK_CORR;
971 correctionInt = -ONE_TICK_CORR;
972 }
972 }
973 else
973 else
974 {
974 {
975 correctionInt = CORR_MULT * ceil(correction);
975 correctionInt = CORR_MULT * ceil(correction);
976 }
976 }
977 }
977 }
978 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt;
978 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt;
979 }
979 }
980
980
981 void snapshot_resynchronization( unsigned char *timePtr )
981 void snapshot_resynchronization( unsigned char *timePtr )
982 {
982 {
983 /** This function compute a correction to apply on delta_snapshot.
983 /** This function compute a correction to apply on delta_snapshot.
984 *
984 *
985 *
985 *
986 * @param timePtr is a pointer to the acquisition time of the snapshot being considered.
986 * @param timePtr is a pointer to the acquisition time of the snapshot being considered.
987 *
987 *
988 * @return void
988 * @return void
989 *
989 *
990 */
990 */
991
991
992 static double correction = INIT_FLOAT;
992 static double correction = INIT_FLOAT;
993 static resynchro_state state = MEASURE;
993 static resynchro_state state = MEASURE;
994 static unsigned int nbSnapshots = 0;
994 static unsigned int nbSnapshots = 0;
995
995
996 int correctionInt;
996 int correctionInt;
997
997
998 correctionInt = 0;
998 correctionInt = 0;
999
999
1000 switch (state)
1000 switch (state)
1001 {
1001 {
1002
1002
1003 case MEASURE:
1003 case MEASURE:
1004 // ********
1004 // ********
1005 PRINTF1("MEASURE === %d\n", nbSnapshots);
1005 PRINTF1("MEASURE === %d\n", nbSnapshots);
1006 state = CORRECTION;
1006 state = CORRECTION;
1007 correction = computeCorrection( timePtr );
1007 correction = computeCorrection( timePtr );
1008 PRINTF1("MEASURE === correction = %.2f\n", correction );
1008 PRINTF1("MEASURE === correction = %.2f\n", correction );
1009 applyCorrection( correction );
1009 applyCorrection( correction );
1010 PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
1010 PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
1011 //****
1011 //****
1012 break;
1012 break;
1013
1013
1014 case CORRECTION:
1014 case CORRECTION:
1015 //************
1015 //************
1016 PRINTF1("CORRECTION === %d\n", nbSnapshots);
1016 PRINTF1("CORRECTION === %d\n", nbSnapshots);
1017 state = MEASURE;
1017 state = MEASURE;
1018 computeCorrection( timePtr );
1018 computeCorrection( timePtr );
1019 set_wfp_delta_snapshot();
1019 set_wfp_delta_snapshot();
1020 PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
1020 PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
1021 //****
1021 //****
1022 break;
1022 break;
1023
1023
1024 default:
1024 default:
1025 break;
1025 break;
1026
1026
1027 }
1027 }
1028
1028
1029 nbSnapshots++;
1029 nbSnapshots++;
1030 }
1030 }
1031
1031
1032 //**************
1032 //**************
1033 // wfp registers
1033 // wfp registers
1034 void reset_wfp_burst_enable( void )
1034 void reset_wfp_burst_enable( void )
1035 {
1035 {
1036 /** This function resets the waveform picker burst_enable register.
1036 /** This function resets the waveform picker burst_enable register.
1037 *
1037 *
1038 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1038 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1039 *
1039 *
1040 */
1040 */
1041
1041
1042 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1042 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1043 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN;
1043 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN;
1044 }
1044 }
1045
1045
1046 void reset_wfp_status( void )
1046 void reset_wfp_status( void )
1047 {
1047 {
1048 /** This function resets the waveform picker status register.
1048 /** This function resets the waveform picker status register.
1049 *
1049 *
1050 * All status bits are set to 0 [new_err full_err full].
1050 * All status bits are set to 0 [new_err full_err full].
1051 *
1051 *
1052 */
1052 */
1053
1053
1054 waveform_picker_regs->status = INT16_ALL_F;
1054 waveform_picker_regs->status = INT16_ALL_F;
1055 }
1055 }
1056
1056
1057 void reset_wfp_buffer_addresses( void )
1057 void reset_wfp_buffer_addresses( void )
1058 {
1058 {
1059 // F0
1059 // F0
1060 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08
1060 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08
1061 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1061 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1062 // F1
1062 // F1
1063 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10
1063 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10
1064 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1064 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1065 // F2
1065 // F2
1066 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18
1066 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18
1067 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1067 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1068 // F3
1068 // F3
1069 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20
1069 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20
1070 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1070 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1071 }
1071 }
1072
1072
1073 void reset_waveform_picker_regs( void )
1073 void reset_waveform_picker_regs( void )
1074 {
1074 {
1075 /** This function resets the waveform picker module registers.
1075 /** This function resets the waveform picker module registers.
1076 *
1076 *
1077 * The registers affected by this function are located at the following offset addresses:
1077 * The registers affected by this function are located at the following offset addresses:
1078 * - 0x00 data_shaping
1078 * - 0x00 data_shaping
1079 * - 0x04 run_burst_enable
1079 * - 0x04 run_burst_enable
1080 * - 0x08 addr_data_f0
1080 * - 0x08 addr_data_f0
1081 * - 0x0C addr_data_f1
1081 * - 0x0C addr_data_f1
1082 * - 0x10 addr_data_f2
1082 * - 0x10 addr_data_f2
1083 * - 0x14 addr_data_f3
1083 * - 0x14 addr_data_f3
1084 * - 0x18 status
1084 * - 0x18 status
1085 * - 0x1C delta_snapshot
1085 * - 0x1C delta_snapshot
1086 * - 0x20 delta_f0
1086 * - 0x20 delta_f0
1087 * - 0x24 delta_f0_2
1087 * - 0x24 delta_f0_2
1088 * - 0x28 delta_f1 (obsolet parameter)
1088 * - 0x28 delta_f1 (obsolet parameter)
1089 * - 0x2c delta_f2
1089 * - 0x2c delta_f2
1090 * - 0x30 nb_data_by_buffer
1090 * - 0x30 nb_data_by_buffer
1091 * - 0x34 nb_snapshot_param
1091 * - 0x34 nb_snapshot_param
1092 * - 0x38 start_date
1092 * - 0x38 start_date
1093 * - 0x3c nb_word_in_buffer
1093 * - 0x3c nb_word_in_buffer
1094 *
1094 *
1095 */
1095 */
1096
1096
1097 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1097 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1098
1098
1099 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1099 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1100
1100
1101 reset_wfp_buffer_addresses();
1101 reset_wfp_buffer_addresses();
1102
1102
1103 reset_wfp_status(); // 0x18
1103 reset_wfp_status(); // 0x18
1104
1104
1105 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1105 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1106
1106
1107 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1107 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1108
1108
1109 //the parameter delta_f1 [0x28] is not used anymore
1109 //the parameter delta_f1 [0x28] is not used anymore
1110
1110
1111 set_wfp_delta_f2(); // 0x2c
1111 set_wfp_delta_f2(); // 0x2c
1112
1112
1113 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot);
1113 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot);
1114 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0);
1114 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0);
1115 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2);
1115 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2);
1116 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1);
1116 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1);
1117 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2);
1117 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2);
1118 // 2688 = 8 * 336
1118 // 2688 = 8 * 336
1119 waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1
1119 waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1
1120 waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples
1120 waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples
1121 waveform_picker_regs->start_date = COARSE_TIME_MASK;
1121 waveform_picker_regs->start_date = COARSE_TIME_MASK;
1122 //
1122 //
1123 // coarse time and fine time registers are not initialized, they are volatile
1123 // coarse time and fine time registers are not initialized, they are volatile
1124 //
1124 //
1125 waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1125 waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1126 }
1126 }
1127
1127
1128 void set_wfp_data_shaping( void )
1128 void set_wfp_data_shaping( void )
1129 {
1129 {
1130 /** This function sets the data_shaping register of the waveform picker module.
1130 /** This function sets the data_shaping register of the waveform picker module.
1131 *
1131 *
1132 * The value is read from one field of the parameter_dump_packet structure:\n
1132 * The value is read from one field of the parameter_dump_packet structure:\n
1133 * bw_sp0_sp1_r0_r1
1133 * bw_sp0_sp1_r0_r1
1134 *
1134 *
1135 */
1135 */
1136
1136
1137 unsigned char data_shaping;
1137 unsigned char data_shaping;
1138
1138
1139 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1139 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1140 // waveform picker : [R1 R0 SP1 SP0 BW]
1140 // waveform picker : [R1 R0 SP1 SP0 BW]
1141
1141
1142 data_shaping = parameter_dump_packet.sy_lfr_common_parameters;
1142 data_shaping = parameter_dump_packet.sy_lfr_common_parameters;
1143
1143
1144 waveform_picker_regs->data_shaping =
1144 waveform_picker_regs->data_shaping =
1145 ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW
1145 ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW
1146 + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0
1146 + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0
1147 + ( (data_shaping & BIT_3) >> 1 ) // SP1
1147 + ( (data_shaping & BIT_3) >> 1 ) // SP1
1148 + ( (data_shaping & BIT_2) << 1 ) // R0
1148 + ( (data_shaping & BIT_2) << 1 ) // R0
1149 + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1
1149 + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1
1150 + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2
1150 + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2
1151 }
1151 }
1152
1152
1153 void set_wfp_burst_enable_register( unsigned char mode )
1153 void set_wfp_burst_enable_register( unsigned char mode )
1154 {
1154 {
1155 /** This function sets the waveform picker burst_enable register depending on the mode.
1155 /** This function sets the waveform picker burst_enable register depending on the mode.
1156 *
1156 *
1157 * @param mode is the LFR mode to launch.
1157 * @param mode is the LFR mode to launch.
1158 *
1158 *
1159 * The burst bits shall be before the enable bits.
1159 * The burst bits shall be before the enable bits.
1160 *
1160 *
1161 */
1161 */
1162
1162
1163 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1163 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1164 // the burst bits shall be set first, before the enable bits
1164 // the burst bits shall be set first, before the enable bits
1165 switch(mode) {
1165 switch(mode) {
1166 case LFR_MODE_NORMAL:
1166 case LFR_MODE_NORMAL:
1167 case LFR_MODE_SBM1:
1167 case LFR_MODE_SBM1:
1168 case LFR_MODE_SBM2:
1168 case LFR_MODE_SBM2:
1169 waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst
1169 waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst
1170 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_ALL; // [1111] enable f3 f2 f1 f0
1170 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_ALL; // [1111] enable f3 f2 f1 f0
1171 break;
1171 break;
1172 case LFR_MODE_BURST:
1172 case LFR_MODE_BURST:
1173 waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled
1173 waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled
1174 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_BURST; // [1100] enable f3 and f2
1174 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_BURST; // [1100] enable f3 and f2
1175 break;
1175 break;
1176 default:
1176 default:
1177 waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled
1177 waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled
1178 break;
1178 break;
1179 }
1179 }
1180 }
1180 }
1181
1181
1182 void set_wfp_delta_snapshot( void )
1182 void set_wfp_delta_snapshot( void )
1183 {
1183 {
1184 /** This function sets the delta_snapshot register of the waveform picker module.
1184 /** This function sets the delta_snapshot register of the waveform picker module.
1185 *
1185 *
1186 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1186 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1187 * - sy_lfr_n_swf_p[0]
1187 * - sy_lfr_n_swf_p[0]
1188 * - sy_lfr_n_swf_p[1]
1188 * - sy_lfr_n_swf_p[1]
1189 *
1189 *
1190 */
1190 */
1191
1191
1192 unsigned int delta_snapshot;
1192 unsigned int delta_snapshot;
1193 unsigned int delta_snapshot_in_T2;
1193 unsigned int delta_snapshot_in_T2;
1194
1194
1195 delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256)
1195 delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256)
1196 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1196 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1197
1197
1198 delta_snapshot_in_T2 = delta_snapshot * FREQ_F2;
1198 delta_snapshot_in_T2 = delta_snapshot * FREQ_F2;
1199 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1199 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1200 }
1200 }
1201
1201
1202 void set_wfp_delta_f0_f0_2( void )
1202 void set_wfp_delta_f0_f0_2( void )
1203 {
1203 {
1204 unsigned int delta_snapshot;
1204 unsigned int delta_snapshot;
1205 unsigned int nb_samples_per_snapshot;
1205 unsigned int nb_samples_per_snapshot;
1206 float delta_f0_in_float;
1206 float delta_f0_in_float;
1207
1207
1208 delta_snapshot = waveform_picker_regs->delta_snapshot;
1208 delta_snapshot = waveform_picker_regs->delta_snapshot;
1209 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1209 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1210 delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2;
1210 delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2;
1211
1211
1212 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1212 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1213 waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2;
1213 waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2;
1214 }
1214 }
1215
1215
1216 void set_wfp_delta_f1( void )
1216 void set_wfp_delta_f1( void )
1217 {
1217 {
1218 /** Sets the value of the delta_f1 parameter
1218 /** Sets the value of the delta_f1 parameter
1219 *
1219 *
1220 * @param void
1220 * @param void
1221 *
1221 *
1222 * @return void
1222 * @return void
1223 *
1223 *
1224 * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms.
1224 * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms.
1225 *
1225 *
1226 */
1226 */
1227
1227
1228 unsigned int delta_snapshot;
1228 unsigned int delta_snapshot;
1229 unsigned int nb_samples_per_snapshot;
1229 unsigned int nb_samples_per_snapshot;
1230 float delta_f1_in_float;
1230 float delta_f1_in_float;
1231
1231
1232 delta_snapshot = waveform_picker_regs->delta_snapshot;
1232 delta_snapshot = waveform_picker_regs->delta_snapshot;
1233 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1233 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1234 delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2;
1234 delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2;
1235
1235
1236 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1236 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1237 }
1237 }
1238
1238
1239 void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used
1239 void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used
1240 {
1240 {
1241 /** Sets the value of the delta_f2 parameter
1241 /** Sets the value of the delta_f2 parameter
1242 *
1242 *
1243 * @param void
1243 * @param void
1244 *
1244 *
1245 * @return void
1245 * @return void
1246 *
1246 *
1247 * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2
1247 * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2
1248 * waveforms (see lpp_waveform_snapshot_controler.vhd for details).
1248 * waveforms (see lpp_waveform_snapshot_controler.vhd for details).
1249 *
1249 *
1250 */
1250 */
1251
1251
1252 unsigned int delta_snapshot;
1252 unsigned int delta_snapshot;
1253 unsigned int nb_samples_per_snapshot;
1253 unsigned int nb_samples_per_snapshot;
1254
1254
1255 delta_snapshot = waveform_picker_regs->delta_snapshot;
1255 delta_snapshot = waveform_picker_regs->delta_snapshot;
1256 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1256 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1257
1257
1258 waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1;
1258 waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1;
1259 }
1259 }
1260
1260
1261 //*****************
1261 //*****************
1262 // local parameters
1262 // local parameters
1263
1263
1264 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1264 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1265 {
1265 {
1266 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1266 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1267 *
1267 *
1268 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1268 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1269 * @param sid is the source identifier of the packet being updated.
1269 * @param sid is the source identifier of the packet being updated.
1270 *
1270 *
1271 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1271 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1272 * The sequence counters shall wrap around from 2^14 to zero.
1272 * The sequence counters shall wrap around from 2^14 to zero.
1273 * The sequence counter shall start at zero at startup.
1273 * The sequence counter shall start at zero at startup.
1274 *
1274 *
1275 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1275 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1276 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1276 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1277 *
1277 *
1278 */
1278 */
1279
1279
1280 unsigned short *sequence_cnt;
1280 unsigned short *sequence_cnt;
1281 unsigned short segmentation_grouping_flag;
1281 unsigned short segmentation_grouping_flag;
1282 unsigned short new_packet_sequence_control;
1282 unsigned short new_packet_sequence_control;
1283 rtems_mode initial_mode_set;
1283 rtems_mode initial_mode_set;
1284 rtems_mode current_mode_set;
1284 rtems_mode current_mode_set;
1285 rtems_status_code status;
1285 rtems_status_code status;
1286
1286
1287 initial_mode_set = RTEMS_DEFAULT_MODES;
1287 initial_mode_set = RTEMS_DEFAULT_MODES;
1288 current_mode_set = RTEMS_DEFAULT_MODES;
1288 current_mode_set = RTEMS_DEFAULT_MODES;
1289 sequence_cnt = NULL;
1289 sequence_cnt = NULL;
1290
1290
1291 //******************************************
1291 //******************************************
1292 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1292 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1293 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1293 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1294
1294
1295 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1295 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1296 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1296 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1297 || (sid == SID_BURST_CWF_F2)
1297 || (sid == SID_BURST_CWF_F2)
1298 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1298 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1299 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1299 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1300 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1300 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1301 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1301 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1302 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1302 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1303 {
1303 {
1304 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1304 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1305 }
1305 }
1306 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1306 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1307 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1307 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1308 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1308 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1309 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1309 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1310 {
1310 {
1311 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1311 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1312 }
1312 }
1313 else
1313 else
1314 {
1314 {
1315 sequence_cnt = (unsigned short *) NULL;
1315 sequence_cnt = (unsigned short *) NULL;
1316 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1316 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1317 }
1317 }
1318
1318
1319 if (sequence_cnt != NULL)
1319 if (sequence_cnt != NULL)
1320 {
1320 {
1321 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
1321 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
1322 *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK;
1322 *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK;
1323
1323
1324 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1324 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1325
1325
1326 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
1326 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
1327 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1327 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1328
1328
1329 // increment the sequence counter
1329 // increment the sequence counter
1330 if ( *sequence_cnt < SEQ_CNT_MAX)
1330 if ( *sequence_cnt < SEQ_CNT_MAX)
1331 {
1331 {
1332 *sequence_cnt = *sequence_cnt + 1;
1332 *sequence_cnt = *sequence_cnt + 1;
1333 }
1333 }
1334 else
1334 else
1335 {
1335 {
1336 *sequence_cnt = 0;
1336 *sequence_cnt = 0;
1337 }
1337 }
1338 }
1338 }
1339
1339
1340 //*************************************
1340 //*************************************
1341 // RESTORE THE MODE OF THE CALLING TASK
1341 // RESTORE THE MODE OF THE CALLING TASK
1342 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1342 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1343 }
1343 }
General Comments 0
You need to be logged in to leave comments. Login now