##// END OF EJS Templates
3.0.0.12...
paul -
r236:5379af5b0bd4 R3
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 82603593a3f6185e68418200fe1fee7d81fe6e3d header/lfr_common_headers
2 07e22c5c44daa84954a10db557a74b8c8dd2d014 header/lfr_common_headers
@@ -1,112 +1,112
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 # lpp_dpu_destid
4 # lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
6 CONFIG -= qt
6 CONFIG -= qt
7
7
8 include(./sparc.pri)
8 include(./sparc.pri)
9
9
10 # flight software version
10 # flight software version
11 SWVERSION=-1-0
11 SWVERSION=-1-0
12 DEFINES += SW_VERSION_N1=3 # major
12 DEFINES += SW_VERSION_N1=3 # major
13 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N2=0 # minor
14 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N3=0 # patch
15 DEFINES += SW_VERSION_N4=11 # internal
15 DEFINES += SW_VERSION_N4=12 # internal
16
16
17 # <GCOV>
17 # <GCOV>
18 QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
20 # </GCOV>
20 # </GCOV>
21
21
22 # <CHANGE BEFORE FLIGHT>
22 # <CHANGE BEFORE FLIGHT>
23 contains( CONFIG, lpp_dpu_destid ) {
23 contains( CONFIG, lpp_dpu_destid ) {
24 DEFINES += LPP_DPU_DESTID
24 DEFINES += LPP_DPU_DESTID
25 }
25 }
26 # </CHANGE BEFORE FLIGHT>
26 # </CHANGE BEFORE FLIGHT>
27
27
28 contains( CONFIG, debug_tch ) {
28 contains( CONFIG, debug_tch ) {
29 DEFINES += DEBUG_TCH
29 DEFINES += DEBUG_TCH
30 }
30 }
31 DEFINES += MSB_FIRST_TCH
31 DEFINES += MSB_FIRST_TCH
32
32
33 contains( CONFIG, vhdl_dev ) {
33 contains( CONFIG, vhdl_dev ) {
34 DEFINES += VHDL_DEV
34 DEFINES += VHDL_DEV
35 }
35 }
36
36
37 contains( CONFIG, verbose ) {
37 contains( CONFIG, verbose ) {
38 DEFINES += PRINT_MESSAGES_ON_CONSOLE
38 DEFINES += PRINT_MESSAGES_ON_CONSOLE
39 }
39 }
40
40
41 contains( CONFIG, debug_messages ) {
41 contains( CONFIG, debug_messages ) {
42 DEFINES += DEBUG_MESSAGES
42 DEFINES += DEBUG_MESSAGES
43 }
43 }
44
44
45 contains( CONFIG, cpu_usage_report ) {
45 contains( CONFIG, cpu_usage_report ) {
46 DEFINES += PRINT_TASK_STATISTICS
46 DEFINES += PRINT_TASK_STATISTICS
47 }
47 }
48
48
49 contains( CONFIG, stack_report ) {
49 contains( CONFIG, stack_report ) {
50 DEFINES += PRINT_STACK_REPORT
50 DEFINES += PRINT_STACK_REPORT
51 }
51 }
52
52
53 contains( CONFIG, boot_messages ) {
53 contains( CONFIG, boot_messages ) {
54 DEFINES += BOOT_MESSAGES
54 DEFINES += BOOT_MESSAGES
55 }
55 }
56
56
57 #doxygen.target = doxygen
57 #doxygen.target = doxygen
58 #doxygen.commands = doxygen ../doc/Doxyfile
58 #doxygen.commands = doxygen ../doc/Doxyfile
59 #QMAKE_EXTRA_TARGETS += doxygen
59 #QMAKE_EXTRA_TARGETS += doxygen
60
60
61 TARGET = fsw
61 TARGET = fsw
62
62
63 INCLUDEPATH += \
63 INCLUDEPATH += \
64 $${PWD}/../src \
64 $${PWD}/../src \
65 $${PWD}/../header \
65 $${PWD}/../header \
66 $${PWD}/../header/lfr_common_headers \
66 $${PWD}/../header/lfr_common_headers \
67 $${PWD}/../header/processing \
67 $${PWD}/../header/processing \
68 $${PWD}/../LFR_basic-parameters
68 $${PWD}/../LFR_basic-parameters
69
69
70 SOURCES += \
70 SOURCES += \
71 ../src/wf_handler.c \
71 ../src/wf_handler.c \
72 ../src/tc_handler.c \
72 ../src/tc_handler.c \
73 ../src/fsw_misc.c \
73 ../src/fsw_misc.c \
74 ../src/fsw_init.c \
74 ../src/fsw_init.c \
75 ../src/fsw_globals.c \
75 ../src/fsw_globals.c \
76 ../src/fsw_spacewire.c \
76 ../src/fsw_spacewire.c \
77 ../src/tc_load_dump_parameters.c \
77 ../src/tc_load_dump_parameters.c \
78 ../src/tm_lfr_tc_exe.c \
78 ../src/tm_lfr_tc_exe.c \
79 ../src/tc_acceptance.c \
79 ../src/tc_acceptance.c \
80 ../src/processing/fsw_processing.c \
80 ../src/processing/fsw_processing.c \
81 ../src/processing/avf0_prc0.c \
81 ../src/processing/avf0_prc0.c \
82 ../src/processing/avf1_prc1.c \
82 ../src/processing/avf1_prc1.c \
83 ../src/processing/avf2_prc2.c \
83 ../src/processing/avf2_prc2.c \
84 ../src/lfr_cpu_usage_report.c \
84 ../src/lfr_cpu_usage_report.c \
85 ../LFR_basic-parameters/basic_parameters.c
85 ../LFR_basic-parameters/basic_parameters.c
86
86
87 HEADERS += \
87 HEADERS += \
88 ../header/wf_handler.h \
88 ../header/wf_handler.h \
89 ../header/tc_handler.h \
89 ../header/tc_handler.h \
90 ../header/grlib_regs.h \
90 ../header/grlib_regs.h \
91 ../header/fsw_misc.h \
91 ../header/fsw_misc.h \
92 ../header/fsw_init.h \
92 ../header/fsw_init.h \
93 ../header/fsw_spacewire.h \
93 ../header/fsw_spacewire.h \
94 ../header/tc_load_dump_parameters.h \
94 ../header/tc_load_dump_parameters.h \
95 ../header/tm_lfr_tc_exe.h \
95 ../header/tm_lfr_tc_exe.h \
96 ../header/tc_acceptance.h \
96 ../header/tc_acceptance.h \
97 ../header/processing/fsw_processing.h \
97 ../header/processing/fsw_processing.h \
98 ../header/processing/avf0_prc0.h \
98 ../header/processing/avf0_prc0.h \
99 ../header/processing/avf1_prc1.h \
99 ../header/processing/avf1_prc1.h \
100 ../header/processing/avf2_prc2.h \
100 ../header/processing/avf2_prc2.h \
101 ../header/fsw_params_wf_handler.h \
101 ../header/fsw_params_wf_handler.h \
102 ../header/lfr_cpu_usage_report.h \
102 ../header/lfr_cpu_usage_report.h \
103 ../header/lfr_common_headers/ccsds_types.h \
103 ../header/lfr_common_headers/ccsds_types.h \
104 ../header/lfr_common_headers/fsw_params.h \
104 ../header/lfr_common_headers/fsw_params.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
107 ../header/lfr_common_headers/TC_types.h \
107 ../header/lfr_common_headers/TC_types.h \
108 ../header/lfr_common_headers/tm_byte_positions.h \
108 ../header/lfr_common_headers/tm_byte_positions.h \
109 ../LFR_basic-parameters/basic_parameters.h \
109 ../LFR_basic-parameters/basic_parameters.h \
110 ../LFR_basic-parameters/basic_parameters_params.h \
110 ../LFR_basic-parameters/basic_parameters_params.h \
111 ../header/GscMemoryLPP.hpp
111 ../header/GscMemoryLPP.hpp
112
112
@@ -1,329 +1,329
1 #ifndef FSW_PROCESSING_H_INCLUDED
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <math.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h>
8 #include <stdio.h>
9 #include <math.h>
9 #include <math.h>
10 #include <grlib_regs.h>
10 #include <grlib_regs.h>
11
11
12 #include "fsw_params.h"
12 #include "fsw_params.h"
13
13
14 typedef struct ring_node_asm
14 typedef struct ring_node_asm
15 {
15 {
16 struct ring_node_asm *next;
16 struct ring_node_asm *next;
17 float matrix[ TOTAL_SIZE_SM ];
17 float matrix[ TOTAL_SIZE_SM ];
18 unsigned int status;
18 unsigned int status;
19 } ring_node_asm;
19 } ring_node_asm;
20
20
21 typedef struct
21 typedef struct
22 {
22 {
23 unsigned char targetLogicalAddress;
23 unsigned char targetLogicalAddress;
24 unsigned char protocolIdentifier;
24 unsigned char protocolIdentifier;
25 unsigned char reserved;
25 unsigned char reserved;
26 unsigned char userApplication;
26 unsigned char userApplication;
27 unsigned char packetID[2];
27 unsigned char packetID[2];
28 unsigned char packetSequenceControl[2];
28 unsigned char packetSequenceControl[2];
29 unsigned char packetLength[2];
29 unsigned char packetLength[2];
30 // DATA FIELD HEADER
30 // DATA FIELD HEADER
31 unsigned char spare1_pusVersion_spare2;
31 unsigned char spare1_pusVersion_spare2;
32 unsigned char serviceType;
32 unsigned char serviceType;
33 unsigned char serviceSubType;
33 unsigned char serviceSubType;
34 unsigned char destinationID;
34 unsigned char destinationID;
35 unsigned char time[6];
35 unsigned char time[6];
36 // AUXILIARY HEADER
36 // AUXILIARY HEADER
37 unsigned char sid;
37 unsigned char sid;
38 unsigned char biaStatusInfo;
38 unsigned char biaStatusInfo;
39 unsigned char sy_lfr_common_parameters_spare;
39 unsigned char sy_lfr_common_parameters_spare;
40 unsigned char sy_lfr_common_parameters;
40 unsigned char sy_lfr_common_parameters;
41 unsigned char acquisitionTime[6];
41 unsigned char acquisitionTime[6];
42 unsigned char pa_lfr_bp_blk_nr[2];
42 unsigned char pa_lfr_bp_blk_nr[2];
43 // SOURCE DATA
43 // SOURCE DATA
44 unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
44 unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
45 } bp_packet;
45 } bp_packet;
46
46
47 typedef struct
47 typedef struct
48 {
48 {
49 unsigned char targetLogicalAddress;
49 unsigned char targetLogicalAddress;
50 unsigned char protocolIdentifier;
50 unsigned char protocolIdentifier;
51 unsigned char reserved;
51 unsigned char reserved;
52 unsigned char userApplication;
52 unsigned char userApplication;
53 unsigned char packetID[2];
53 unsigned char packetID[2];
54 unsigned char packetSequenceControl[2];
54 unsigned char packetSequenceControl[2];
55 unsigned char packetLength[2];
55 unsigned char packetLength[2];
56 // DATA FIELD HEADER
56 // DATA FIELD HEADER
57 unsigned char spare1_pusVersion_spare2;
57 unsigned char spare1_pusVersion_spare2;
58 unsigned char serviceType;
58 unsigned char serviceType;
59 unsigned char serviceSubType;
59 unsigned char serviceSubType;
60 unsigned char destinationID;
60 unsigned char destinationID;
61 unsigned char time[6];
61 unsigned char time[6];
62 // AUXILIARY HEADER
62 // AUXILIARY HEADER
63 unsigned char sid;
63 unsigned char sid;
64 unsigned char biaStatusInfo;
64 unsigned char biaStatusInfo;
65 unsigned char sy_lfr_common_parameters_spare;
65 unsigned char sy_lfr_common_parameters_spare;
66 unsigned char sy_lfr_common_parameters;
66 unsigned char sy_lfr_common_parameters;
67 unsigned char acquisitionTime[6];
67 unsigned char acquisitionTime[6];
68 unsigned char source_data_spare;
68 unsigned char source_data_spare;
69 unsigned char pa_lfr_bp_blk_nr[2];
69 unsigned char pa_lfr_bp_blk_nr[2];
70 // SOURCE DATA
70 // SOURCE DATA
71 unsigned char data[ 143 ]; // 13 bins * 11 Bytes
71 unsigned char data[ 143 ]; // 13 bins * 11 Bytes
72 } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
72 } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
73
73
74 typedef struct asm_msg
74 typedef struct asm_msg
75 {
75 {
76 ring_node_asm *norm;
76 ring_node_asm *norm;
77 ring_node_asm *burst_sbm;
77 ring_node_asm *burst_sbm;
78 rtems_event_set event;
78 rtems_event_set event;
79 unsigned int coarseTimeNORM;
79 unsigned int coarseTimeNORM;
80 unsigned int fineTimeNORM;
80 unsigned int fineTimeNORM;
81 unsigned int coarseTimeSBM;
81 unsigned int coarseTimeSBM;
82 unsigned int fineTimeSBM;
82 unsigned int fineTimeSBM;
83 } asm_msg;
83 } asm_msg;
84
84
85 extern volatile int sm_f0[ ];
85 extern volatile int sm_f0[ ];
86 extern volatile int sm_f1[ ];
86 extern volatile int sm_f1[ ];
87 extern volatile int sm_f2[ ];
87 extern volatile int sm_f2[ ];
88
88
89 // parameters
89 // parameters
90 extern struct param_local_str param_local;
90 extern struct param_local_str param_local;
91 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
91 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
92
92
93 // registers
93 // registers
94 extern time_management_regs_t *time_management_regs;
94 extern time_management_regs_t *time_management_regs;
95 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
95 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
96
96
97 extern rtems_name misc_name[5];
97 extern rtems_name misc_name[5];
98 extern rtems_id Task_id[20]; /* array of task ids */
98 extern rtems_id Task_id[20]; /* array of task ids */
99
99
100 //
100 //
101 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
101 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
102 // ISR
102 // ISR
103 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
103 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
104 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
104 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
105
105
106 //******************
106 //******************
107 // Spectral Matrices
107 // Spectral Matrices
108 void reset_nb_sm( void );
108 void reset_nb_sm( void );
109 // SM
109 // SM
110 void SM_init_rings( void );
110 void SM_init_rings( void );
111 void SM_reset_current_ring_nodes( void );
111 void SM_reset_current_ring_nodes( void );
112 // ASM
112 // ASM
113 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
113 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
114
114
115 //*****************
115 //*****************
116 // Basic Parameters
116 // Basic Parameters
117
117
118 void BP_reset_current_ring_nodes( void );
118 void BP_reset_current_ring_nodes( void );
119 void BP_init_header(bp_packet *packet,
119 void BP_init_header(bp_packet *packet,
120 unsigned int apid, unsigned char sid,
120 unsigned int apid, unsigned char sid,
121 unsigned int packetLength , unsigned char blkNr);
121 unsigned int packetLength , unsigned char blkNr);
122 void BP_init_header_with_spare(bp_packet_with_spare *packet,
122 void BP_init_header_with_spare(bp_packet_with_spare *packet,
123 unsigned int apid, unsigned char sid,
123 unsigned int apid, unsigned char sid,
124 unsigned int packetLength, unsigned char blkNr );
124 unsigned int packetLength, unsigned char blkNr );
125 void BP_send( char *data,
125 void BP_send( char *data,
126 rtems_id queue_id ,
126 rtems_id queue_id ,
127 unsigned int nbBytesToSend , unsigned int sid );
127 unsigned int nbBytesToSend , unsigned int sid );
128
128
129 //******************
129 //******************
130 // general functions
130 // general functions
131 void reset_sm_status( void );
131 void reset_sm_status( void );
132 void reset_spectral_matrix_regs( void );
132 void reset_spectral_matrix_regs( void );
133 void set_time(unsigned char *time, unsigned char *timeInBuffer );
133 void set_time(unsigned char *time, unsigned char *timeInBuffer );
134 unsigned long long int get_acquisition_time( unsigned char *timePtr );
134 unsigned long long int get_acquisition_time( unsigned char *timePtr );
135 unsigned char getSID( rtems_event_set event );
135 unsigned char getSID( rtems_event_set event );
136
136
137 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
137 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
138 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
138 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
139
139
140 //***************************************
140 //***************************************
141 // DEFINITIONS OF STATIC INLINE FUNCTIONS
141 // DEFINITIONS OF STATIC INLINE FUNCTIONS
142 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
142 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
143 ring_node *ring_node_tab[],
143 ring_node *ring_node_tab[],
144 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
144 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
145 asm_msg *msgForMATR );
145 asm_msg *msgForMATR );
146
146
147 static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
147 static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
148 ring_node *ring_node_tab[],
148 ring_node *ring_node_tab[],
149 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
149 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
150 asm_msg *msgForMATR );
150 asm_msg *msgForMATR );
151
151
152 void ASM_patch( float *inputASM, float *outputASM );
152 void ASM_patch( float *inputASM, float *outputASM );
153
153
154 void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent );
154 void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent );
155
155
156 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
156 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
157 float divider );
157 float divider );
158
158
159 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
159 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
160 float divider,
160 float divider,
161 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
161 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
162
162
163 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
163 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
164
164
165 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
165 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
166 ring_node *ring_node_tab[],
166 ring_node *ring_node_tab[],
167 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
167 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
168 asm_msg *msgForMATR )
168 asm_msg *msgForMATR )
169 {
169 {
170 float sum;
170 float sum;
171 unsigned int i;
171 unsigned int i;
172
172
173 for(i=0; i<TOTAL_SIZE_SM; i++)
173 for(i=0; i<TOTAL_SIZE_SM; i++)
174 {
174 {
175 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
175 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
176 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
176 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
177 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
177 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
178 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
178 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
179 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
179 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
180 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
180 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
181 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
181 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
182 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
182 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
183
183
184 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
184 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
185 {
185 {
186 averaged_spec_mat_NORM[ i ] = sum;
186 averaged_spec_mat_NORM[ i ] = sum;
187 averaged_spec_mat_SBM[ i ] = sum;
187 averaged_spec_mat_SBM[ i ] = sum;
188 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
188 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
189 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
189 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
190 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
190 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
191 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
191 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
192 }
192 }
193 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
193 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
194 {
194 {
195 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
195 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
196 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
196 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
197 }
197 }
198 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
198 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
199 {
199 {
200 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
200 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
201 averaged_spec_mat_SBM[ i ] = sum;
201 averaged_spec_mat_SBM[ i ] = sum;
202 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
202 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
203 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
203 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
204 }
204 }
205 else
205 else
206 {
206 {
207 averaged_spec_mat_NORM[ i ] = sum;
207 averaged_spec_mat_NORM[ i ] = sum;
208 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
208 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
209 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
209 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
210 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
210 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
211 // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
211 // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
212 }
212 }
213 }
213 }
214 }
214 }
215
215
216 void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
216 void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
217 ring_node *ring_node_tab[],
217 ring_node *ring_node_tab[],
218 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
218 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
219 asm_msg *msgForMATR )
219 asm_msg *msgForMATR )
220 {
220 {
221 float sum;
221 float sum;
222 unsigned int i;
222 unsigned int i;
223
223
224 for(i=0; i<TOTAL_SIZE_SM; i++)
224 for(i=0; i<TOTAL_SIZE_SM; i++)
225 {
225 {
226 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ];
226 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ];
227 averaged_spec_mat_NORM[ i ] = sum;
227 averaged_spec_mat_NORM[ i ] = sum;
228 averaged_spec_mat_SBM[ i ] = sum;
228 averaged_spec_mat_SBM[ i ] = sum;
229 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
229 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
230 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
230 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
231 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
231 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
232 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
232 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
233 }
233 }
234 }
234 }
235
235
236 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
236 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
237 {
237 {
238 int frequencyBin;
238 int frequencyBin;
239 int asmComponent;
239 int asmComponent;
240 unsigned int offsetASM;
240 unsigned int offsetASM;
241 unsigned int offsetASMReorganized;
241 unsigned int offsetASMReorganized;
242
242
243 // BUILD DATA
243 // BUILD DATA
244 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
244 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
245 {
245 {
246 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
246 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
247 {
247 {
248 offsetASMReorganized =
248 offsetASMReorganized =
249 frequencyBin * NB_VALUES_PER_SM
249 frequencyBin * NB_VALUES_PER_SM
250 + asmComponent;
250 + asmComponent;
251 offsetASM =
251 offsetASM =
252 asmComponent * NB_BINS_PER_SM
252 asmComponent * NB_BINS_PER_SM
253 + frequencyBin;
253 + frequencyBin;
254 averaged_spec_mat_reorganized[offsetASMReorganized ] =
254 averaged_spec_mat_reorganized[offsetASMReorganized ] =
255 averaged_spec_mat[ offsetASM ] / divider;
255 averaged_spec_mat[ offsetASM ] / divider;
256 }
256 }
257 }
257 }
258 }
258 }
259
259
260 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
260 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
261 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
261 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
262 {
262 {
263 int frequencyBin;
263 int frequencyBin;
264 int asmComponent;
264 int asmComponent;
265 int offsetASM;
265 int offsetASM;
266 int offsetCompressed;
266 int offsetCompressed;
267 int k;
267 int k;
268
268
269 // BUILD DATA
269 // BUILD DATA
270 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
270 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
271 {
271 {
272 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
272 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
273 {
273 {
274 offsetCompressed = // NO TIME OFFSET
274 offsetCompressed = // NO TIME OFFSET
275 frequencyBin * NB_VALUES_PER_SM
275 frequencyBin * NB_VALUES_PER_SM
276 + asmComponent;
276 + asmComponent;
277 offsetASM = // NO TIME OFFSET
277 offsetASM = // NO TIME OFFSET
278 asmComponent * NB_BINS_PER_SM
278 asmComponent * NB_BINS_PER_SM
279 + ASMIndexStart
279 + ASMIndexStart
280 + frequencyBin * nbBinsToAverage;
280 + frequencyBin * nbBinsToAverage;
281 compressed_spec_mat[ offsetCompressed ] = 0;
281 compressed_spec_mat[ offsetCompressed ] = 0;
282 for ( k = 0; k < nbBinsToAverage; k++ )
282 for ( k = 0; k < nbBinsToAverage; k++ )
283 {
283 {
284 compressed_spec_mat[offsetCompressed ] =
284 compressed_spec_mat[offsetCompressed ] =
285 ( compressed_spec_mat[ offsetCompressed ]
285 ( compressed_spec_mat[ offsetCompressed ]
286 + averaged_spec_mat[ offsetASM + k ] );
286 + averaged_spec_mat[ offsetASM + k ] );
287 }
287 }
288 compressed_spec_mat[ offsetCompressed ] =
288 compressed_spec_mat[ offsetCompressed ] =
289 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
289 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
290 }
290 }
291 }
291 }
292 }
292 }
293
293
294 void ASM_convert( volatile float *input_matrix, char *output_matrix)
294 void ASM_convert( volatile float *input_matrix, char *output_matrix)
295 {
295 {
296 unsigned int frequencyBin;
296 unsigned int frequencyBin;
297 unsigned int asmComponent;
297 unsigned int asmComponent;
298 char * pt_char_input;
298 char * pt_char_input;
299 char * pt_char_output;
299 char * pt_char_output;
300 unsigned int offsetInput;
300 unsigned int offsetInput;
301 unsigned int offsetOutput;
301 unsigned int offsetOutput;
302
302
303 pt_char_input = (char*) &input_matrix;
303 pt_char_input = (char*) &input_matrix;
304 pt_char_output = (char*) &output_matrix;
304 pt_char_output = (char*) &output_matrix;
305
305
306 // convert all other data
306 // convert all other data
307 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
307 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
308 {
308 {
309 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
309 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
310 {
310 {
311 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
311 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
312 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
312 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
313 pt_char_input = (char*) &input_matrix [ offsetInput ];
313 pt_char_input = (char*) &input_matrix [ offsetInput ];
314 pt_char_output = (char*) &output_matrix[ offsetOutput ];
314 pt_char_output = (char*) &output_matrix[ offsetOutput ];
315 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
315 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
316 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
316 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
317 }
317 }
318 }
318 }
319 }
319 }
320
320
321 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat,
321 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat,
322 float divider,
322 float divider,
323 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
323 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel);
324
324
325 int getFBinMask(int k);
325 int getFBinMask(int k, unsigned char channel);
326
326
327 void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm);
327 void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm);
328
328
329 #endif // FSW_PROCESSING_H_INCLUDED
329 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,408 +1,408
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf0_prc0.h"
10 #include "avf0_prc0.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14
14
15 //***
15 //***
16 // F0
16 // F0
17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ];
18 ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19
19
20 ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ];
20 ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ];
21 int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ];
21 int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ];
22
22
23 float asm_f0_patched_norm [ TOTAL_SIZE_SM ];
23 float asm_f0_patched_norm [ TOTAL_SIZE_SM ];
24 float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ];
24 float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ];
25 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
25 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
26
26
27 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
27 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
28 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
28 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
29 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
29 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
30
30
31 float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352
31 float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352
32 float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704
32 float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704
33
33
34 //************
34 //************
35 // RTEMS TASKS
35 // RTEMS TASKS
36
36
37 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
37 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
38 {
38 {
39 int i;
39 int i;
40
40
41 rtems_event_set event_out;
41 rtems_event_set event_out;
42 rtems_status_code status;
42 rtems_status_code status;
43 rtems_id queue_id_prc0;
43 rtems_id queue_id_prc0;
44 asm_msg msgForMATR;
44 asm_msg msgForMATR;
45 ring_node *nodeForAveraging;
45 ring_node *nodeForAveraging;
46 ring_node *ring_node_tab[8];
46 ring_node *ring_node_tab[8];
47 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
47 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
48 ring_node_asm *current_ring_node_asm_norm_f0;
48 ring_node_asm *current_ring_node_asm_norm_f0;
49
49
50 unsigned int nb_norm_bp1;
50 unsigned int nb_norm_bp1;
51 unsigned int nb_norm_bp2;
51 unsigned int nb_norm_bp2;
52 unsigned int nb_norm_asm;
52 unsigned int nb_norm_asm;
53 unsigned int nb_sbm_bp1;
53 unsigned int nb_sbm_bp1;
54 unsigned int nb_sbm_bp2;
54 unsigned int nb_sbm_bp2;
55
55
56 nb_norm_bp1 = 0;
56 nb_norm_bp1 = 0;
57 nb_norm_bp2 = 0;
57 nb_norm_bp2 = 0;
58 nb_norm_asm = 0;
58 nb_norm_asm = 0;
59 nb_sbm_bp1 = 0;
59 nb_sbm_bp1 = 0;
60 nb_sbm_bp2 = 0;
60 nb_sbm_bp2 = 0;
61
61
62 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
62 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
63 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
63 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
64 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
64 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
65 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
65 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
66 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
66 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
67
67
68 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
68 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
69
69
70 status = get_message_queue_id_prc0( &queue_id_prc0 );
70 status = get_message_queue_id_prc0( &queue_id_prc0 );
71 if (status != RTEMS_SUCCESSFUL)
71 if (status != RTEMS_SUCCESSFUL)
72 {
72 {
73 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
73 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
74 }
74 }
75
75
76 while(1){
76 while(1){
77 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
77 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
78
78
79 //****************************************
79 //****************************************
80 // initialize the mesage for the MATR task
80 // initialize the mesage for the MATR task
81 msgForMATR.norm = current_ring_node_asm_norm_f0;
81 msgForMATR.norm = current_ring_node_asm_norm_f0;
82 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
82 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
83 msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task
83 msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task
84 //
84 //
85 //****************************************
85 //****************************************
86
86
87 nodeForAveraging = getRingNodeForAveraging( 0 );
87 nodeForAveraging = getRingNodeForAveraging( 0 );
88
88
89 ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging;
89 ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging;
90 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
90 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
91 {
91 {
92 nodeForAveraging = nodeForAveraging->previous;
92 nodeForAveraging = nodeForAveraging->previous;
93 ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging;
93 ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging;
94 }
94 }
95
95
96 // compute the average and store it in the averaged_sm_f1 buffer
96 // compute the average and store it in the averaged_sm_f1 buffer
97 SM_average( current_ring_node_asm_norm_f0->matrix,
97 SM_average( current_ring_node_asm_norm_f0->matrix,
98 current_ring_node_asm_burst_sbm_f0->matrix,
98 current_ring_node_asm_burst_sbm_f0->matrix,
99 ring_node_tab,
99 ring_node_tab,
100 nb_norm_bp1, nb_sbm_bp1,
100 nb_norm_bp1, nb_sbm_bp1,
101 &msgForMATR );
101 &msgForMATR );
102
102
103 // update nb_average
103 // update nb_average
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
105 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
105 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
106 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
106 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
107 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
107 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
108 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
108 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
109
109
110 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
110 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
111 {
111 {
112 nb_sbm_bp1 = 0;
112 nb_sbm_bp1 = 0;
113 // set another ring for the ASM storage
113 // set another ring for the ASM storage
114 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
114 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
115 if ( lfrCurrentMode == LFR_MODE_BURST )
115 if ( lfrCurrentMode == LFR_MODE_BURST )
116 {
116 {
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
118 }
118 }
119 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
119 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
120 {
120 {
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
122 }
122 }
123 }
123 }
124
124
125 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
125 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
126 {
126 {
127 nb_sbm_bp2 = 0;
127 nb_sbm_bp2 = 0;
128 if ( lfrCurrentMode == LFR_MODE_BURST )
128 if ( lfrCurrentMode == LFR_MODE_BURST )
129 {
129 {
130 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
130 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
131 }
131 }
132 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
132 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
133 {
133 {
134 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
134 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
135 }
135 }
136 }
136 }
137
137
138 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
138 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
139 {
139 {
140 nb_norm_bp1 = 0;
140 nb_norm_bp1 = 0;
141 // set another ring for the ASM storage
141 // set another ring for the ASM storage
142 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
142 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 {
145 {
146 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
146 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
147 }
147 }
148 }
148 }
149
149
150 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
150 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
151 {
151 {
152 nb_norm_bp2 = 0;
152 nb_norm_bp2 = 0;
153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 {
155 {
156 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
156 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
157 }
157 }
158 }
158 }
159
159
160 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
160 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
161 {
161 {
162 nb_norm_asm = 0;
162 nb_norm_asm = 0;
163 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
163 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
164 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
164 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
165 {
165 {
166 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
166 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
167 }
167 }
168 }
168 }
169
169
170 //*************************
170 //*************************
171 // send the message to MATR
171 // send the message to MATR
172 if (msgForMATR.event != 0x00)
172 if (msgForMATR.event != 0x00)
173 {
173 {
174 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
174 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
175 }
175 }
176
176
177 if (status != RTEMS_SUCCESSFUL) {
177 if (status != RTEMS_SUCCESSFUL) {
178 PRINTF1("in AVF0 *** Error sending message to MATR, code %d\n", status)
178 PRINTF1("in AVF0 *** Error sending message to MATR, code %d\n", status)
179 }
179 }
180 }
180 }
181 }
181 }
182
182
183 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
183 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
184 {
184 {
185 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
185 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
186 size_t size; // size of the incoming TC packet
186 size_t size; // size of the incoming TC packet
187 asm_msg *incomingMsg;
187 asm_msg *incomingMsg;
188 //
188 //
189 unsigned char sid;
189 unsigned char sid;
190 rtems_status_code status;
190 rtems_status_code status;
191 rtems_id queue_id;
191 rtems_id queue_id;
192 rtems_id queue_id_q_p0;
192 rtems_id queue_id_q_p0;
193 bp_packet_with_spare packet_norm_bp1;
193 bp_packet_with_spare packet_norm_bp1;
194 bp_packet packet_norm_bp2;
194 bp_packet packet_norm_bp2;
195 bp_packet packet_sbm_bp1;
195 bp_packet packet_sbm_bp1;
196 bp_packet packet_sbm_bp2;
196 bp_packet packet_sbm_bp2;
197 ring_node *current_ring_node_to_send_asm_f0;
197 ring_node *current_ring_node_to_send_asm_f0;
198
198
199 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
199 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
200 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
200 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
201 current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0;
201 current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0;
202
202
203 //*************
203 //*************
204 // NORM headers
204 // NORM headers
205 BP_init_header_with_spare( &packet_norm_bp1,
205 BP_init_header_with_spare( &packet_norm_bp1,
206 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
206 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
207 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
207 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
208 BP_init_header( &packet_norm_bp2,
208 BP_init_header( &packet_norm_bp2,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
211
211
212 //****************************
212 //****************************
213 // BURST SBM1 and SBM2 headers
213 // BURST SBM1 and SBM2 headers
214 if ( lfrRequestedMode == LFR_MODE_BURST )
214 if ( lfrRequestedMode == LFR_MODE_BURST )
215 {
215 {
216 BP_init_header( &packet_sbm_bp1,
216 BP_init_header( &packet_sbm_bp1,
217 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
217 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
219 BP_init_header( &packet_sbm_bp2,
219 BP_init_header( &packet_sbm_bp2,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 }
222 }
223 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
223 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
224 {
224 {
225 BP_init_header( &packet_sbm_bp1,
225 BP_init_header( &packet_sbm_bp1,
226 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
226 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
227 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
227 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 BP_init_header( &packet_sbm_bp2,
228 BP_init_header( &packet_sbm_bp2,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
231 }
231 }
232 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
232 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
233 {
233 {
234 BP_init_header( &packet_sbm_bp1,
234 BP_init_header( &packet_sbm_bp1,
235 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
235 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
236 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
236 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
237 BP_init_header( &packet_sbm_bp2,
237 BP_init_header( &packet_sbm_bp2,
238 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
238 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
239 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
239 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
240 }
240 }
241 else
241 else
242 {
242 {
243 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
243 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
244 }
244 }
245
245
246 status = get_message_queue_id_send( &queue_id );
246 status = get_message_queue_id_send( &queue_id );
247 if (status != RTEMS_SUCCESSFUL)
247 if (status != RTEMS_SUCCESSFUL)
248 {
248 {
249 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
249 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
250 }
250 }
251 status = get_message_queue_id_prc0( &queue_id_q_p0);
251 status = get_message_queue_id_prc0( &queue_id_q_p0);
252 if (status != RTEMS_SUCCESSFUL)
252 if (status != RTEMS_SUCCESSFUL)
253 {
253 {
254 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
254 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
255 }
255 }
256
256
257 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
257 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
258
258
259 while(1){
259 while(1){
260 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
260 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
261 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
261 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
262
262
263 incomingMsg = (asm_msg*) incomingData;
263 incomingMsg = (asm_msg*) incomingData;
264
264
265 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
265 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
266 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
266 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
267
267
268 //****************
268 //****************
269 //****************
269 //****************
270 // BURST SBM1 SBM2
270 // BURST SBM1 SBM2
271 //****************
271 //****************
272 //****************
272 //****************
273 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
273 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
274 {
274 {
275 sid = getSID( incomingMsg->event );
275 sid = getSID( incomingMsg->event );
276 // 1) compress the matrix for Basic Parameters calculation
276 // 1) compress the matrix for Basic Parameters calculation
277 ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
277 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
278 nb_sm_before_f0.burst_sbm_bp1,
278 nb_sm_before_f0.burst_sbm_bp1,
279 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
279 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
280 ASM_F0_INDICE_START);
280 ASM_F0_INDICE_START, CHANNELF0);
281 // 2) compute the BP1 set
281 // 2) compute the BP1 set
282 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
282 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
283 // 3) send the BP1 set
283 // 3) send the BP1 set
284 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
284 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
285 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
285 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
286 packet_sbm_bp1.biaStatusInfo = pa_bia_status_info;
286 packet_sbm_bp1.biaStatusInfo = pa_bia_status_info;
287 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
287 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
288 BP_send( (char *) &packet_sbm_bp1, queue_id,
288 BP_send( (char *) &packet_sbm_bp1, queue_id,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
290 sid);
290 sid);
291 // 4) compute the BP2 set if needed
291 // 4) compute the BP2 set if needed
292 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
292 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
293 {
293 {
294 // 1) compute the BP2 set
294 // 1) compute the BP2 set
295 BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data );
295 BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data );
296 // 2) send the BP2 set
296 // 2) send the BP2 set
297 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
297 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
298 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
298 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
299 packet_sbm_bp2.biaStatusInfo = pa_bia_status_info;
299 packet_sbm_bp2.biaStatusInfo = pa_bia_status_info;
300 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
300 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
301 BP_send( (char *) &packet_sbm_bp2, queue_id,
301 BP_send( (char *) &packet_sbm_bp2, queue_id,
302 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
302 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
303 sid);
303 sid);
304 }
304 }
305 }
305 }
306
306
307 //*****
307 //*****
308 //*****
308 //*****
309 // NORM
309 // NORM
310 //*****
310 //*****
311 //*****
311 //*****
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
313 {
313 {
314 // 1) compress the matrix for Basic Parameters calculation
314 // 1) compress the matrix for Basic Parameters calculation
315 ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0,
315 ASM_compress_reorganize_and_divide_mask( asm_f0_patched_norm, compressed_sm_norm_f0,
316 nb_sm_before_f0.norm_bp1,
316 nb_sm_before_f0.norm_bp1,
317 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
317 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
318 ASM_F0_INDICE_START );
318 ASM_F0_INDICE_START, CHANNELF0 );
319 // 2) compute the BP1 set
319 // 2) compute the BP1 set
320 BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
320 BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
321 // 3) send the BP1 set
321 // 3) send the BP1 set
322 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
322 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
323 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
323 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
324 packet_norm_bp1.biaStatusInfo = pa_bia_status_info;
324 packet_norm_bp1.biaStatusInfo = pa_bia_status_info;
325 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
325 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
326 BP_send( (char *) &packet_norm_bp1, queue_id,
326 BP_send( (char *) &packet_norm_bp1, queue_id,
327 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
327 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
328 SID_NORM_BP1_F0 );
328 SID_NORM_BP1_F0 );
329 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
329 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
330 {
330 {
331 // 1) compute the BP2 set using the same ASM as the one used for BP1
331 // 1) compute the BP2 set using the same ASM as the one used for BP1
332 BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data );
332 BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data );
333 // 2) send the BP2 set
333 // 2) send the BP2 set
334 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
334 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
335 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
335 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
336 packet_norm_bp2.biaStatusInfo = pa_bia_status_info;
336 packet_norm_bp2.biaStatusInfo = pa_bia_status_info;
337 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
337 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
338 BP_send( (char *) &packet_norm_bp2, queue_id,
338 BP_send( (char *) &packet_norm_bp2, queue_id,
339 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
339 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
340 SID_NORM_BP2_F0);
340 SID_NORM_BP2_F0);
341 }
341 }
342 }
342 }
343
343
344 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
344 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
345 {
345 {
346 // 1) reorganize the ASM and divide
346 // 1) reorganize the ASM and divide
347 ASM_reorganize_and_divide( asm_f0_patched_norm,
347 ASM_reorganize_and_divide( asm_f0_patched_norm,
348 (float*) current_ring_node_to_send_asm_f0->buffer_address,
348 (float*) current_ring_node_to_send_asm_f0->buffer_address,
349 nb_sm_before_f0.norm_bp1 );
349 nb_sm_before_f0.norm_bp1 );
350 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
350 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
351 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
351 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
352 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
352 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
353
353
354 // 3) send the spectral matrix packets
354 // 3) send the spectral matrix packets
355 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
355 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
356 // change asm ring node
356 // change asm ring node
357 current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next;
357 current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next;
358 }
358 }
359
359
360 update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max );
360 update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max );
361
361
362 }
362 }
363 }
363 }
364
364
365 //**********
365 //**********
366 // FUNCTIONS
366 // FUNCTIONS
367
367
368 void reset_nb_sm_f0( unsigned char lfrMode )
368 void reset_nb_sm_f0( unsigned char lfrMode )
369 {
369 {
370 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
370 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
371 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
371 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
372 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;
372 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;
373 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
373 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
374 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
374 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
375 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
375 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
376 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
376 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
377 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
377 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
378 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
378 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
379
379
380 if (lfrMode == LFR_MODE_SBM1)
380 if (lfrMode == LFR_MODE_SBM1)
381 {
381 {
382 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
382 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
383 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
383 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
384 }
384 }
385 else if (lfrMode == LFR_MODE_SBM2)
385 else if (lfrMode == LFR_MODE_SBM2)
386 {
386 {
387 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
387 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
388 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
388 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
389 }
389 }
390 else if (lfrMode == LFR_MODE_BURST)
390 else if (lfrMode == LFR_MODE_BURST)
391 {
391 {
392 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
392 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
393 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
393 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
394 }
394 }
395 else
395 else
396 {
396 {
397 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
397 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
398 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
398 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
399 }
399 }
400 }
400 }
401
401
402 void init_k_coefficients_prc0( void )
402 void init_k_coefficients_prc0( void )
403 {
403 {
404 init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 );
404 init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 );
405
405
406 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0);
406 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0);
407 }
407 }
408
408
@@ -1,394 +1,394
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf1_prc1.h"
10 #include "avf1_prc1.h"
11
11
12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
13
13
14 extern ring_node sm_ring_f1[ ];
14 extern ring_node sm_ring_f1[ ];
15
15
16 //***
16 //***
17 // F1
17 // F1
18 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
18 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
19 ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ];
19 ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ];
20
20
21 ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ];
21 ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ];
22 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ];
22 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ];
23
23
24 float asm_f1_patched_norm [ TOTAL_SIZE_SM ];
24 float asm_f1_patched_norm [ TOTAL_SIZE_SM ];
25 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ];
25 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ];
26 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
26 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
27
27
28 char asm_f1_char [ TOTAL_SIZE_SM * 2 ];
28 char asm_f1_char [ TOTAL_SIZE_SM * 2 ];
29 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
29 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
30 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
30 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
31
31
32 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416
32 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416
33 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832
33 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832
34
34
35 //************
35 //************
36 // RTEMS TASKS
36 // RTEMS TASKS
37
37
38 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
38 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
39 {
39 {
40 int i;
40 int i;
41
41
42 rtems_event_set event_out;
42 rtems_event_set event_out;
43 rtems_status_code status;
43 rtems_status_code status;
44 rtems_id queue_id_prc1;
44 rtems_id queue_id_prc1;
45 asm_msg msgForMATR;
45 asm_msg msgForMATR;
46 ring_node *nodeForAveraging;
46 ring_node *nodeForAveraging;
47 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0];
47 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0];
48 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
48 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
49 ring_node_asm *current_ring_node_asm_norm_f1;
49 ring_node_asm *current_ring_node_asm_norm_f1;
50
50
51 unsigned int nb_norm_bp1;
51 unsigned int nb_norm_bp1;
52 unsigned int nb_norm_bp2;
52 unsigned int nb_norm_bp2;
53 unsigned int nb_norm_asm;
53 unsigned int nb_norm_asm;
54 unsigned int nb_sbm_bp1;
54 unsigned int nb_sbm_bp1;
55 unsigned int nb_sbm_bp2;
55 unsigned int nb_sbm_bp2;
56
56
57 nb_norm_bp1 = 0;
57 nb_norm_bp1 = 0;
58 nb_norm_bp2 = 0;
58 nb_norm_bp2 = 0;
59 nb_norm_asm = 0;
59 nb_norm_asm = 0;
60 nb_sbm_bp1 = 0;
60 nb_sbm_bp1 = 0;
61 nb_sbm_bp2 = 0;
61 nb_sbm_bp2 = 0;
62
62
63 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
63 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
64 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
64 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
65 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
65 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
66 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
66 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
67 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
67 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
68
68
69 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
69 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
70
70
71 status = get_message_queue_id_prc1( &queue_id_prc1 );
71 status = get_message_queue_id_prc1( &queue_id_prc1 );
72 if (status != RTEMS_SUCCESSFUL)
72 if (status != RTEMS_SUCCESSFUL)
73 {
73 {
74 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
74 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
75 }
75 }
76
76
77 while(1){
77 while(1){
78 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
78 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
79
79
80 //****************************************
80 //****************************************
81 // initialize the mesage for the MATR task
81 // initialize the mesage for the MATR task
82 msgForMATR.norm = current_ring_node_asm_norm_f1;
82 msgForMATR.norm = current_ring_node_asm_norm_f1;
83 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
83 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
84 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
84 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
85 //
85 //
86 //****************************************
86 //****************************************
87
87
88 nodeForAveraging = getRingNodeForAveraging( 1 );
88 nodeForAveraging = getRingNodeForAveraging( 1 );
89
89
90 ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging;
90 ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging;
91 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
91 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
92 {
92 {
93 nodeForAveraging = nodeForAveraging->previous;
93 nodeForAveraging = nodeForAveraging->previous;
94 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
94 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
95 }
95 }
96
96
97 // compute the average and store it in the averaged_sm_f1 buffer
97 // compute the average and store it in the averaged_sm_f1 buffer
98 SM_average( current_ring_node_asm_norm_f1->matrix,
98 SM_average( current_ring_node_asm_norm_f1->matrix,
99 current_ring_node_asm_burst_sbm_f1->matrix,
99 current_ring_node_asm_burst_sbm_f1->matrix,
100 ring_node_tab,
100 ring_node_tab,
101 nb_norm_bp1, nb_sbm_bp1,
101 nb_norm_bp1, nb_sbm_bp1,
102 &msgForMATR );
102 &msgForMATR );
103
103
104 // update nb_average
104 // update nb_average
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
110
110
111 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
111 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
112 {
112 {
113 nb_sbm_bp1 = 0;
113 nb_sbm_bp1 = 0;
114 // set another ring for the ASM storage
114 // set another ring for the ASM storage
115 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
115 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
116 if ( lfrCurrentMode == LFR_MODE_BURST )
116 if ( lfrCurrentMode == LFR_MODE_BURST )
117 {
117 {
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
119 }
119 }
120 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
121 {
121 {
122 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
122 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
123 }
123 }
124 }
124 }
125
125
126 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
126 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
127 {
127 {
128 nb_sbm_bp2 = 0;
128 nb_sbm_bp2 = 0;
129 if ( lfrCurrentMode == LFR_MODE_BURST )
129 if ( lfrCurrentMode == LFR_MODE_BURST )
130 {
130 {
131 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
131 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
132 }
132 }
133 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
133 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
134 {
134 {
135 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
135 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
136 }
136 }
137 }
137 }
138
138
139 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
139 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
140 {
140 {
141 nb_norm_bp1 = 0;
141 nb_norm_bp1 = 0;
142 // set another ring for the ASM storage
142 // set another ring for the ASM storage
143 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
143 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
146 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
148 }
148 }
149 }
149 }
150
150
151 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
151 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
152 {
152 {
153 nb_norm_bp2 = 0;
153 nb_norm_bp2 = 0;
154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
156 {
156 {
157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
158 }
158 }
159 }
159 }
160
160
161 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
161 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
162 {
162 {
163 nb_norm_asm = 0;
163 nb_norm_asm = 0;
164 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
164 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
165 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
165 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
166 {
166 {
167 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
167 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
168 }
168 }
169 }
169 }
170
170
171 //*************************
171 //*************************
172 // send the message to MATR
172 // send the message to MATR
173 if (msgForMATR.event != 0x00)
173 if (msgForMATR.event != 0x00)
174 {
174 {
175 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
175 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
176 }
176 }
177
177
178 if (status != RTEMS_SUCCESSFUL) {
178 if (status != RTEMS_SUCCESSFUL) {
179 PRINTF1("in AVF1 *** Error sending message to PRC1, code %d\n", status)
179 PRINTF1("in AVF1 *** Error sending message to PRC1, code %d\n", status)
180 }
180 }
181 }
181 }
182 }
182 }
183
183
184 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
184 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
185 {
185 {
186 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
186 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
187 size_t size; // size of the incoming TC packet
187 size_t size; // size of the incoming TC packet
188 asm_msg *incomingMsg;
188 asm_msg *incomingMsg;
189 //
189 //
190 unsigned char sid;
190 unsigned char sid;
191 rtems_status_code status;
191 rtems_status_code status;
192 rtems_id queue_id_send;
192 rtems_id queue_id_send;
193 rtems_id queue_id_q_p1;
193 rtems_id queue_id_q_p1;
194 bp_packet_with_spare packet_norm_bp1;
194 bp_packet_with_spare packet_norm_bp1;
195 bp_packet packet_norm_bp2;
195 bp_packet packet_norm_bp2;
196 bp_packet packet_sbm_bp1;
196 bp_packet packet_sbm_bp1;
197 bp_packet packet_sbm_bp2;
197 bp_packet packet_sbm_bp2;
198 ring_node *current_ring_node_to_send_asm_f1;
198 ring_node *current_ring_node_to_send_asm_f1;
199
199
200 unsigned long long int localTime;
200 unsigned long long int localTime;
201
201
202 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
202 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
203 init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM );
203 init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM );
204 current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1;
204 current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1;
205
205
206 //*************
206 //*************
207 // NORM headers
207 // NORM headers
208 BP_init_header_with_spare( &packet_norm_bp1,
208 BP_init_header_with_spare( &packet_norm_bp1,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
211 BP_init_header( &packet_norm_bp2,
211 BP_init_header( &packet_norm_bp2,
212 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
212 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
213 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
213 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
214
214
215 //***********************
215 //***********************
216 // BURST and SBM2 headers
216 // BURST and SBM2 headers
217 if ( lfrRequestedMode == LFR_MODE_BURST )
217 if ( lfrRequestedMode == LFR_MODE_BURST )
218 {
218 {
219 BP_init_header( &packet_sbm_bp1,
219 BP_init_header( &packet_sbm_bp1,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
222 BP_init_header( &packet_sbm_bp2,
222 BP_init_header( &packet_sbm_bp2,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
225 }
225 }
226 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
226 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
227 {
227 {
228 BP_init_header( &packet_sbm_bp1,
228 BP_init_header( &packet_sbm_bp1,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
231 BP_init_header( &packet_sbm_bp2,
231 BP_init_header( &packet_sbm_bp2,
232 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
232 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
233 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
233 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
234 }
234 }
235 else
235 else
236 {
236 {
237 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
237 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
238 }
238 }
239
239
240 status = get_message_queue_id_send( &queue_id_send );
240 status = get_message_queue_id_send( &queue_id_send );
241 if (status != RTEMS_SUCCESSFUL)
241 if (status != RTEMS_SUCCESSFUL)
242 {
242 {
243 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
243 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
244 }
244 }
245 status = get_message_queue_id_prc1( &queue_id_q_p1);
245 status = get_message_queue_id_prc1( &queue_id_q_p1);
246 if (status != RTEMS_SUCCESSFUL)
246 if (status != RTEMS_SUCCESSFUL)
247 {
247 {
248 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
248 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
249 }
249 }
250
250
251 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
251 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
252
252
253 while(1){
253 while(1){
254 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
254 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
255 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
255 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
256
256
257 incomingMsg = (asm_msg*) incomingData;
257 incomingMsg = (asm_msg*) incomingData;
258
258
259 ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm );
259 ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm );
260 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm );
260 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm );
261
261
262 localTime = getTimeAsUnsignedLongLongInt( );
262 localTime = getTimeAsUnsignedLongLongInt( );
263 //***********
263 //***********
264 //***********
264 //***********
265 // BURST SBM2
265 // BURST SBM2
266 //***********
266 //***********
267 //***********
267 //***********
268 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
268 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
269 {
269 {
270 sid = getSID( incomingMsg->event );
270 sid = getSID( incomingMsg->event );
271 // 1) compress the matrix for Basic Parameters calculation
271 // 1) compress the matrix for Basic Parameters calculation
272 ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
272 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1,
273 nb_sm_before_f1.burst_sbm_bp1,
273 nb_sm_before_f1.burst_sbm_bp1,
274 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
274 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
275 ASM_F1_INDICE_START);
275 ASM_F1_INDICE_START, CHANNELF1);
276 // 2) compute the BP1 set
276 // 2) compute the BP1 set
277 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
277 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
278 // 3) send the BP1 set
278 // 3) send the BP1 set
279 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
279 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
280 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
280 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
281 packet_sbm_bp1.biaStatusInfo = pa_bia_status_info;
281 packet_sbm_bp1.biaStatusInfo = pa_bia_status_info;
282 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
282 packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
283 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
283 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
284 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
284 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
285 sid );
285 sid );
286 // 4) compute the BP2 set if needed
286 // 4) compute the BP2 set if needed
287 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
287 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
288 {
288 {
289 // 1) compute the BP2 set
289 // 1) compute the BP2 set
290 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data );
290 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data );
291 // 2) send the BP2 set
291 // 2) send the BP2 set
292 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
292 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
293 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
293 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
294 packet_sbm_bp2.biaStatusInfo = pa_bia_status_info;
294 packet_sbm_bp2.biaStatusInfo = pa_bia_status_info;
295 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
295 packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
296 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
296 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
297 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
297 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
298 sid );
298 sid );
299 }
299 }
300 }
300 }
301
301
302 //*****
302 //*****
303 //*****
303 //*****
304 // NORM
304 // NORM
305 //*****
305 //*****
306 //*****
306 //*****
307 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
307 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
308 {
308 {
309 // 1) compress the matrix for Basic Parameters calculation
309 // 1) compress the matrix for Basic Parameters calculation
310 ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1,
310 ASM_compress_reorganize_and_divide_mask( asm_f1_patched_norm, compressed_sm_norm_f1,
311 nb_sm_before_f1.norm_bp1,
311 nb_sm_before_f1.norm_bp1,
312 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
312 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
313 ASM_F1_INDICE_START );
313 ASM_F1_INDICE_START, CHANNELF1 );
314 // 2) compute the BP1 set
314 // 2) compute the BP1 set
315 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
315 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
316 // 3) send the BP1 set
316 // 3) send the BP1 set
317 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
317 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
318 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
318 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
319 packet_norm_bp1.biaStatusInfo = pa_bia_status_info;
319 packet_norm_bp1.biaStatusInfo = pa_bia_status_info;
320 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
320 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
321 BP_send( (char *) &packet_norm_bp1, queue_id_send,
321 BP_send( (char *) &packet_norm_bp1, queue_id_send,
322 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
322 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
323 SID_NORM_BP1_F1 );
323 SID_NORM_BP1_F1 );
324 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
324 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
325 {
325 {
326 // 1) compute the BP2 set
326 // 1) compute the BP2 set
327 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
327 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
328 // 2) send the BP2 set
328 // 2) send the BP2 set
329 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
329 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
330 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
330 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
331 packet_norm_bp2.biaStatusInfo = pa_bia_status_info;
331 packet_norm_bp2.biaStatusInfo = pa_bia_status_info;
332 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
332 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
333 BP_send( (char *) &packet_norm_bp2, queue_id_send,
333 BP_send( (char *) &packet_norm_bp2, queue_id_send,
334 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
334 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
335 SID_NORM_BP2_F1 );
335 SID_NORM_BP2_F1 );
336 }
336 }
337 }
337 }
338
338
339 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
339 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
340 {
340 {
341 // 1) reorganize the ASM and divide
341 // 1) reorganize the ASM and divide
342 ASM_reorganize_and_divide( asm_f1_patched_norm,
342 ASM_reorganize_and_divide( asm_f1_patched_norm,
343 (float*) current_ring_node_to_send_asm_f1->buffer_address,
343 (float*) current_ring_node_to_send_asm_f1->buffer_address,
344 nb_sm_before_f1.norm_bp1 );
344 nb_sm_before_f1.norm_bp1 );
345 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
345 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
346 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
346 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
347 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
347 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
348 // 3) send the spectral matrix packets
348 // 3) send the spectral matrix packets
349 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
349 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
350 // change asm ring node
350 // change asm ring node
351 current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next;
351 current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next;
352 }
352 }
353
353
354 update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max );
354 update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max );
355
355
356 }
356 }
357 }
357 }
358
358
359 //**********
359 //**********
360 // FUNCTIONS
360 // FUNCTIONS
361
361
362 void reset_nb_sm_f1( unsigned char lfrMode )
362 void reset_nb_sm_f1( unsigned char lfrMode )
363 {
363 {
364 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
364 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
365 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
365 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
366 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
366 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
367 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
367 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
368 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
368 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
369 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
369 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
370 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
370 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
371
371
372 if (lfrMode == LFR_MODE_SBM2)
372 if (lfrMode == LFR_MODE_SBM2)
373 {
373 {
374 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
374 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
375 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
375 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
376 }
376 }
377 else if (lfrMode == LFR_MODE_BURST)
377 else if (lfrMode == LFR_MODE_BURST)
378 {
378 {
379 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
379 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
380 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
380 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
381 }
381 }
382 else
382 else
383 {
383 {
384 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
384 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
385 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
385 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
386 }
386 }
387 }
387 }
388
388
389 void init_k_coefficients_prc1( void )
389 void init_k_coefficients_prc1( void )
390 {
390 {
391 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
391 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
392
392
393 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1);
393 init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1);
394 }
394 }
@@ -1,281 +1,281
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf2_prc2.h"
10 #include "avf2_prc2.h"
11
11
12 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
12 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
13
13
14 extern ring_node sm_ring_f2[ ];
14 extern ring_node sm_ring_f2[ ];
15
15
16 //***
16 //***
17 // F2
17 // F2
18 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
18 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
19
19
20 ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ];
20 ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ];
21 int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ];
21 int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ];
22
22
23 float asm_f2_patched_norm [ TOTAL_SIZE_SM ];
23 float asm_f2_patched_norm [ TOTAL_SIZE_SM ];
24 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
24 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
25
25
26 char asm_f2_char [ TOTAL_SIZE_SM * 2 ];
26 char asm_f2_char [ TOTAL_SIZE_SM * 2 ];
27 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
27 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
28
28
29 float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384
29 float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384
30
30
31 //************
31 //************
32 // RTEMS TASKS
32 // RTEMS TASKS
33
33
34 //***
34 //***
35 // F2
35 // F2
36 rtems_task avf2_task( rtems_task_argument argument )
36 rtems_task avf2_task( rtems_task_argument argument )
37 {
37 {
38 rtems_event_set event_out;
38 rtems_event_set event_out;
39 rtems_status_code status;
39 rtems_status_code status;
40 rtems_id queue_id_prc2;
40 rtems_id queue_id_prc2;
41 asm_msg msgForMATR;
41 asm_msg msgForMATR;
42 ring_node *nodeForAveraging;
42 ring_node *nodeForAveraging;
43 ring_node_asm *current_ring_node_asm_norm_f2;
43 ring_node_asm *current_ring_node_asm_norm_f2;
44
44
45 unsigned int nb_norm_bp1;
45 unsigned int nb_norm_bp1;
46 unsigned int nb_norm_bp2;
46 unsigned int nb_norm_bp2;
47 unsigned int nb_norm_asm;
47 unsigned int nb_norm_asm;
48
48
49 nb_norm_bp1 = 0;
49 nb_norm_bp1 = 0;
50 nb_norm_bp2 = 0;
50 nb_norm_bp2 = 0;
51 nb_norm_asm = 0;
51 nb_norm_asm = 0;
52
52
53 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
53 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
54 ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 );
54 ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 );
55 current_ring_node_asm_norm_f2 = asm_ring_norm_f2;
55 current_ring_node_asm_norm_f2 = asm_ring_norm_f2;
56
56
57 BOOT_PRINTF("in AVF2 ***\n")
57 BOOT_PRINTF("in AVF2 ***\n")
58
58
59 status = get_message_queue_id_prc2( &queue_id_prc2 );
59 status = get_message_queue_id_prc2( &queue_id_prc2 );
60 if (status != RTEMS_SUCCESSFUL)
60 if (status != RTEMS_SUCCESSFUL)
61 {
61 {
62 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
62 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
63 }
63 }
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
67
68 //****************************************
68 //****************************************
69 // initialize the mesage for the MATR task
69 // initialize the mesage for the MATR task
70 msgForMATR.norm = current_ring_node_asm_norm_f2;
70 msgForMATR.norm = current_ring_node_asm_norm_f2;
71 msgForMATR.burst_sbm = NULL;
71 msgForMATR.burst_sbm = NULL;
72 msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task
72 msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task
73 //
73 //
74 //****************************************
74 //****************************************
75
75
76 nodeForAveraging = getRingNodeForAveraging( 2 );
76 nodeForAveraging = getRingNodeForAveraging( 2 );
77
77
78 // compute the average and store it in the averaged_sm_f2 buffer
78 // compute the average and store it in the averaged_sm_f2 buffer
79 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
79 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
80 nodeForAveraging,
80 nodeForAveraging,
81 nb_norm_bp1,
81 nb_norm_bp1,
82 &msgForMATR );
82 &msgForMATR );
83
83
84 // update nb_average
84 // update nb_average
85 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
85 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
86 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
86 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
87 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
87 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
88
88
89 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
89 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
90 {
90 {
91 nb_norm_bp1 = 0;
91 nb_norm_bp1 = 0;
92 // set another ring for the ASM storage
92 // set another ring for the ASM storage
93 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
93 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
94 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
94 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
95 || (lfrCurrentMode == LFR_MODE_SBM2) )
95 || (lfrCurrentMode == LFR_MODE_SBM2) )
96 {
96 {
97 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2;
97 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2;
98 }
98 }
99 }
99 }
100
100
101 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
101 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
102 {
102 {
103 nb_norm_bp2 = 0;
103 nb_norm_bp2 = 0;
104 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
104 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
105 || (lfrCurrentMode == LFR_MODE_SBM2) )
105 || (lfrCurrentMode == LFR_MODE_SBM2) )
106 {
106 {
107 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
107 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
108 }
108 }
109 }
109 }
110
110
111 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
111 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
112 {
112 {
113 nb_norm_asm = 0;
113 nb_norm_asm = 0;
114 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
114 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
115 || (lfrCurrentMode == LFR_MODE_SBM2) )
115 || (lfrCurrentMode == LFR_MODE_SBM2) )
116 {
116 {
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
118 }
118 }
119 }
119 }
120
120
121 //*************************
121 //*************************
122 // send the message to MATR
122 // send the message to MATR
123 if (msgForMATR.event != 0x00)
123 if (msgForMATR.event != 0x00)
124 {
124 {
125 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2);
125 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2);
126 }
126 }
127
127
128 if (status != RTEMS_SUCCESSFUL) {
128 if (status != RTEMS_SUCCESSFUL) {
129 PRINTF1("in AVF2 *** Error sending message to MATR, code %d\n", status)
129 PRINTF1("in AVF2 *** Error sending message to MATR, code %d\n", status)
130 }
130 }
131 }
131 }
132 }
132 }
133
133
134 rtems_task prc2_task( rtems_task_argument argument )
134 rtems_task prc2_task( rtems_task_argument argument )
135 {
135 {
136 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
136 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
137 size_t size; // size of the incoming TC packet
137 size_t size; // size of the incoming TC packet
138 asm_msg *incomingMsg;
138 asm_msg *incomingMsg;
139 //
139 //
140 rtems_status_code status;
140 rtems_status_code status;
141 rtems_id queue_id_send;
141 rtems_id queue_id_send;
142 rtems_id queue_id_q_p2;
142 rtems_id queue_id_q_p2;
143 bp_packet packet_norm_bp1;
143 bp_packet packet_norm_bp1;
144 bp_packet packet_norm_bp2;
144 bp_packet packet_norm_bp2;
145 ring_node *current_ring_node_to_send_asm_f2;
145 ring_node *current_ring_node_to_send_asm_f2;
146
146
147 unsigned long long int localTime;
147 unsigned long long int localTime;
148
148
149 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
149 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
150 init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM );
150 init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM );
151 current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2;
151 current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2;
152
152
153 //*************
153 //*************
154 // NORM headers
154 // NORM headers
155 BP_init_header( &packet_norm_bp1,
155 BP_init_header( &packet_norm_bp1,
156 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
156 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
157 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
157 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
158 BP_init_header( &packet_norm_bp2,
158 BP_init_header( &packet_norm_bp2,
159 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
159 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
160 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
160 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
161
161
162 status = get_message_queue_id_send( &queue_id_send );
162 status = get_message_queue_id_send( &queue_id_send );
163 if (status != RTEMS_SUCCESSFUL)
163 if (status != RTEMS_SUCCESSFUL)
164 {
164 {
165 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
165 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
166 }
166 }
167 status = get_message_queue_id_prc2( &queue_id_q_p2);
167 status = get_message_queue_id_prc2( &queue_id_q_p2);
168 if (status != RTEMS_SUCCESSFUL)
168 if (status != RTEMS_SUCCESSFUL)
169 {
169 {
170 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
170 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
171 }
171 }
172
172
173 BOOT_PRINTF("in PRC2 ***\n")
173 BOOT_PRINTF("in PRC2 ***\n")
174
174
175 while(1){
175 while(1){
176 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
176 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
177 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2
177 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2
178
178
179 incomingMsg = (asm_msg*) incomingData;
179 incomingMsg = (asm_msg*) incomingData;
180
180
181 ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm );
181 ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm );
182
182
183 localTime = getTimeAsUnsignedLongLongInt( );
183 localTime = getTimeAsUnsignedLongLongInt( );
184
184
185 //*****
185 //*****
186 //*****
186 //*****
187 // NORM
187 // NORM
188 //*****
188 //*****
189 //*****
189 //*****
190 // 1) compress the matrix for Basic Parameters calculation
190 // 1) compress the matrix for Basic Parameters calculation
191 ASM_compress_reorganize_and_divide( asm_f2_patched_norm, compressed_sm_norm_f2,
191 ASM_compress_reorganize_and_divide_mask( asm_f2_patched_norm, compressed_sm_norm_f2,
192 nb_sm_before_f2.norm_bp1,
192 nb_sm_before_f2.norm_bp1,
193 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
193 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
194 ASM_F2_INDICE_START );
194 ASM_F2_INDICE_START, CHANNELF2 );
195 // BP1_F2
195 // BP1_F2
196 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
196 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
197 {
197 {
198 // 1) compute the BP1 set
198 // 1) compute the BP1 set
199 BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data );
199 BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data );
200 // 2) send the BP1 set
200 // 2) send the BP1 set
201 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
201 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
202 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
202 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
203 packet_norm_bp1.biaStatusInfo = pa_bia_status_info;
203 packet_norm_bp1.biaStatusInfo = pa_bia_status_info;
204 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
204 packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
205 BP_send( (char *) &packet_norm_bp1, queue_id_send,
205 BP_send( (char *) &packet_norm_bp1, queue_id_send,
206 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
206 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
207 SID_NORM_BP1_F2 );
207 SID_NORM_BP1_F2 );
208 }
208 }
209 // BP2_F2
209 // BP2_F2
210 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
210 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
211 {
211 {
212 // 1) compute the BP2 set
212 // 1) compute the BP2 set
213 BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data );
213 BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data );
214 // 2) send the BP2 set
214 // 2) send the BP2 set
215 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
215 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
216 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
216 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
217 packet_norm_bp2.biaStatusInfo = pa_bia_status_info;
217 packet_norm_bp2.biaStatusInfo = pa_bia_status_info;
218 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
218 packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
219 BP_send( (char *) &packet_norm_bp2, queue_id_send,
219 BP_send( (char *) &packet_norm_bp2, queue_id_send,
220 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
220 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
221 SID_NORM_BP2_F2 );
221 SID_NORM_BP2_F2 );
222 }
222 }
223
223
224 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
224 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
225 {
225 {
226 // 1) reorganize the ASM and divide
226 // 1) reorganize the ASM and divide
227 ASM_reorganize_and_divide( asm_f2_patched_norm,
227 ASM_reorganize_and_divide( asm_f2_patched_norm,
228 (float*) current_ring_node_to_send_asm_f2->buffer_address,
228 (float*) current_ring_node_to_send_asm_f2->buffer_address,
229 nb_sm_before_f2.norm_bp1 );
229 nb_sm_before_f2.norm_bp1 );
230 current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM;
230 current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM;
231 current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM;
231 current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM;
232 current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2;
232 current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2;
233 // 3) send the spectral matrix packets
233 // 3) send the spectral matrix packets
234 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f2, sizeof( ring_node* ) );
234 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f2, sizeof( ring_node* ) );
235 // change asm ring node
235 // change asm ring node
236 current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next;
236 current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next;
237 }
237 }
238
238
239 update_queue_max_count( queue_id_q_p2, &hk_lfr_q_p2_fifo_size_max );
239 update_queue_max_count( queue_id_q_p2, &hk_lfr_q_p2_fifo_size_max );
240
240
241 }
241 }
242 }
242 }
243
243
244 //**********
244 //**********
245 // FUNCTIONS
245 // FUNCTIONS
246
246
247 void reset_nb_sm_f2( void )
247 void reset_nb_sm_f2( void )
248 {
248 {
249 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
249 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
250 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
250 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
251 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
251 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
252 }
252 }
253
253
254 void SM_average_f2( float *averaged_spec_mat_f2,
254 void SM_average_f2( float *averaged_spec_mat_f2,
255 ring_node *ring_node,
255 ring_node *ring_node,
256 unsigned int nbAverageNormF2,
256 unsigned int nbAverageNormF2,
257 asm_msg *msgForMATR )
257 asm_msg *msgForMATR )
258 {
258 {
259 float sum;
259 float sum;
260 unsigned int i;
260 unsigned int i;
261
261
262 for(i=0; i<TOTAL_SIZE_SM; i++)
262 for(i=0; i<TOTAL_SIZE_SM; i++)
263 {
263 {
264 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
264 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
265 if ( (nbAverageNormF2 == 0) )
265 if ( (nbAverageNormF2 == 0) )
266 {
266 {
267 averaged_spec_mat_f2[ i ] = sum;
267 averaged_spec_mat_f2[ i ] = sum;
268 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
268 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
269 msgForMATR->fineTimeNORM = ring_node->fineTime;
269 msgForMATR->fineTimeNORM = ring_node->fineTime;
270 }
270 }
271 else
271 else
272 {
272 {
273 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
273 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
274 }
274 }
275 }
275 }
276 }
276 }
277
277
278 void init_k_coefficients_prc2( void )
278 void init_k_coefficients_prc2( void )
279 {
279 {
280 init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2);
280 init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2);
281 }
281 }
@@ -1,669 +1,689
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "fsw_processing.h"
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
11 #include "fsw_processing_globals.c"
12 #include "fsw_init.h"
12 #include "fsw_init.h"
13
13
14 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0;
15 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f0_aux_f1;
16 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f1;
17 unsigned int nb_sm_f0_aux_f2;
17 unsigned int nb_sm_f0_aux_f2;
18
18
19 //************************
19 //************************
20 // spectral matrices rings
20 // spectral matrices rings
21 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
22 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
23 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
24 ring_node *current_ring_node_sm_f0;
24 ring_node *current_ring_node_sm_f0;
25 ring_node *current_ring_node_sm_f1;
25 ring_node *current_ring_node_sm_f1;
26 ring_node *current_ring_node_sm_f2;
26 ring_node *current_ring_node_sm_f2;
27 ring_node *ring_node_for_averaging_sm_f0;
27 ring_node *ring_node_for_averaging_sm_f0;
28 ring_node *ring_node_for_averaging_sm_f1;
28 ring_node *ring_node_for_averaging_sm_f1;
29 ring_node *ring_node_for_averaging_sm_f2;
29 ring_node *ring_node_for_averaging_sm_f2;
30
30
31 //
31 //
32 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
32 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
33 {
33 {
34 ring_node *node;
34 ring_node *node;
35
35
36 node = NULL;
36 node = NULL;
37 switch ( frequencyChannel ) {
37 switch ( frequencyChannel ) {
38 case 0:
38 case 0:
39 node = ring_node_for_averaging_sm_f0;
39 node = ring_node_for_averaging_sm_f0;
40 break;
40 break;
41 case 1:
41 case 1:
42 node = ring_node_for_averaging_sm_f1;
42 node = ring_node_for_averaging_sm_f1;
43 break;
43 break;
44 case 2:
44 case 2:
45 node = ring_node_for_averaging_sm_f2;
45 node = ring_node_for_averaging_sm_f2;
46 break;
46 break;
47 default:
47 default:
48 break;
48 break;
49 }
49 }
50
50
51 return node;
51 return node;
52 }
52 }
53
53
54 //***********************************************************
54 //***********************************************************
55 // Interrupt Service Routine for spectral matrices processing
55 // Interrupt Service Routine for spectral matrices processing
56
56
57 void spectral_matrices_isr_f0( unsigned char statusReg )
57 void spectral_matrices_isr_f0( unsigned char statusReg )
58 {
58 {
59 unsigned char status;
59 unsigned char status;
60 rtems_status_code status_code;
60 rtems_status_code status_code;
61 ring_node *full_ring_node;
61 ring_node *full_ring_node;
62
62
63 status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits
63 status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits
64
64
65 switch(status)
65 switch(status)
66 {
66 {
67 case 0:
67 case 0:
68 break;
68 break;
69 case 3:
69 case 3:
70 // UNEXPECTED VALUE
70 // UNEXPECTED VALUE
71 spectral_matrix_regs->status = 0x03; // [0011]
71 spectral_matrix_regs->status = 0x03; // [0011]
72 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
72 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
73 break;
73 break;
74 case 1:
74 case 1:
75 full_ring_node = current_ring_node_sm_f0->previous;
75 full_ring_node = current_ring_node_sm_f0->previous;
76 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
76 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
77 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
77 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
78 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
78 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
79 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
79 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
80 // if there are enough ring nodes ready, wake up an AVFx task
80 // if there are enough ring nodes ready, wake up an AVFx task
81 nb_sm_f0 = nb_sm_f0 + 1;
81 nb_sm_f0 = nb_sm_f0 + 1;
82 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
82 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
83 {
83 {
84 ring_node_for_averaging_sm_f0 = full_ring_node;
84 ring_node_for_averaging_sm_f0 = full_ring_node;
85 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
85 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
86 {
86 {
87 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
87 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
88 }
88 }
89 nb_sm_f0 = 0;
89 nb_sm_f0 = 0;
90 }
90 }
91 spectral_matrix_regs->status = 0x01; // [0000 0001]
91 spectral_matrix_regs->status = 0x01; // [0000 0001]
92 break;
92 break;
93 case 2:
93 case 2:
94 full_ring_node = current_ring_node_sm_f0->previous;
94 full_ring_node = current_ring_node_sm_f0->previous;
95 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
95 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
96 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
96 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
97 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
97 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
98 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
98 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
99 // if there are enough ring nodes ready, wake up an AVFx task
99 // if there are enough ring nodes ready, wake up an AVFx task
100 nb_sm_f0 = nb_sm_f0 + 1;
100 nb_sm_f0 = nb_sm_f0 + 1;
101 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
101 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
102 {
102 {
103 ring_node_for_averaging_sm_f0 = full_ring_node;
103 ring_node_for_averaging_sm_f0 = full_ring_node;
104 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
104 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
105 {
105 {
106 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
106 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
107 }
107 }
108 nb_sm_f0 = 0;
108 nb_sm_f0 = 0;
109 }
109 }
110 spectral_matrix_regs->status = 0x02; // [0000 0010]
110 spectral_matrix_regs->status = 0x02; // [0000 0010]
111 break;
111 break;
112 }
112 }
113 }
113 }
114
114
115 void spectral_matrices_isr_f1( unsigned char statusReg )
115 void spectral_matrices_isr_f1( unsigned char statusReg )
116 {
116 {
117 rtems_status_code status_code;
117 rtems_status_code status_code;
118 unsigned char status;
118 unsigned char status;
119 ring_node *full_ring_node;
119 ring_node *full_ring_node;
120
120
121 status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
121 status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
122
122
123 switch(status)
123 switch(status)
124 {
124 {
125 case 0:
125 case 0:
126 break;
126 break;
127 case 3:
127 case 3:
128 // UNEXPECTED VALUE
128 // UNEXPECTED VALUE
129 spectral_matrix_regs->status = 0xc0; // [1100]
129 spectral_matrix_regs->status = 0xc0; // [1100]
130 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
130 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
131 break;
131 break;
132 case 1:
132 case 1:
133 full_ring_node = current_ring_node_sm_f1->previous;
133 full_ring_node = current_ring_node_sm_f1->previous;
134 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
134 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
135 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
135 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
136 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
136 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
137 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
137 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
138 // if there are enough ring nodes ready, wake up an AVFx task
138 // if there are enough ring nodes ready, wake up an AVFx task
139 nb_sm_f1 = nb_sm_f1 + 1;
139 nb_sm_f1 = nb_sm_f1 + 1;
140 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
140 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
141 {
141 {
142 ring_node_for_averaging_sm_f1 = full_ring_node;
142 ring_node_for_averaging_sm_f1 = full_ring_node;
143 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
143 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
144 {
144 {
145 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
145 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
146 }
146 }
147 nb_sm_f1 = 0;
147 nb_sm_f1 = 0;
148 }
148 }
149 spectral_matrix_regs->status = 0x04; // [0000 0100]
149 spectral_matrix_regs->status = 0x04; // [0000 0100]
150 break;
150 break;
151 case 2:
151 case 2:
152 full_ring_node = current_ring_node_sm_f1->previous;
152 full_ring_node = current_ring_node_sm_f1->previous;
153 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
153 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
154 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
154 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
155 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
155 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
156 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
156 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
157 // if there are enough ring nodes ready, wake up an AVFx task
157 // if there are enough ring nodes ready, wake up an AVFx task
158 nb_sm_f1 = nb_sm_f1 + 1;
158 nb_sm_f1 = nb_sm_f1 + 1;
159 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
159 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
160 {
160 {
161 ring_node_for_averaging_sm_f1 = full_ring_node;
161 ring_node_for_averaging_sm_f1 = full_ring_node;
162 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
162 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
163 {
163 {
164 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
164 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
165 }
165 }
166 nb_sm_f1 = 0;
166 nb_sm_f1 = 0;
167 }
167 }
168 spectral_matrix_regs->status = 0x08; // [1000 0000]
168 spectral_matrix_regs->status = 0x08; // [1000 0000]
169 break;
169 break;
170 }
170 }
171 }
171 }
172
172
173 void spectral_matrices_isr_f2( unsigned char statusReg )
173 void spectral_matrices_isr_f2( unsigned char statusReg )
174 {
174 {
175 unsigned char status;
175 unsigned char status;
176 rtems_status_code status_code;
176 rtems_status_code status_code;
177
177
178 status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
178 status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
179
179
180 switch(status)
180 switch(status)
181 {
181 {
182 case 0:
182 case 0:
183 break;
183 break;
184 case 3:
184 case 3:
185 // UNEXPECTED VALUE
185 // UNEXPECTED VALUE
186 spectral_matrix_regs->status = 0x30; // [0011 0000]
186 spectral_matrix_regs->status = 0x30; // [0011 0000]
187 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
187 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
188 break;
188 break;
189 case 1:
189 case 1:
190 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
190 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
191 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
191 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
192 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
192 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
193 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
193 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
194 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
194 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
195 spectral_matrix_regs->status = 0x10; // [0001 0000]
195 spectral_matrix_regs->status = 0x10; // [0001 0000]
196 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
196 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
197 {
197 {
198 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
198 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
199 }
199 }
200 break;
200 break;
201 case 2:
201 case 2:
202 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
202 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
203 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
203 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
204 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
204 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
205 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
205 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
206 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
206 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
207 spectral_matrix_regs->status = 0x20; // [0010 0000]
207 spectral_matrix_regs->status = 0x20; // [0010 0000]
208 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
208 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
209 {
209 {
210 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
210 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
211 }
211 }
212 break;
212 break;
213 }
213 }
214 }
214 }
215
215
216 void spectral_matrix_isr_error_handler( unsigned char statusReg )
216 void spectral_matrix_isr_error_handler( unsigned char statusReg )
217 {
217 {
218 rtems_status_code status_code;
218 rtems_status_code status_code;
219
219
220 if (statusReg & 0x7c0) // [0111 1100 0000]
220 if (statusReg & 0x7c0) // [0111 1100 0000]
221 {
221 {
222 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
222 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
223 }
223 }
224
224
225 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
225 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
226 }
226 }
227
227
228 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
228 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
229 {
229 {
230 // STATUS REGISTER
230 // STATUS REGISTER
231 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
231 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
232 // 10 9 8
232 // 10 9 8
233 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
233 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
234 // 7 6 5 4 3 2 1 0
234 // 7 6 5 4 3 2 1 0
235
235
236 unsigned char statusReg;
236 unsigned char statusReg;
237
237
238 statusReg = spectral_matrix_regs->status;
238 statusReg = spectral_matrix_regs->status;
239
239
240 spectral_matrices_isr_f0( statusReg );
240 spectral_matrices_isr_f0( statusReg );
241
241
242 spectral_matrices_isr_f1( statusReg );
242 spectral_matrices_isr_f1( statusReg );
243
243
244 spectral_matrices_isr_f2( statusReg );
244 spectral_matrices_isr_f2( statusReg );
245
245
246 spectral_matrix_isr_error_handler( statusReg );
246 spectral_matrix_isr_error_handler( statusReg );
247 }
247 }
248
248
249 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
249 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
250 {
250 {
251 rtems_status_code status_code;
251 rtems_status_code status_code;
252
252
253 //***
253 //***
254 // F0
254 // F0
255 nb_sm_f0 = nb_sm_f0 + 1;
255 nb_sm_f0 = nb_sm_f0 + 1;
256 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
256 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
257 {
257 {
258 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
258 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
259 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
259 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
260 {
260 {
261 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
261 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
262 }
262 }
263 nb_sm_f0 = 0;
263 nb_sm_f0 = 0;
264 }
264 }
265
265
266 //***
266 //***
267 // F1
267 // F1
268 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
268 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
269 if (nb_sm_f0_aux_f1 == 6)
269 if (nb_sm_f0_aux_f1 == 6)
270 {
270 {
271 nb_sm_f0_aux_f1 = 0;
271 nb_sm_f0_aux_f1 = 0;
272 nb_sm_f1 = nb_sm_f1 + 1;
272 nb_sm_f1 = nb_sm_f1 + 1;
273 }
273 }
274 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
274 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
275 {
275 {
276 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
276 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
277 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
277 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
278 {
278 {
279 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
279 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
280 }
280 }
281 nb_sm_f1 = 0;
281 nb_sm_f1 = 0;
282 }
282 }
283
283
284 //***
284 //***
285 // F2
285 // F2
286 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
286 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
287 if (nb_sm_f0_aux_f2 == 96)
287 if (nb_sm_f0_aux_f2 == 96)
288 {
288 {
289 nb_sm_f0_aux_f2 = 0;
289 nb_sm_f0_aux_f2 = 0;
290 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
290 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
291 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
291 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
292 {
292 {
293 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
293 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
294 }
294 }
295 }
295 }
296 }
296 }
297
297
298 //******************
298 //******************
299 // Spectral Matrices
299 // Spectral Matrices
300
300
301 void reset_nb_sm( void )
301 void reset_nb_sm( void )
302 {
302 {
303 nb_sm_f0 = 0;
303 nb_sm_f0 = 0;
304 nb_sm_f0_aux_f1 = 0;
304 nb_sm_f0_aux_f1 = 0;
305 nb_sm_f0_aux_f2 = 0;
305 nb_sm_f0_aux_f2 = 0;
306
306
307 nb_sm_f1 = 0;
307 nb_sm_f1 = 0;
308 }
308 }
309
309
310 void SM_init_rings( void )
310 void SM_init_rings( void )
311 {
311 {
312 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
312 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
313 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
313 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
314 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
314 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
315
315
316 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
316 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
317 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
317 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
318 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
318 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
319 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
319 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
320 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
320 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
321 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
321 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
322 }
322 }
323
323
324 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
324 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
325 {
325 {
326 unsigned char i;
326 unsigned char i;
327
327
328 ring[ nbNodes - 1 ].next
328 ring[ nbNodes - 1 ].next
329 = (ring_node_asm*) &ring[ 0 ];
329 = (ring_node_asm*) &ring[ 0 ];
330
330
331 for(i=0; i<nbNodes-1; i++)
331 for(i=0; i<nbNodes-1; i++)
332 {
332 {
333 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
333 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
334 }
334 }
335 }
335 }
336
336
337 void SM_reset_current_ring_nodes( void )
337 void SM_reset_current_ring_nodes( void )
338 {
338 {
339 current_ring_node_sm_f0 = sm_ring_f0[0].next;
339 current_ring_node_sm_f0 = sm_ring_f0[0].next;
340 current_ring_node_sm_f1 = sm_ring_f1[0].next;
340 current_ring_node_sm_f1 = sm_ring_f1[0].next;
341 current_ring_node_sm_f2 = sm_ring_f2[0].next;
341 current_ring_node_sm_f2 = sm_ring_f2[0].next;
342
342
343 ring_node_for_averaging_sm_f0 = NULL;
343 ring_node_for_averaging_sm_f0 = NULL;
344 ring_node_for_averaging_sm_f1 = NULL;
344 ring_node_for_averaging_sm_f1 = NULL;
345 ring_node_for_averaging_sm_f2 = NULL;
345 ring_node_for_averaging_sm_f2 = NULL;
346 }
346 }
347
347
348 //*****************
348 //*****************
349 // Basic Parameters
349 // Basic Parameters
350
350
351 void BP_init_header( bp_packet *packet,
351 void BP_init_header( bp_packet *packet,
352 unsigned int apid, unsigned char sid,
352 unsigned int apid, unsigned char sid,
353 unsigned int packetLength, unsigned char blkNr )
353 unsigned int packetLength, unsigned char blkNr )
354 {
354 {
355 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
355 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
356 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
356 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
357 packet->reserved = 0x00;
357 packet->reserved = 0x00;
358 packet->userApplication = CCSDS_USER_APP;
358 packet->userApplication = CCSDS_USER_APP;
359 packet->packetID[0] = (unsigned char) (apid >> 8);
359 packet->packetID[0] = (unsigned char) (apid >> 8);
360 packet->packetID[1] = (unsigned char) (apid);
360 packet->packetID[1] = (unsigned char) (apid);
361 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
361 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
362 packet->packetSequenceControl[1] = 0x00;
362 packet->packetSequenceControl[1] = 0x00;
363 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
363 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
364 packet->packetLength[1] = (unsigned char) (packetLength);
364 packet->packetLength[1] = (unsigned char) (packetLength);
365 // DATA FIELD HEADER
365 // DATA FIELD HEADER
366 packet->spare1_pusVersion_spare2 = 0x10;
366 packet->spare1_pusVersion_spare2 = 0x10;
367 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
367 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
368 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
368 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
369 packet->destinationID = TM_DESTINATION_ID_GROUND;
369 packet->destinationID = TM_DESTINATION_ID_GROUND;
370 packet->time[0] = 0x00;
370 packet->time[0] = 0x00;
371 packet->time[1] = 0x00;
371 packet->time[1] = 0x00;
372 packet->time[2] = 0x00;
372 packet->time[2] = 0x00;
373 packet->time[3] = 0x00;
373 packet->time[3] = 0x00;
374 packet->time[4] = 0x00;
374 packet->time[4] = 0x00;
375 packet->time[5] = 0x00;
375 packet->time[5] = 0x00;
376 // AUXILIARY DATA HEADER
376 // AUXILIARY DATA HEADER
377 packet->sid = sid;
377 packet->sid = sid;
378 packet->biaStatusInfo = 0x00;
378 packet->biaStatusInfo = 0x00;
379 packet->sy_lfr_common_parameters_spare = 0x00;
379 packet->sy_lfr_common_parameters_spare = 0x00;
380 packet->sy_lfr_common_parameters = 0x00;
380 packet->sy_lfr_common_parameters = 0x00;
381 packet->acquisitionTime[0] = 0x00;
381 packet->acquisitionTime[0] = 0x00;
382 packet->acquisitionTime[1] = 0x00;
382 packet->acquisitionTime[1] = 0x00;
383 packet->acquisitionTime[2] = 0x00;
383 packet->acquisitionTime[2] = 0x00;
384 packet->acquisitionTime[3] = 0x00;
384 packet->acquisitionTime[3] = 0x00;
385 packet->acquisitionTime[4] = 0x00;
385 packet->acquisitionTime[4] = 0x00;
386 packet->acquisitionTime[5] = 0x00;
386 packet->acquisitionTime[5] = 0x00;
387 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
387 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
388 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
388 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
389 }
389 }
390
390
391 void BP_init_header_with_spare( bp_packet_with_spare *packet,
391 void BP_init_header_with_spare( bp_packet_with_spare *packet,
392 unsigned int apid, unsigned char sid,
392 unsigned int apid, unsigned char sid,
393 unsigned int packetLength , unsigned char blkNr)
393 unsigned int packetLength , unsigned char blkNr)
394 {
394 {
395 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
395 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
396 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
396 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
397 packet->reserved = 0x00;
397 packet->reserved = 0x00;
398 packet->userApplication = CCSDS_USER_APP;
398 packet->userApplication = CCSDS_USER_APP;
399 packet->packetID[0] = (unsigned char) (apid >> 8);
399 packet->packetID[0] = (unsigned char) (apid >> 8);
400 packet->packetID[1] = (unsigned char) (apid);
400 packet->packetID[1] = (unsigned char) (apid);
401 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
401 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
402 packet->packetSequenceControl[1] = 0x00;
402 packet->packetSequenceControl[1] = 0x00;
403 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
403 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
404 packet->packetLength[1] = (unsigned char) (packetLength);
404 packet->packetLength[1] = (unsigned char) (packetLength);
405 // DATA FIELD HEADER
405 // DATA FIELD HEADER
406 packet->spare1_pusVersion_spare2 = 0x10;
406 packet->spare1_pusVersion_spare2 = 0x10;
407 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
407 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
408 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
408 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
409 packet->destinationID = TM_DESTINATION_ID_GROUND;
409 packet->destinationID = TM_DESTINATION_ID_GROUND;
410 // AUXILIARY DATA HEADER
410 // AUXILIARY DATA HEADER
411 packet->sid = sid;
411 packet->sid = sid;
412 packet->biaStatusInfo = 0x00;
412 packet->biaStatusInfo = 0x00;
413 packet->sy_lfr_common_parameters_spare = 0x00;
413 packet->sy_lfr_common_parameters_spare = 0x00;
414 packet->sy_lfr_common_parameters = 0x00;
414 packet->sy_lfr_common_parameters = 0x00;
415 packet->time[0] = 0x00;
415 packet->time[0] = 0x00;
416 packet->time[0] = 0x00;
416 packet->time[0] = 0x00;
417 packet->time[0] = 0x00;
417 packet->time[0] = 0x00;
418 packet->time[0] = 0x00;
418 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
421 packet->source_data_spare = 0x00;
421 packet->source_data_spare = 0x00;
422 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
422 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
423 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
423 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
424 }
424 }
425
425
426 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
426 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
427 {
427 {
428 rtems_status_code status;
428 rtems_status_code status;
429
429
430 // SEND PACKET
430 // SEND PACKET
431 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
431 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
432 if (status != RTEMS_SUCCESSFUL)
432 if (status != RTEMS_SUCCESSFUL)
433 {
433 {
434 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
434 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
435 }
435 }
436 }
436 }
437
437
438 //******************
438 //******************
439 // general functions
439 // general functions
440
440
441 void reset_sm_status( void )
441 void reset_sm_status( void )
442 {
442 {
443 // error
443 // error
444 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
444 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
445 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
445 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
446 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
446 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
447 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
447 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
448
448
449 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
449 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
450 }
450 }
451
451
452 void reset_spectral_matrix_regs( void )
452 void reset_spectral_matrix_regs( void )
453 {
453 {
454 /** This function resets the spectral matrices module registers.
454 /** This function resets the spectral matrices module registers.
455 *
455 *
456 * The registers affected by this function are located at the following offset addresses:
456 * The registers affected by this function are located at the following offset addresses:
457 *
457 *
458 * - 0x00 config
458 * - 0x00 config
459 * - 0x04 status
459 * - 0x04 status
460 * - 0x08 matrixF0_Address0
460 * - 0x08 matrixF0_Address0
461 * - 0x10 matrixFO_Address1
461 * - 0x10 matrixFO_Address1
462 * - 0x14 matrixF1_Address
462 * - 0x14 matrixF1_Address
463 * - 0x18 matrixF2_Address
463 * - 0x18 matrixF2_Address
464 *
464 *
465 */
465 */
466
466
467 set_sm_irq_onError( 0 );
467 set_sm_irq_onError( 0 );
468
468
469 set_sm_irq_onNewMatrix( 0 );
469 set_sm_irq_onNewMatrix( 0 );
470
470
471 reset_sm_status();
471 reset_sm_status();
472
472
473 // F1
473 // F1
474 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
474 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
475 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
475 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
476 // F2
476 // F2
477 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
477 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
478 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
478 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
479 // F3
479 // F3
480 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
480 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
481 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
481 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
482
482
483 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
483 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
484 }
484 }
485
485
486 void set_time( unsigned char *time, unsigned char * timeInBuffer )
486 void set_time( unsigned char *time, unsigned char * timeInBuffer )
487 {
487 {
488 time[0] = timeInBuffer[0];
488 time[0] = timeInBuffer[0];
489 time[1] = timeInBuffer[1];
489 time[1] = timeInBuffer[1];
490 time[2] = timeInBuffer[2];
490 time[2] = timeInBuffer[2];
491 time[3] = timeInBuffer[3];
491 time[3] = timeInBuffer[3];
492 time[4] = timeInBuffer[6];
492 time[4] = timeInBuffer[6];
493 time[5] = timeInBuffer[7];
493 time[5] = timeInBuffer[7];
494 }
494 }
495
495
496 unsigned long long int get_acquisition_time( unsigned char *timePtr )
496 unsigned long long int get_acquisition_time( unsigned char *timePtr )
497 {
497 {
498 unsigned long long int acquisitionTimeAslong;
498 unsigned long long int acquisitionTimeAslong;
499 acquisitionTimeAslong = 0x00;
499 acquisitionTimeAslong = 0x00;
500 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
500 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
501 + ( (unsigned long long int) timePtr[1] << 32 )
501 + ( (unsigned long long int) timePtr[1] << 32 )
502 + ( (unsigned long long int) timePtr[2] << 24 )
502 + ( (unsigned long long int) timePtr[2] << 24 )
503 + ( (unsigned long long int) timePtr[3] << 16 )
503 + ( (unsigned long long int) timePtr[3] << 16 )
504 + ( (unsigned long long int) timePtr[6] << 8 )
504 + ( (unsigned long long int) timePtr[6] << 8 )
505 + ( (unsigned long long int) timePtr[7] );
505 + ( (unsigned long long int) timePtr[7] );
506 return acquisitionTimeAslong;
506 return acquisitionTimeAslong;
507 }
507 }
508
508
509 unsigned char getSID( rtems_event_set event )
509 unsigned char getSID( rtems_event_set event )
510 {
510 {
511 unsigned char sid;
511 unsigned char sid;
512
512
513 rtems_event_set eventSetBURST;
513 rtems_event_set eventSetBURST;
514 rtems_event_set eventSetSBM;
514 rtems_event_set eventSetSBM;
515
515
516 //******
516 //******
517 // BURST
517 // BURST
518 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
518 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
519 | RTEMS_EVENT_BURST_BP1_F1
519 | RTEMS_EVENT_BURST_BP1_F1
520 | RTEMS_EVENT_BURST_BP2_F0
520 | RTEMS_EVENT_BURST_BP2_F0
521 | RTEMS_EVENT_BURST_BP2_F1;
521 | RTEMS_EVENT_BURST_BP2_F1;
522
522
523 //****
523 //****
524 // SBM
524 // SBM
525 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
525 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
526 | RTEMS_EVENT_SBM_BP1_F1
526 | RTEMS_EVENT_SBM_BP1_F1
527 | RTEMS_EVENT_SBM_BP2_F0
527 | RTEMS_EVENT_SBM_BP2_F0
528 | RTEMS_EVENT_SBM_BP2_F1;
528 | RTEMS_EVENT_SBM_BP2_F1;
529
529
530 if (event & eventSetBURST)
530 if (event & eventSetBURST)
531 {
531 {
532 sid = SID_BURST_BP1_F0;
532 sid = SID_BURST_BP1_F0;
533 }
533 }
534 else if (event & eventSetSBM)
534 else if (event & eventSetSBM)
535 {
535 {
536 sid = SID_SBM1_BP1_F0;
536 sid = SID_SBM1_BP1_F0;
537 }
537 }
538 else
538 else
539 {
539 {
540 sid = 0;
540 sid = 0;
541 }
541 }
542
542
543 return sid;
543 return sid;
544 }
544 }
545
545
546 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
546 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
547 {
547 {
548 unsigned int i;
548 unsigned int i;
549 float re;
549 float re;
550 float im;
550 float im;
551
551
552 for (i=0; i<NB_BINS_PER_SM; i++){
552 for (i=0; i<NB_BINS_PER_SM; i++){
553 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
553 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
554 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
554 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
555 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
555 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
556 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
556 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
557 }
557 }
558 }
558 }
559
559
560 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
560 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
561 {
561 {
562 unsigned int i;
562 unsigned int i;
563 float re;
563 float re;
564
564
565 for (i=0; i<NB_BINS_PER_SM; i++){
565 for (i=0; i<NB_BINS_PER_SM; i++){
566 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
566 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
567 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
567 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
568 }
568 }
569 }
569 }
570
570
571 void ASM_patch( float *inputASM, float *outputASM )
571 void ASM_patch( float *inputASM, float *outputASM )
572 {
572 {
573 extractReImVectors( inputASM, outputASM, 1); // b1b2
573 extractReImVectors( inputASM, outputASM, 1); // b1b2
574 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
574 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
575 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
575 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
576 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
576 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
577 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
577 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
578 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
578 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
579 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
579 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
580 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
580 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
581 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
581 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
582 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
582 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
583
583
584 copyReVectors(inputASM, outputASM, 0 ); // b1b1
584 copyReVectors(inputASM, outputASM, 0 ); // b1b1
585 copyReVectors(inputASM, outputASM, 9 ); // b2b2
585 copyReVectors(inputASM, outputASM, 9 ); // b2b2
586 copyReVectors(inputASM, outputASM, 16); // b3b3
586 copyReVectors(inputASM, outputASM, 16); // b3b3
587 copyReVectors(inputASM, outputASM, 21); // e1e1
587 copyReVectors(inputASM, outputASM, 21); // e1e1
588 copyReVectors(inputASM, outputASM, 24); // e2e2
588 copyReVectors(inputASM, outputASM, 24); // e2e2
589 }
589 }
590
590
591 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
591 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
592 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
592 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage,
593 unsigned char ASMIndexStart,
594 unsigned char channel )
593 {
595 {
594 //*************
596 //*************
595 // input format
597 // input format
596 // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127]
598 // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127]
597 //**************
599 //**************
598 // output format
600 // output format
599 // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24]
601 // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24]
600 //************
602 //************
601 // compression
603 // compression
602 // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM
604 // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM
603 // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM
605 // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM
604
606
605 int frequencyBin;
607 int frequencyBin;
606 int asmComponent;
608 int asmComponent;
607 int offsetASM;
609 int offsetASM;
608 int offsetCompressed;
610 int offsetCompressed;
609 int offsetFBin;
611 int offsetFBin;
610 int fBinMask;
612 int fBinMask;
611 int k;
613 int k;
612
614
613 // BUILD DATA
615 // BUILD DATA
614 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
616 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
615 {
617 {
616 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
618 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
617 {
619 {
618 offsetCompressed = // NO TIME OFFSET
620 offsetCompressed = // NO TIME OFFSET
619 frequencyBin * NB_VALUES_PER_SM
621 frequencyBin * NB_VALUES_PER_SM
620 + asmComponent;
622 + asmComponent;
621 offsetASM = // NO TIME OFFSET
623 offsetASM = // NO TIME OFFSET
622 asmComponent * NB_BINS_PER_SM
624 asmComponent * NB_BINS_PER_SM
623 + ASMIndexStart
625 + ASMIndexStart
624 + frequencyBin * nbBinsToAverage;
626 + frequencyBin * nbBinsToAverage;
625 offsetFBin = ASMIndexStart
627 offsetFBin = ASMIndexStart
626 + frequencyBin * nbBinsToAverage;
628 + frequencyBin * nbBinsToAverage;
627 compressed_spec_mat[ offsetCompressed ] = 0;
629 compressed_spec_mat[ offsetCompressed ] = 0;
628 for ( k = 0; k < nbBinsToAverage; k++ )
630 for ( k = 0; k < nbBinsToAverage; k++ )
629 {
631 {
630 fBinMask = getFBinMask( offsetFBin + k );
632 fBinMask = getFBinMask( offsetFBin + k, channel );
631 compressed_spec_mat[offsetCompressed ] =
633 compressed_spec_mat[offsetCompressed ] =
632 ( compressed_spec_mat[ offsetCompressed ]
634 ( compressed_spec_mat[ offsetCompressed ]
633 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
635 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
634 }
636 }
635 compressed_spec_mat[ offsetCompressed ] =
637 compressed_spec_mat[ offsetCompressed ] =
636 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
638 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
637 }
639 }
638 }
640 }
639
641
640 }
642 }
641
643
642 int getFBinMask( int index )
644 int getFBinMask( int index, unsigned char channel )
643 {
645 {
644 unsigned int indexInChar;
646 unsigned int indexInChar;
645 unsigned int indexInTheChar;
647 unsigned int indexInTheChar;
646 int fbin;
648 int fbin;
649 unsigned char *sy_lfr_fbins_fx_word1;
650
651 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
652
653 switch(channel)
654 {
655 case 0:
656 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
657 break;
658 case 1:
659 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
660 break;
661 case 2:
662 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
663 break;
664 default:
665 PRINTF("ERR *** in getFBinMask, wrong frequency channel")
666 }
647
667
648 indexInChar = index >> 3;
668 indexInChar = index >> 3;
649 indexInTheChar = index - indexInChar * 8;
669 indexInTheChar = index - indexInChar * 8;
650
670
651 fbin = (int) ((parameter_dump_packet.sy_lfr_fbins_f0_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
671 fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
652
672
653 return fbin;
673 return fbin;
654 }
674 }
655
675
656 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
676 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
657 {
677 {
658 unsigned char bin;
678 unsigned char bin;
659 unsigned char kcoeff;
679 unsigned char kcoeff;
660
680
661 for (bin=0; bin<nb_bins_norm; bin++)
681 for (bin=0; bin<nb_bins_norm; bin++)
662 {
682 {
663 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
683 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
664 {
684 {
665 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
685 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
666 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
686 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
667 }
687 }
668 }
688 }
669 }
689 }
General Comments 0
You need to be logged in to leave comments. Login now