##// END OF EJS Templates
updates for the compliance with the spectral matrix VHDL design
paul -
r150:035669d03c81 VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 09:16:01 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 15:44:22 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T07:35:26. -->
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T15:53:55. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -90,20 +90,20 typedef struct {
90 volatile int f2_0_address; // 0x18
90 volatile int f2_0_address; // 0x18
91 volatile int f2_1_address; // 0x1C
91 volatile int f2_1_address; // 0x1C
92 //
92 //
93 volatile int f0_0_coarse_time; // 0x20
93 volatile unsigned int f0_0_coarse_time; // 0x20
94 volatile int f0_0_fine_time; // 0x24
94 volatile unsigned int f0_0_fine_time; // 0x24
95 volatile int f0_1_coarse_time; // 0x28
95 volatile unsigned int f0_1_coarse_time; // 0x28
96 volatile int f0_1_fine_time; // 0x2C
96 volatile unsigned int f0_1_fine_time; // 0x2C
97 //
97 //
98 volatile int f1_0_coarse_time; // 0x30
98 volatile unsigned int f1_0_coarse_time; // 0x30
99 volatile int f1_0_fine_time; // 0x34
99 volatile unsigned int f1_0_fine_time; // 0x34
100 volatile int f1_1_coarse_time; // 0x38
100 volatile unsigned int f1_1_coarse_time; // 0x38
101 volatile int f1_1_time_time; // 0x3C
101 volatile unsigned int f1_1_time_time; // 0x3C
102 //
102 //
103 volatile int f2_0_coarse_time; // 0x40
103 volatile unsigned int f2_0_coarse_time; // 0x40
104 volatile int f2_0_fine_time; // 0x44
104 volatile unsigned int f2_0_fine_time; // 0x44
105 volatile int f2_1_coarse_time; // 0x48
105 volatile unsigned int f2_1_coarse_time; // 0x48
106 volatile int f2_1_time_time; // 0x4C
106 volatile unsigned int f2_1_fine_time; // 0x4C
107 } spectral_matrix_regs_t;
107 } spectral_matrix_regs_t;
108
108
109 #endif // GRLIB_REGS_H_INCLUDED
109 #endif // GRLIB_REGS_H_INCLUDED
@@ -30,7 +30,7 void reset_nb_sm_f0( unsigned char lfrMo
30
30
31 //*******
31 //*******
32 // EXTERN
32 // EXTERN
33 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
33 extern ring_node_sm *ring_node_for_averaging_sm_f0;
34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35
35
36 #endif // AVF0_PRC0_H_INCLUDED
36 #endif // AVF0_PRC0_H_INCLUDED
@@ -100,7 +100,7 void reset_spectral_matrix_regs( void );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode);
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
104 unsigned char getSID( rtems_event_set event );
104 unsigned char getSID( rtems_event_set event );
105
105
106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
@@ -108,9 +108,9 extern rtems_status_code get_message_que
108
108
109 //***************************************
109 //***************************************
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
111 static inline void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
111 static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
112 ring_node_sm *ring_node_tab[],
112 ring_node_sm *ring_node_tab[],
113 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
113 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
115 float divider );
115 float divider );
116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
@@ -118,9 +118,9 static inline void ASM_compress_reorgani
118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
120
120
121 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
121 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
122 ring_node_sm *ring_node_tab[],
122 ring_node_sm *ring_node_tab[],
123 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
123 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
124 {
124 {
125 float sum;
125 float sum;
126 unsigned int i;
126 unsigned int i;
@@ -136,24 +136,24 void SM_average( float *averaged_spec_ma
136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
138
138
139 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
139 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
140 {
140 {
141 averaged_spec_mat_f0[ i ] = sum;
141 averaged_spec_mat_NORM[ i ] = sum;
142 averaged_spec_mat_f1[ i ] = sum;
142 averaged_spec_mat_SBM[ i ] = sum;
143 }
143 }
144 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
144 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
145 {
145 {
146 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
146 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
147 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
147 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
148 }
148 }
149 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
149 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
150 {
150 {
151 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
151 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
152 averaged_spec_mat_f1[ i ] = sum;
152 averaged_spec_mat_SBM[ i ] = sum;
153 }
153 }
154 else
154 else
155 {
155 {
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
157 }
157 }
158 }
158 }
159 }
159 }
@@ -259,7 +259,7 rtems_task dumb_task( rtems_task_argumen
259 unsigned int fine_time = 0;
259 unsigned int fine_time = 0;
260 rtems_event_set event_out;
260 rtems_event_set event_out;
261
261
262 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
262 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
@@ -267,8 +267,10 rtems_task dumb_task( rtems_task_argumen
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
268 "ERR HK", // RTEMS_EVENT_6
268 "ERR HK", // RTEMS_EVENT_6
269 "ready for dump", // RTEMS_EVENT_7
269 "ready for dump", // RTEMS_EVENT_7
270 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
270 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
271 "tick" // RTEMS_EVENT_9
271 "tick", // RTEMS_EVENT_9
272 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
273 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
272 };
274 };
273
275
274 BOOT_PRINTF("in DUMB *** \n")
276 BOOT_PRINTF("in DUMB *** \n")
@@ -288,7 +290,11 rtems_task dumb_task( rtems_task_argumen
288 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
290 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
289 if (i==8)
291 if (i==8)
290 {
292 {
291 PRINTF1("status = %x\n", spectral_matrix_regs->status)
293 PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status)
294 }
295 if (i==10)
296 {
297 PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status)
292 }
298 }
293 }
299 }
294 }
300 }
@@ -67,6 +67,17 rtems_task avf0_task( rtems_task_argumen
67
67
68 while(1){
68 while(1){
69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70
71 //****************************************
72 // initialize the mesage for the MATR task
73 msgForMATR.norm = current_ring_node_asm_norm_f0;
74 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
75 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
76 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
77 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
78 //
79 //****************************************
80
70 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
81 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
82 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 {
83 {
@@ -87,16 +98,6 rtems_task avf0_task( rtems_task_argumen
87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
98 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
99 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89
100
90 //****************************************
91 // initialize the mesage for the MATR task
92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 msgForMATR.fineTime = time_management_regs->fine_time;
99
100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 {
102 {
102 nb_sbm_bp1 = 0;
103 nb_sbm_bp1 = 0;
@@ -349,7 +350,7 void reset_nb_sm_f0( unsigned char lfrMo
349 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
350 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
350 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
351 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
351 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
352 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
352 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
353 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
353 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
354 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
354 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
355 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
355 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
356 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
@@ -64,6 +64,17 rtems_task avf1_task( rtems_task_argumen
64
64
65 while(1){
65 while(1){
66 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
66 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
67
68 //****************************************
69 // initialize the mesage for the MATR task
70 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
71 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
72 msgForMATR.norm = current_ring_node_asm_norm_f1;
73 msgForMATR.coarseTime = ring_node_for_averaging_sm_f1->coarseTime;
74 msgForMATR.fineTime = ring_node_for_averaging_sm_f1->fineTime;
75 //
76 //****************************************
77
67 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
78 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
68 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
79 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
69 {
80 {
@@ -84,16 +95,6 rtems_task avf1_task( rtems_task_argumen
84 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
95 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
85 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
96 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
86
97
87 //****************************************
88 // initialize the mesage for the MATR task
89 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
90 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
91 msgForMATR.norm = current_ring_node_asm_norm_f1;
92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
94 msgForMATR.coarseTime = time_management_regs->coarse_time;
95 msgForMATR.fineTime = time_management_regs->fine_time;
96
97 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 {
99 {
99 nb_sbm_bp1 = 0;
100 nb_sbm_bp1 = 0;
@@ -57,6 +57,16 rtems_task avf2_task( rtems_task_argumen
57 while(1){
57 while(1){
58 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
58 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
59
59
60 //****************************************
61 // initialize the mesage for the MATR task
62 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
63 msgForMATR.burst_sbm = NULL;
64 msgForMATR.norm = current_ring_node_asm_norm_f2;
65 msgForMATR.coarseTime = ring_node_for_averaging_sm_f2->coarseTime;
66 msgForMATR.fineTime = ring_node_for_averaging_sm_f2->fineTime;
67 //
68 //****************************************
69
60 // compute the average and store it in the averaged_sm_f2 buffer
70 // compute the average and store it in the averaged_sm_f2 buffer
61 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
71 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
62 ring_node_for_averaging_sm_f2,
72 ring_node_for_averaging_sm_f2,
@@ -67,16 +77,6 rtems_task avf2_task( rtems_task_argumen
67 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
77 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
68 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
78 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
69
79
70 //****************************************
71 // initialize the mesage for the MATR task
72 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
73 msgForMATR.burst_sbm = NULL;
74 msgForMATR.norm = current_ring_node_asm_norm_f2;
75 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
76 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
77 msgForMATR.coarseTime = time_management_regs->coarse_time;
78 msgForMATR.fineTime = time_management_regs->fine_time;
79
80 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
80 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
81 {
81 {
82 nb_norm_bp1 = 0;
82 nb_norm_bp1 = 0;
@@ -35,44 +35,55 void spectral_matrices_isr_f0( void )
35 unsigned char status;
35 unsigned char status;
36 unsigned long long int time_0;
36 unsigned long long int time_0;
37 unsigned long long int time_1;
37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
38
40
39 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
40
42
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47
41 switch(status)
48 switch(status)
42 {
49 {
43 case 0:
50 case 0:
44 break;
51 break;
45 case 3:
52 case 3:
46 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_0_coarse_time );
47 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_1_coarse_time );
48 if ( time_0 < time_1 )
53 if ( time_0 < time_1 )
49 {
54 {
50 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
51 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
52 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
58 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
53 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
54 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
55 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
56 }
63 }
57 else
64 else
58 {
65 {
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
60 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
63 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
64 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
65 }
74 }
66 spectral_matrix_regs->status = 0x03; // [0011]
75 spectral_matrix_regs->status = 0x03; // [0011]
67 break;
76 break;
68 case 1:
77 case 1:
69 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
70 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
71 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
72 spectral_matrix_regs->status = 0x01; // [0001]
82 spectral_matrix_regs->status = 0x01; // [0001]
73 break;
83 break;
74 case 2:
84 case 2:
75 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
76 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
77 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
78 spectral_matrix_regs->status = 0x02; // [0010]
89 spectral_matrix_regs->status = 0x02; // [0010]
@@ -83,8 +94,8 void spectral_matrices_isr_f0( void )
83 void spectral_matrices_isr_f1( void )
94 void spectral_matrices_isr_f1( void )
84 {
95 {
85 unsigned char status;
96 unsigned char status;
86 unsigned long long int time_0;
97 unsigned long long int time;
87 unsigned long long int time_1;
98 unsigned long long int syncBit;
88
99
89 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
100 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
90
101
@@ -93,36 +104,24 void spectral_matrices_isr_f1( void )
93 case 0:
104 case 0:
94 break;
105 break;
95 case 3:
106 case 3:
96 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time );
107 // UNEXPECTED VALUE
97 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time );
108 spectral_matrix_regs->status = 0xc0; // [1100]
98 if ( time_0 < time_1 )
109 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
99 {
100 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
101 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
102 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
103 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
104 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
105 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
106 }
107 else
108 {
109 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
110 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
111 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
112 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
113 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
114 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
115 }
116 spectral_matrix_regs->status = 0x0c; // [1100]
117 break;
110 break;
118 case 1:
111 case 1:
119 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
112 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
113 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
114 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
115 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
120 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
116 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
121 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
117 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
122 spectral_matrix_regs->status = 0x04; // [0100]
118 spectral_matrix_regs->status = 0x04; // [0100]
123 break;
119 break;
124 case 2:
120 case 2:
125 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
121 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
122 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
123 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
124 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
126 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
125 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
127 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
126 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 spectral_matrix_regs->status = 0x08; // [1000]
127 spectral_matrix_regs->status = 0x08; // [1000]
@@ -136,7 +135,7 void spectral_matrices_isr_f2( void )
136
135
137 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
136 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138
137
139 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
138 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
140
139
141 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
140 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
142
141
@@ -145,14 +144,13 void spectral_matrices_isr_f2( void )
145 case 0:
144 case 0:
146 break;
145 break;
147 case 3:
146 case 3:
148 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
147 // UNEXPECTED VALUE
149 spectral_matrix_regs->status = 0x30; // [0011 0000]
148 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
151 {
152 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
154 break;
150 break;
155 case 1:
151 case 1:
152 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
153 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
154 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
155 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
156 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -161,6 +159,8 void spectral_matrices_isr_f2( void )
161 }
159 }
162 break;
160 break;
163 case 2:
161 case 2:
162 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
163 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -173,7 +173,10 void spectral_matrices_isr_f2( void )
173
173
174 void spectral_matrix_isr_error_handler( void )
174 void spectral_matrix_isr_error_handler( void )
175 {
175 {
176 spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000]
176 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
177 {
178 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
179 }
177 }
180 }
178
181
179 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
182 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
@@ -596,13 +599,6 void reset_spectral_matrix_regs( void )
596
599
597 void set_time( unsigned char *time, unsigned char * timeInBuffer )
600 void set_time( unsigned char *time, unsigned char * timeInBuffer )
598 {
601 {
599 // time[0] = timeInBuffer[2];
600 // time[1] = timeInBuffer[3];
601 // time[2] = timeInBuffer[0];
602 // time[3] = timeInBuffer[1];
603 // time[4] = timeInBuffer[6];
604 // time[5] = timeInBuffer[7];
605
606 time[0] = timeInBuffer[0];
602 time[0] = timeInBuffer[0];
607 time[1] = timeInBuffer[1];
603 time[1] = timeInBuffer[1];
608 time[2] = timeInBuffer[2];
604 time[2] = timeInBuffer[2];
@@ -619,18 +615,33 unsigned long long int get_acquisition_t
619 + ( (unsigned long long int) timePtr[1] << 32 )
615 + ( (unsigned long long int) timePtr[1] << 32 )
620 + ( timePtr[2] << 24 )
616 + ( timePtr[2] << 24 )
621 + ( timePtr[3] << 16 )
617 + ( timePtr[3] << 16 )
622 + ( timePtr[4] << 8 )
618 + ( timePtr[6] << 8 )
623 + ( timePtr[5] );
619 + ( timePtr[7] );
624 return acquisitionTimeAslong;
620 return acquisitionTimeAslong;
625 }
621 }
626
622
627 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
623 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
628 ring_node_sm *node_for_averaging, ring_node_sm *ringNode )
624 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
625 unsigned long long int time )
629 {
626 {
627 unsigned char *timePtr;
628 unsigned char *coarseTimePtr;
629 unsigned char *fineTimePtr;
630
631 timePtr = (unsigned char *) &time;
632 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
633 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
634
630 *nb_sm = *nb_sm + 1;
635 *nb_sm = *nb_sm + 1;
631 if (*nb_sm == nb_sm_before_avf)
636 if (*nb_sm == nb_sm_before_avf)
632 {
637 {
633 node_for_averaging = ringNode;
638 node_for_averaging = ringNode;
639 coarseTimePtr[0] = timePtr[2];
640 coarseTimePtr[1] = timePtr[3];
641 coarseTimePtr[2] = timePtr[4];
642 coarseTimePtr[3] = timePtr[5];
643 fineTimePtr[2] = timePtr[6];
644 fineTimePtr[3] = timePtr[7];
634 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
645 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
635 {
646 {
636 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
647 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
@@ -532,8 +532,8 int enter_mode( unsigned char mode, unsi
532 #endif
532 #endif
533 status = restart_science_tasks( mode );
533 status = restart_science_tasks( mode );
534 launch_waveform_picker( mode, transitionCoarseTime );
534 launch_waveform_picker( mode, transitionCoarseTime );
535 // launch_spectral_matrix( );
535 launch_spectral_matrix( );
536 launch_spectral_matrix_simu( );
536 // launch_spectral_matrix_simu( );
537 }
537 }
538 else if ( mode == LFR_MODE_STANDBY )
538 else if ( mode == LFR_MODE_STANDBY )
539 {
539 {
General Comments 0
You need to be logged in to leave comments. Login now