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