##// END OF EJS Templates
the function asm_reorganize format the spectral matrix to the ICD format
paul -
r103:b24459a013ed VHDLib206
parent child
Show More
@@ -1,12 +1,12
1 1 #!/usr/bin/lppmon -e
2 2
3 proxy.loadSysDriver("RMAPPlugin","RMAPplugin0");
4 proxy.loadSysDriverToParent("dsu3plugin","RMAPplugin0");
3 proxy.loadSysDriver("RMAPPlugin","RMAPPlugin0");
4 proxy.loadSysDriverToParent("dsu3plugin","RMAPPlugin0");
5 5
6 6 #BUTTON_selectStarDundee.click()
7 7 BUTTON_selectGRESB.click()
8 BUTTON_rmapOpenCommunication.click()
8 9
9 BUTTON_rmapOpenCommunication.click()
10 10 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
11 11 dsu3plugin0.loadFile()
12 12 dsu3plugin0.run()
@@ -7,13 +7,14 print hex(matrixF0_Address0)
7 7
8 8 # BUILD THE DATA
9 9 dataToWrite = []
10 for frequencyBin in range(128):
11 for component in range (25):
12 dataToWrite.append( component )
10 dataToWrite.append( 0x1234abcd )
11 dataToWrite.append( 0x4321dcba )
13 12
14 #for frequencyBin in range(64):
15 # for component in range (25):
16 # dataToWrite.append( 2 * component )
13 for component in range(25):
14 for frequencyBin in range (64):
15 dataToWrite.append( component + frequencyBin )
16 for frequencyBin in range (64):
17 dataToWrite.append( - (component + frequencyBin) )
17 18
18 19 # WRITE THE DATA
19 20 print len(dataToWrite)
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.0, 2014-02-21T15:56:03. -->
3 <!-- Written by QtCreator 3.0.0, 2014-03-03T07:03:32. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -12,9 +12,9
12 12 #include "fsw_spacewire.h"
13 13 #include "basic_parameters.h"
14 14
15 extern volatile int sm_f0[ ][ SM_HEADER + TOTAL_SIZE_SM ];
16 extern volatile int sm_f1[ ][ SM_HEADER + TOTAL_SIZE_SM ];
17 extern volatile int sm_f2[ ][ SM_HEADER + TOTAL_SIZE_SM ];
15 extern volatile int sm_f0[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
16 extern volatile int sm_f1[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
17 extern volatile int sm_f2[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
18 18
19 19 // parameters
20 20 extern struct param_local_str param_local;
@@ -44,9 +44,10 void BP1_set_old(float * compressed_spec
44 44 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
45 45 //
46 46 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
47 void compress_averaged_spectral_matrix( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
48 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
49 void send_averaged_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
47 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized );
48 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
49 void ASM_convert(volatile float *input_matrix, char *output_matrix);
50 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
50 51 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
51 52 void fill_averaged_spectral_matrix( void );
52 53 void reset_spectral_matrix_regs();
@@ -39,6 +39,9 int restart_science_tasks();
39 39 int suspend_science_tasks();
40 40 void launch_waveform_picker( unsigned char mode );
41 41 void launch_spectral_matrix( unsigned char mode );
42 void enable_irq_on_new_ready_matrix( void );
43 void disable_irq_on_new_ready_matrix( void );
44 void launch_spectral_matrix_simu( unsigned char mode );
42 45
43 46 // other functions
44 47 void updateLFRCurrentMode();
@@ -46,9 +46,9 volatile int wf_cont_f3_b [ (NB_SAMPL
46 46 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
47 47
48 48 // SPECTRAL MATRICES GLOBAL VARIABLES
49 volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ SM_HEADER + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ SM_HEADER + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ SM_HEADER + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
49 volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 52
53 53 // APB CONFIGURATION REGISTERS
54 54 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
@@ -179,6 +179,10 rtems_task Init( rtems_task_argument ign
179 179 status = rtems_interrupt_catch( waveforms_isr,
180 180 IRQ_SPARC_WAVEFORM_PICKER,
181 181 &old_isr_handler) ;
182 // configure IRQ handling for the spectral matrices unit
183 status = rtems_interrupt_catch( spectral_matrices_isr,
184 IRQ_SPARC_SPECTRAL_MATRIX,
185 &old_isr_handler) ;
182 186
183 187 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
184 188 if ( status_spw != RTEMS_SUCCESSFUL )
@@ -232,21 +232,23 rtems_task dumb_task( rtems_task_argumen
232 232 unsigned int fine_time = 0;
233 233 rtems_event_set event_out;
234 234
235 char *DumbMessages[8] = {"in DUMB *** default", // RTEMS_EVENT_0
235 char *DumbMessages[9] = {"in DUMB *** default", // RTEMS_EVENT_0
236 236 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
237 237 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
238 238 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
239 239 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
240 240 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
241 241 "ERR HK", // RTEMS_EVENT_6
242 "ready for dump" // RTEMS_EVENT_7
242 "ready for dump", // RTEMS_EVENT_7
243 "in DUMB *** spectral_matrices_isr" // RTEMS_EVENT_8
243 244 };
244 245
245 246 BOOT_PRINTF("in DUMB *** \n")
246 247
247 248 while(1){
248 249 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
249 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7,
250 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
251 | RTEMS_EVENT_8,
250 252 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
251 253 intEventOut = (unsigned int) event_out;
252 254 for ( i=0; i<32; i++)
@@ -256,7 +258,6 rtems_task dumb_task( rtems_task_argumen
256 258 coarse_time = time_management_regs->coarse_time;
257 259 fine_time = time_management_regs->fine_time;
258 260 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
259 PRINTF1("status = %x\n", waveform_picker_regs->status)
260 261 }
261 262 }
262 263 }
@@ -22,9 +22,10 ring_node *current_ring_node_sm_f1;
22 22 ring_node *current_ring_node_sm_f2;
23 23
24 24 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
25 float averaged_sm_f0[ TOTAL_SIZE_SM ];
26 char averaged_sm_f0_char[ TOTAL_SIZE_SM * 2 ];
27 float compressed_sm_f0[ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
25 float averaged_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
26 float averaged_sm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
27 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_SM * 2 ];
28 float compressed_sm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
28 29
29 30 unsigned int nb_sm_f0;
30 31
@@ -69,54 +70,76 void reset_nb_sm_f0( void )
69 70
70 71 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
71 72 {
72 // unsigned char status;
73 // unsigned char i;
73 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
74
75 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
76 {
77 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
78 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
79 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
80 nb_sm_f0 = nb_sm_f0 + 1;
81 }
82 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
83 {
84 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
85 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
86 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
87 nb_sm_f0 = nb_sm_f0 + 1;
88 }
74 89
75 // status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0]
76 // for (i=0; i<4; i++)
77 // {
78 // if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation
79 // {
80 // switch(i)
81 // {
82 // case 0:
83 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
84 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
85 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
86 // nb_interrupt_f0 = nb_interrupt_f0 + 1;
87 // if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
88 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
89 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
90 // {
91 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
92 // }
93 // nb_interrupt_f0 = 0;
94 // }
95 // break;
96 // case 1:
97 // break;
98 // case 2:
99 // break;
100 // default:
101 // break;
102 // }
103 // }
104 // }
90 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
91 {
92 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
93 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
94 }
95
96 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
105 97
106 // // reset error codes to 0
107 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111]
98 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
99 {
100 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
101 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
102 {
103 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
104 }
105 nb_sm_f0 = 0;
106 }
107 else
108 {
109 nb_sm_f0 = nb_sm_f0 + 1;
110 }
108 111 }
109 112
110 113 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
111 114 {
112 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
113 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
114 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
116
117 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
118 {
119 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
120 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
121 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
122 nb_sm_f0 = nb_sm_f0 + 1;
123 }
124 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
125 {
126 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
127 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
128 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
129 nb_sm_f0 = nb_sm_f0 + 1;
130 }
131
132 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
133 {
134 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
135 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
136 }
137
138 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
115 139
116 140 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
117 141 {
118 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
119 ring_node_for_averaging_sm_f0 = &sm_ring_f0[NB_SM_TO_RECEIVE_BEFORE_AVF0-1];
142 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
120 143 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
121 144 {
122 145 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
@@ -165,15 +188,16 rtems_task avf0_task(rtems_task_argument
165 188 }
166 189 for(i=0; i<TOTAL_SIZE_SM; i++)
167 190 {
168 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i]
169 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i]
170 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i]
171 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i]
172 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i]
173 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i]
174 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i]
175 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i];
191 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i + TIME_OFFSET]
192 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i + TIME_OFFSET]
193 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i + TIME_OFFSET]
194 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i + TIME_OFFSET]
195 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i + TIME_OFFSET]
196 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i + TIME_OFFSET]
197 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i + TIME_OFFSET]
198 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i + TIME_OFFSET];
176 199 }
200
177 201 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
178 202 if (nb_average == NB_AVERAGE_NORMAL_f0) {
179 203 nb_average = 0;
@@ -208,13 +232,14 rtems_task matr_task(rtems_task_argument
208 232 while(1){
209 233 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
210 234 // 1) compress the matrix for Basic Parameters calculation
211 compress_averaged_spectral_matrix( averaged_sm_f0, 0, compressed_sm_f0 );
235 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
212 236 // 2)
213 237 //BP1_set(compressed_sm_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
214 238 // 3) convert the float array in a char array
215 convert_averaged_spectral_matrix( averaged_sm_f0, averaged_sm_f0_char);
239 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
240 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
216 241 // 4) send the spectral matrix packets
217 send_averaged_spectral_matrix( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
242 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
218 243 }
219 244 }
220 245
@@ -229,33 +254,51 void matrix_reset(volatile float *averag
229 254 }
230 255 }
231 256
232 void compress_averaged_spectral_matrix( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
257 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized )
258 {
259 int frequencyBin;
260 int asmComponent;
261
262 // copy the time information
263 averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ];
264 averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ];
265
266 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
267 {
268 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
269 {
270 averaged_spec_mat_reorganized[ frequencyBin * NB_VALUES_PER_SM + asmComponent + TIME_OFFSET ] =
271 averaged_spec_mat[ asmComponent * NB_BINS_PER_SM + frequencyBin + TIME_OFFSET];
272 }
273 }
274 }
275
276 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
233 277 {
234 278 int frequencyBin;
235 279 int asmComponent;
236 280 int offsetASM;
237 int generalOffsetASM;
238 281 int offsetCompressed;
239 282 int k;
240 283
241 284 switch (fChannel){
242 285 case 0:
243 generalOffsetASM = ASM_F0_INDICE_START * NB_VALUES_PER_SM;
244 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
286 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
245 287 {
246 offsetCompressed = frequencyBin * NB_VALUES_PER_SM;
247 offsetASM = generalOffsetASM + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0 * NB_VALUES_PER_SM;
248 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
288 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
249 289 {
250 compressed_spec_mat[ offsetCompressed + asmComponent ] = 0;
290 offsetASM = asmComponent * NB_BINS_PER_SM
291 + ASM_F0_INDICE_START
292 + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0;
293 offsetCompressed = frequencyBin * NB_VALUES_PER_SM
294 + asmComponent;
295 compressed_spec_mat[ offsetCompressed ] = 0;
251 296 for ( k = 0; k < NB_BINS_TO_AVERAGE_ASM_F0; k++ )
252 297 {
253 compressed_spec_mat[ offsetCompressed + asmComponent ] =
254 compressed_spec_mat[ offsetCompressed + asmComponent ]
255 + averaged_spec_mat[ offsetASM + (k*NB_VALUES_PER_SM) + asmComponent ];
298 compressed_spec_mat[offsetCompressed ] =
299 compressed_spec_mat[ offsetCompressed ]
300 + averaged_spec_mat[ offsetASM + k ];
256 301 }
257 compressed_spec_mat[ offsetCompressed + asmComponent ] =
258 compressed_spec_mat[ offsetCompressed + asmComponent ] / NB_BINS_TO_AVERAGE_ASM_F0;
259 302 }
260 303 }
261 304 break;
@@ -273,29 +316,37 void compress_averaged_spectral_matrix(
273 316 }
274 317 }
275 318
276 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
319 void ASM_convert( volatile float *input_matrix, char *output_matrix)
277 320 {
278 321 unsigned int i;
279 unsigned int j;
322 unsigned int frequencyBin;
323 unsigned int asmComponent;
280 324 char * pt_char_input;
281 325 char * pt_char_output;
282 326
283 pt_char_input = NULL;
284 pt_char_output = NULL;
327 pt_char_input = (char*) &input_matrix;
328 pt_char_output = (char*) &output_matrix;
285 329
286 for( i=0; i<NB_BINS_PER_SM; i++)
330 // copy the time information
331 for (i=0; i<TIME_OFFSET_IN_BYTES; i++)
287 332 {
288 for ( j=0; j<NB_VALUES_PER_SM; j++)
333 pt_char_output[ i ] = pt_char_output[ i ];
334 }
335
336 // convert all other data
337 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
338 {
339 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
289 340 {
290 pt_char_input = (char*) &input_matrix [ (i*NB_VALUES_PER_SM) + j ];
291 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
341 pt_char_input = (char*) &input_matrix [ (frequencyBin*NB_VALUES_PER_SM) + asmComponent + TIME_OFFSET ];
342 pt_char_output = (char*) &output_matrix[ 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) + TIME_OFFSET_IN_BYTES ];
292 343 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
293 344 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
294 345 }
295 346 }
296 347 }
297 348
298 void send_averaged_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
349 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
299 350 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
300 351 {
301 352 unsigned int i;
@@ -309,7 +360,10 void send_averaged_spectral_matrix(Heade
309 360 {
310 361 case SID_NORM_ASM_F0:
311 362 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
312 spw_ioctl_send->data = &spectral_matrix[ ( (ASM_F0_INDICE_START+ (i*NB_BINS_PER_PKT_ASM_F0)) * NB_VALUES_PER_SM) * 2 ];
363 spw_ioctl_send->data = &spectral_matrix[
364 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
365 + TIME_OFFSET_IN_BYTES
366 ];
313 367 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
314 368 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
315 369 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
@@ -319,7 +373,7 void send_averaged_spectral_matrix(Heade
319 373 case SID_NORM_ASM_F2:
320 374 break;
321 375 default:
322 PRINTF1("ERR *** in send_averaged_spectral_matrix *** unexpected sid %d\n", sid)
376 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
323 377 break;
324 378 }
325 379 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
@@ -351,7 +405,7 void send_averaged_spectral_matrix(Heade
351 405 // (4) SEND PACKET
352 406 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
353 407 if (status != RTEMS_SUCCESSFUL) {
354 printf("in send_averaged_spectral_matrix *** ERR %d\n", (int) status);
408 printf("in ASM_send *** ERR %d\n", (int) status);
355 409 }
356 410 }
357 411 }
@@ -665,6 +719,9 void reset_spectral_matrix_regs()
665 719 *
666 720 */
667 721
722 spectral_matrix_regs->config = 0x00;
723 spectral_matrix_regs->status = 0x00;
724
668 725 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
669 726 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
670 727 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
@@ -388,15 +388,16 int stop_current_mode(void)
388 388
389 389 // (1) mask interruptions
390 390 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
391 //LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
391 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
392 392
393 393 // (2) clear interruptions
394 394 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
395 //LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
395 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
396 396
397 397 // (3) reset registers
398 398 reset_wfp_burst_enable(); // reset burst and enable bits
399 399 reset_wfp_status(); // reset all the status bits
400 disable_irq_on_new_ready_matrix(); // stop the spectral matrices
400 401
401 402 // <Spectral Matrices simulator>
402 403 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
@@ -445,7 +446,7 int enter_mode(unsigned char mode )
445 446 #endif
446 447 status = restart_science_tasks();
447 448 launch_waveform_picker( mode );
448 //launch_spectral_matrix( mode );
449 launch_spectral_matrix( mode );
449 450 }
450 451 else if ( mode == LFR_MODE_STANDBY )
451 452 {
@@ -609,6 +610,29 void launch_spectral_matrix( unsigned ch
609 610 reset_current_sm_ring_nodes();
610 611 reset_spectral_matrix_regs();
611 612
613 enable_irq_on_new_ready_matrix();
614
615 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
616 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
617 }
618
619 void enable_irq_on_new_ready_matrix( void )
620 {
621 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
622 }
623
624 void disable_irq_on_new_ready_matrix( void )
625 {
626 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
627 }
628
629
630 void launch_spectral_matrix_simu( unsigned char mode )
631 {
632 reset_nb_sm_f0();
633 reset_current_sm_ring_nodes();
634 reset_spectral_matrix_regs();
635
612 636 // Spectral Matrices simulator
613 637 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
614 638 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
General Comments 0
You need to be logged in to leave comments. Login now