##// END OF EJS Templates
Integration of basic parameters functions in the flight software...
paul -
r179:f0fdfd2b8c4c VHDL_0_1_28
parent child
Show More
@@ -0,0 +1,191
1 # This file was generated by an application wizard of Qt Creator.
2 # The code below handles deployment to Android and Maemo, aswell as copying
3 # of the application data to shadow build directories on desktop.
4 # It is recommended not to modify this file, since newer versions of Qt Creator
5 # may offer an updated version of it.
6
7 defineTest(qtcAddDeployment) {
8 for(deploymentfolder, DEPLOYMENTFOLDERS) {
9 item = item$${deploymentfolder}
10 greaterThan(QT_MAJOR_VERSION, 4) {
11 itemsources = $${item}.files
12 } else {
13 itemsources = $${item}.sources
14 }
15 $$itemsources = $$eval($${deploymentfolder}.source)
16 itempath = $${item}.path
17 $$itempath= $$eval($${deploymentfolder}.target)
18 export($$itemsources)
19 export($$itempath)
20 DEPLOYMENT += $$item
21 }
22
23 MAINPROFILEPWD = $$PWD
24
25 android-no-sdk {
26 for(deploymentfolder, DEPLOYMENTFOLDERS) {
27 item = item$${deploymentfolder}
28 itemfiles = $${item}.files
29 $$itemfiles = $$eval($${deploymentfolder}.source)
30 itempath = $${item}.path
31 $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target)
32 export($$itemfiles)
33 export($$itempath)
34 INSTALLS += $$item
35 }
36
37 target.path = /data/user/qt
38
39 export(target.path)
40 INSTALLS += target
41 } else:android {
42 for(deploymentfolder, DEPLOYMENTFOLDERS) {
43 item = item$${deploymentfolder}
44 itemfiles = $${item}.files
45 $$itemfiles = $$eval($${deploymentfolder}.source)
46 itempath = $${item}.path
47 $$itempath = /assets/$$eval($${deploymentfolder}.target)
48 export($$itemfiles)
49 export($$itempath)
50 INSTALLS += $$item
51 }
52
53 x86 {
54 target.path = /libs/x86
55 } else: armeabi-v7a {
56 target.path = /libs/armeabi-v7a
57 } else {
58 target.path = /libs/armeabi
59 }
60
61 export(target.path)
62 INSTALLS += target
63 } else:win32 {
64 copyCommand =
65 for(deploymentfolder, DEPLOYMENTFOLDERS) {
66 source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
67 source = $$replace(source, /, \\)
68 sourcePathSegments = $$split(source, \\)
69 target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
70 target = $$replace(target, /, \\)
71 target ~= s,\\\\\\.?\\\\,\\,
72 !isEqual(source,$$target) {
73 !isEmpty(copyCommand):copyCommand += &&
74 isEqual(QMAKE_DIR_SEP, \\) {
75 copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
76 } else {
77 source = $$replace(source, \\\\, /)
78 target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
79 target = $$replace(target, \\\\, /)
80 copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
81 }
82 }
83 }
84 !isEmpty(copyCommand) {
85 copyCommand = @echo Copying application data... && $$copyCommand
86 copydeploymentfolders.commands = $$copyCommand
87 first.depends = $(first) copydeploymentfolders
88 export(first.depends)
89 export(copydeploymentfolders.commands)
90 QMAKE_EXTRA_TARGETS += first copydeploymentfolders
91 }
92 } else:ios {
93 copyCommand =
94 for(deploymentfolder, DEPLOYMENTFOLDERS) {
95 source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
96 source = $$replace(source, \\\\, /)
97 target = $CODESIGNING_FOLDER_PATH/$$eval($${deploymentfolder}.target)
98 target = $$replace(target, \\\\, /)
99 sourcePathSegments = $$split(source, /)
100 targetFullPath = $$target/$$last(sourcePathSegments)
101 targetFullPath ~= s,/\\.?/,/,
102 !isEqual(source,$$targetFullPath) {
103 !isEmpty(copyCommand):copyCommand += &&
104 copyCommand += mkdir -p \"$$target\"
105 copyCommand += && cp -r \"$$source\" \"$$target\"
106 }
107 }
108 !isEmpty(copyCommand) {
109 copyCommand = echo Copying application data... && $$copyCommand
110 !isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
111 QMAKE_POST_LINK += "$$copyCommand"
112 export(QMAKE_POST_LINK)
113 }
114 } else:unix {
115 maemo5 {
116 desktopfile.files = $${TARGET}.desktop
117 desktopfile.path = /usr/share/applications/hildon
118 icon.files = $${TARGET}64.png
119 icon.path = /usr/share/icons/hicolor/64x64/apps
120 } else:!isEmpty(MEEGO_VERSION_MAJOR) {
121 desktopfile.files = $${TARGET}_harmattan.desktop
122 desktopfile.path = /usr/share/applications
123 icon.files = $${TARGET}80.png
124 icon.path = /usr/share/icons/hicolor/80x80/apps
125 } else { # Assumed to be a Desktop Unix
126 copyCommand =
127 for(deploymentfolder, DEPLOYMENTFOLDERS) {
128 source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
129 source = $$replace(source, \\\\, /)
130 macx {
131 target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
132 } else {
133 target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
134 }
135 target = $$replace(target, \\\\, /)
136 sourcePathSegments = $$split(source, /)
137 targetFullPath = $$target/$$last(sourcePathSegments)
138 targetFullPath ~= s,/\\.?/,/,
139 !isEqual(source,$$targetFullPath) {
140 !isEmpty(copyCommand):copyCommand += &&
141 copyCommand += $(MKDIR) \"$$target\"
142 copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
143 }
144 }
145 !isEmpty(copyCommand) {
146 copyCommand = @echo Copying application data... && $$copyCommand
147 copydeploymentfolders.commands = $$copyCommand
148 first.depends = $(first) copydeploymentfolders
149 export(first.depends)
150 export(copydeploymentfolders.commands)
151 QMAKE_EXTRA_TARGETS += first copydeploymentfolders
152 }
153 }
154 !isEmpty(target.path) {
155 installPrefix = $${target.path}
156 } else {
157 installPrefix = /opt/$${TARGET}
158 }
159 for(deploymentfolder, DEPLOYMENTFOLDERS) {
160 item = item$${deploymentfolder}
161 itemfiles = $${item}.files
162 $$itemfiles = $$eval($${deploymentfolder}.source)
163 itempath = $${item}.path
164 $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
165 export($$itemfiles)
166 export($$itempath)
167 INSTALLS += $$item
168 }
169
170 !isEmpty(desktopfile.path) {
171 export(icon.files)
172 export(icon.path)
173 export(desktopfile.files)
174 export(desktopfile.path)
175 INSTALLS += icon desktopfile
176 }
177
178 isEmpty(target.path) {
179 target.path = $${installPrefix}/bin
180 export(target.path)
181 }
182 INSTALLS += target
183 }
184
185 export (ICON)
186 export (INSTALLS)
187 export (DEPLOYMENT)
188 export (LIBS)
189 export (QMAKE_EXTRA_TARGETS)
190 }
191
@@ -0,0 +1,13
1 TEMPLATE = app
2 CONFIG += console
3 CONFIG -= app_bundle
4 CONFIG -= qt
5
6 SOURCES += main.c
7
8 include(deployment.pri)
9 qtcAddDeployment()
10
11 HEADERS += \
12 functions.h
13
@@ -0,0 +1,65
1 #define NB_VALUES_PER_SM 25
2 #define NB_BINS_PER_SM 128
3
4 #define NB_BINS_COMPRESSED_SM_F0 11
5 #define ASM_F0_INDICE_START 17 // 88 bins
6 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
7 #define NB_BINS_TO_AVERAGE_ASM_F0 8
8
9 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
10 {
11 int frequencyBin;
12 int asmComponent;
13 unsigned int offsetASM;
14 unsigned int offsetASMReorganized;
15
16 // BUILD DATA
17 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
18 {
19 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
20 {
21 offsetASMReorganized =
22 frequencyBin * NB_VALUES_PER_SM
23 + asmComponent;
24 offsetASM =
25 asmComponent * NB_BINS_PER_SM
26 + frequencyBin;
27 averaged_spec_mat_reorganized[offsetASMReorganized ] =
28 averaged_spec_mat[ offsetASM ] / divider;
29 }
30 }
31 }
32
33 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
34 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
35 {
36 int frequencyBin;
37 int asmComponent;
38 int offsetASM;
39 int offsetCompressed;
40 int k;
41
42 // BUILD DATA
43 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
44 {
45 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
46 {
47 offsetCompressed = // NO TIME OFFSET
48 frequencyBin * NB_VALUES_PER_SM
49 + asmComponent;
50 offsetASM = // NO TIME OFFSET
51 asmComponent * NB_BINS_PER_SM
52 + ASMIndexStart
53 + frequencyBin * nbBinsToAverage;
54 compressed_spec_mat[ offsetCompressed ] = 0;
55 for ( k = 0; k < nbBinsToAverage; k++ )
56 {
57 compressed_spec_mat[offsetCompressed ] =
58 ( compressed_spec_mat[ offsetCompressed ]
59 + averaged_spec_mat[ offsetASM + k ] );
60 }
61 compressed_spec_mat[ offsetCompressed ] =
62 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
63 }
64 }
65 }
@@ -0,0 +1,64
1 #include <stdio.h>
2
3 #include "functions.h"
4
5 int main(void)
6 {
7 printf("Hello World!\n");
8
9 unsigned int asmComponent;
10 unsigned int frequencyBin;
11 unsigned int offset_input_ASM;
12
13 float input_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
14 float output_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
15 float output_ASM_compressed [ NB_VALUES_PER_SM * NB_BINS_COMPRESSED_SM_F0 ];
16
17 //*******
18 // TEST 1
19
20 offset_input_ASM = 0;
21
22 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
23 {
24 for (frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++)
25 {
26 offset_input_ASM = asmComponent * NB_BINS_PER_SM + frequencyBin;
27 input_ASM[ offset_input_ASM ] = asmComponent;
28 }
29 }
30
31 ASM_reorganize_and_divide( input_ASM, output_ASM,
32 1 ); // divider
33
34 ASM_compress_reorganize_and_divide( input_ASM, output_ASM_compressed,
35 1, // divider
36 NB_BINS_COMPRESSED_SM_F0,
37 NB_BINS_TO_AVERAGE_ASM_F0,
38 ASM_F0_INDICE_START);
39
40 //*******
41 // TEST 2
42 offset_input_ASM = 0;
43
44 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
45 {
46 for (frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++)
47 {
48 offset_input_ASM = asmComponent * NB_BINS_PER_SM + frequencyBin;
49 input_ASM[ offset_input_ASM ] = asmComponent * NB_BINS_PER_SM + frequencyBin;
50 }
51 }
52
53 ASM_reorganize_and_divide( input_ASM, output_ASM,
54 1 ); // divider
55
56 ASM_compress_reorganize_and_divide( input_ASM, output_ASM_compressed,
57 10, // divider
58 NB_BINS_COMPRESSED_SM_F0,
59 NB_BINS_TO_AVERAGE_ASM_F0,
60 ASM_F0_INDICE_START);
61
62 return 0;
63 }
64
@@ -1,2 +1,2
1 19349b3a5e90c2bacc9d369aa948c68aa9e8d5f0 LFR_basic-parameters
1 a309a930a482e851061936696121f4a1cf7005de LFR_basic-parameters
2 da5613aff4446e5c98b3c56bc32ce7008b3e2340 header/lfr_common_headers
2 2b5dc338fb623046072d6eb98c26ad884e17f95e header/lfr_common_headers
@@ -12,7 +12,7 SWVERSION=-1-0
12 DEFINES += SW_VERSION_N1=2 # major
12 DEFINES += SW_VERSION_N1=2 # major
13 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N2=0 # minor
14 DEFINES += SW_VERSION_N3=2 # patch
14 DEFINES += SW_VERSION_N3=2 # patch
15 DEFINES += SW_VERSION_N4=0 # internal
15 DEFINES += SW_VERSION_N4=1 # internal
16
16
17 # <GCOV>
17 # <GCOV>
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
@@ -28,6 +28,7 contains( CONFIG, lpp_dpu_destid ) {
28 contains( CONFIG, debug_tch ) {
28 contains( CONFIG, debug_tch ) {
29 DEFINES += DEBUG_TCH
29 DEFINES += DEBUG_TCH
30 }
30 }
31 DEFINES += LSB_FIRST_TCH
31
32
32 contains( CONFIG, vhdl_dev ) {
33 contains( CONFIG, vhdl_dev ) {
33 DEFINES += VHDL_DEV
34 DEFINES += VHDL_DEV
@@ -64,7 +65,7 INCLUDEPATH += \
64 $${PWD}/../header \
65 $${PWD}/../header \
65 $${PWD}/../header/lfr_common_headers \
66 $${PWD}/../header/lfr_common_headers \
66 $${PWD}/../header/processing \
67 $${PWD}/../header/processing \
67 $${PWD}/../src/LFR_basic-parameters
68 $${PWD}/../LFR_basic-parameters
68
69
69 SOURCES += \
70 SOURCES += \
70 ../src/wf_handler.c \
71 ../src/wf_handler.c \
@@ -81,7 +82,7 SOURCES += \
81 ../src/processing/avf1_prc1.c \
82 ../src/processing/avf1_prc1.c \
82 ../src/processing/avf2_prc2.c \
83 ../src/processing/avf2_prc2.c \
83 ../src/lfr_cpu_usage_report.c \
84 ../src/lfr_cpu_usage_report.c \
84 ../src/LFR_basic-parameters/basic_parameters.c
85 ../LFR_basic-parameters/basic_parameters.c
85
86
86 HEADERS += \
87 HEADERS += \
87 ../header/wf_handler.h \
88 ../header/wf_handler.h \
@@ -99,12 +100,12 HEADERS += \
99 ../header/processing/avf2_prc2.h \
100 ../header/processing/avf2_prc2.h \
100 ../header/fsw_params_wf_handler.h \
101 ../header/fsw_params_wf_handler.h \
101 ../header/lfr_cpu_usage_report.h \
102 ../header/lfr_cpu_usage_report.h \
102 ../src/LFR_basic-parameters/basic_parameters.h \
103 ../src/LFR_basic-parameters/basic_parameters_params.h \
104 ../header/lfr_common_headers/ccsds_types.h \
103 ../header/lfr_common_headers/ccsds_types.h \
105 ../header/lfr_common_headers/fsw_params.h \
104 ../header/lfr_common_headers/fsw_params.h \
106 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
107 ../header/lfr_common_headers/fsw_params_processing.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
108 ../header/lfr_common_headers/TC_types.h \
107 ../header/lfr_common_headers/TC_types.h \
109 ../header/lfr_common_headers/tm_byte_positions.h
108 ../header/lfr_common_headers/tm_byte_positions.h \
109 ../LFR_basic-parameters/basic_parameters.h \
110 ../LFR_basic-parameters/basic_parameters_params.h
110
111
@@ -90,6 +90,10 typedef struct{
90 volatile unsigned int f3_1_fine_time; // 0x88
90 volatile unsigned int f3_1_fine_time; // 0x88
91 //
91 //
92 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
92 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
93 //
94 volatile unsigned int v; // 0x90
95 volatile unsigned int e1; // 0x94
96 volatile unsigned int e2; // 0x98
93 } waveform_picker_regs_0_1_18_t;
97 } waveform_picker_regs_0_1_18_t;
94
98
95 typedef struct {
99 typedef struct {
@@ -111,7 +115,7 typedef struct {
111 volatile unsigned int f1_0_coarse_time; // 0x30
115 volatile unsigned int f1_0_coarse_time; // 0x30
112 volatile unsigned int f1_0_fine_time; // 0x34
116 volatile unsigned int f1_0_fine_time; // 0x34
113 volatile unsigned int f1_1_coarse_time; // 0x38
117 volatile unsigned int f1_1_coarse_time; // 0x38
114 volatile unsigned int f1_1_time_time; // 0x3C
118 volatile unsigned int f1_1_fine_time; // 0x3C
115 //
119 //
116 volatile unsigned int f2_0_coarse_time; // 0x40
120 volatile unsigned int f2_0_coarse_time; // 0x40
117 volatile unsigned int f2_0_fine_time; // 0x44
121 volatile unsigned int f2_0_fine_time; // 0x44
@@ -27,10 +27,11 rtems_task prc0_task( rtems_task_argumen
27 // FUNCTIONS
27 // FUNCTIONS
28
28
29 void reset_nb_sm_f0( unsigned char lfrMode );
29 void reset_nb_sm_f0( unsigned char lfrMode );
30 void init_k_coefficients_f0( void );
31 void test_TCH( void );
30
32
31 //*******
33 //*******
32 // EXTERN
34 // EXTERN
33 extern ring_node *ring_node_for_averaging_sm_f0;
34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35
36
36 #endif // AVF0_PRC0_H_INCLUDED
37 #endif // AVF0_PRC0_H_INCLUDED
@@ -2,6 +2,7
2 #define AVF1_PRC1_H
2 #define AVF1_PRC1_H
3
3
4 #include "fsw_processing.h"
4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5
6
6 typedef struct {
7 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp1;
@@ -24,10 +25,10 rtems_task prc1_task( rtems_task_argumen
24 // FUNCTIONS
25 // FUNCTIONS
25
26
26 void reset_nb_sm_f1( unsigned char lfrMode );
27 void reset_nb_sm_f1( unsigned char lfrMode );
28 void init_k_coefficients_f1( void );
27
29
28 //*******
30 //*******
29 // EXTERN
31 // EXTERN
30 extern struct ring_node *ring_node_for_averaging_sm_f1;
31 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
32 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
32
33
33 #endif // AVF1_PRC1_H
34 #endif // AVF1_PRC1_H
@@ -2,6 +2,7
2 #define AVF2_PRC2_H
2 #define AVF2_PRC2_H
3
3
4 #include "fsw_processing.h"
4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5
6
6 typedef struct {
7 typedef struct {
7 unsigned int norm_bp1;
8 unsigned int norm_bp1;
@@ -18,11 +19,11 rtems_task prc2_task( rtems_task_argumen
18 // FUNCTIONS
19 // FUNCTIONS
19
20
20 void reset_nb_sm_f2( void );
21 void reset_nb_sm_f2( void );
21 void SM_average_f2(float *averaged_spec_mat_f2, ring_node *ring_node, unsigned int nbAverageNormF2 );
22 void SM_average_f2(float *averaged_spec_mat_f2, ring_node *ring_node, unsigned int nbAverageNormF2 , asm_msg *msgForMATR);
23 void init_k_coefficients_f2( void );
22
24
23 //*******
25 //*******
24 // EXTERN
26 // EXTERN
25 extern struct ring_node *ring_node_for_averaging_sm_f2;
26 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
27 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
27
28
28 #endif // AVF2_PRC2_H
29 #endif // AVF2_PRC2_H
@@ -21,7 +21,25 typedef struct ring_node_asm
21
21
22 typedef struct
22 typedef struct
23 {
23 {
24 Header_TM_LFR_SCIENCE_BP_t header;
24 unsigned char targetLogicalAddress;
25 unsigned char protocolIdentifier;
26 unsigned char reserved;
27 unsigned char userApplication;
28 unsigned char packetID[2];
29 unsigned char packetSequenceControl[2];
30 unsigned char packetLength[2];
31 // DATA FIELD HEADER
32 unsigned char spare1_pusVersion_spare2;
33 unsigned char serviceType;
34 unsigned char serviceSubType;
35 unsigned char destinationID;
36 unsigned char time[6];
37 // AUXILIARY HEADER
38 unsigned char sid;
39 unsigned char biaStatusInfo;
40 unsigned char acquisitionTime[6];
41 unsigned char pa_lfr_bp_blk_nr[2];
42 // SOURCE DATA
25 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
43 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
26 } bp_packet;
44 } bp_packet;
27
45
@@ -36,8 +54,10 typedef struct
36 ring_node_asm *norm;
54 ring_node_asm *norm;
37 ring_node_asm *burst_sbm;
55 ring_node_asm *burst_sbm;
38 rtems_event_set event;
56 rtems_event_set event;
39 unsigned int coarseTime;
57 unsigned int coarseTimeNORM;
40 unsigned int fineTime;
58 unsigned int fineTimeNORM;
59 unsigned int coarseTimeSBM;
60 unsigned int fineTimeSBM;
41 } asm_msg;
61 } asm_msg;
42
62
43 extern volatile int sm_f0[ ];
63 extern volatile int sm_f0[ ];
@@ -49,11 +69,13 extern struct param_local_str param_loca
49
69
50 // registers
70 // registers
51 extern time_management_regs_t *time_management_regs;
71 extern time_management_regs_t *time_management_regs;
52 extern spectral_matrix_regs_t *spectral_matrix_regs;
72 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
53
73
54 extern rtems_name misc_name[5];
74 extern rtems_name misc_name[5];
55 extern rtems_id Task_id[20]; /* array of task ids */
75 extern rtems_id Task_id[20]; /* array of task ids */
56
76
77 //
78 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
57 // ISR
79 // ISR
58 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
80 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
59 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
81 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
@@ -71,7 +93,7 void ASM_generic_init_ring(ring_node_asm
71 // Basic Parameters
93 // Basic Parameters
72
94
73 void BP_reset_current_ring_nodes( void );
95 void BP_reset_current_ring_nodes( void );
74 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
96 void BP_init_header(bp_packet *header,
75 unsigned int apid, unsigned char sid,
97 unsigned int apid, unsigned char sid,
76 unsigned int packetLength , unsigned char blkNr);
98 unsigned int packetLength , unsigned char blkNr);
77 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
99 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
@@ -87,8 +109,6 void reset_sm_status( void );
87 void reset_spectral_matrix_regs( void );
109 void reset_spectral_matrix_regs( void );
88 void set_time(unsigned char *time, unsigned char *timeInBuffer );
110 void set_time(unsigned char *time, unsigned char *timeInBuffer );
89 unsigned long long int get_acquisition_time( unsigned char *timePtr );
111 unsigned long long int get_acquisition_time( unsigned char *timePtr );
90 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
91 ring_node *node_for_averaging, ring_node *ringNode, unsigned long long int time );
92 unsigned char getSID( rtems_event_set event );
112 unsigned char getSID( rtems_event_set event );
93
113
94 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
114 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
@@ -98,7 +118,8 extern rtems_status_code get_message_que
98 // DEFINITIONS OF STATIC INLINE FUNCTIONS
118 // DEFINITIONS OF STATIC INLINE FUNCTIONS
99 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
119 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
100 ring_node *ring_node_tab[],
120 ring_node *ring_node_tab[],
101 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
121 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
122 asm_msg *msgForMATR );
102 static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
123 static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
103 ring_node *ring_node_tab[],
124 ring_node *ring_node_tab[],
104 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
125 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
@@ -111,7 +132,8 static inline void ASM_convert(volatile
111
132
112 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
133 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
113 ring_node *ring_node_tab[],
134 ring_node *ring_node_tab[],
114 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
135 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
136 asm_msg *msgForMATR )
115 {
137 {
116 float sum;
138 float sum;
117 unsigned int i;
139 unsigned int i;
@@ -131,6 +153,10 void SM_average( float *averaged_spec_ma
131 {
153 {
132 averaged_spec_mat_NORM[ i ] = sum;
154 averaged_spec_mat_NORM[ i ] = sum;
133 averaged_spec_mat_SBM[ i ] = sum;
155 averaged_spec_mat_SBM[ i ] = sum;
156 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
157 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
158 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
159 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
134 }
160 }
135 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
161 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
136 {
162 {
@@ -141,6 +167,8 void SM_average( float *averaged_spec_ma
141 {
167 {
142 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
168 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
143 averaged_spec_mat_SBM[ i ] = sum;
169 averaged_spec_mat_SBM[ i ] = sum;
170 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
171 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
144 }
172 }
145 else
173 else
146 {
174 {
@@ -186,21 +214,22 void ASM_reorganize_and_divide( float *a
186 {
214 {
187 int frequencyBin;
215 int frequencyBin;
188 int asmComponent;
216 int asmComponent;
189 unsigned int offsetAveragedSpecMatReorganized;
217 unsigned int offsetASM;
190 unsigned int offsetAveragedSpecMat;
218 unsigned int offsetASMReorganized;
191
219
220 // BUILD DATA
192 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
221 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
193 {
222 {
194 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
223 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
195 {
224 {
196 offsetAveragedSpecMatReorganized =
225 offsetASMReorganized =
197 frequencyBin * NB_VALUES_PER_SM
226 frequencyBin * NB_VALUES_PER_SM
198 + asmComponent;
227 + asmComponent;
199 offsetAveragedSpecMat =
228 offsetASM =
200 asmComponent * NB_BINS_PER_SM
229 asmComponent * NB_BINS_PER_SM
201 + frequencyBin;
230 + frequencyBin;
202 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
231 averaged_spec_mat_reorganized[offsetASMReorganized ] =
203 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
232 averaged_spec_mat[ offsetASM ] / divider;
204 }
233 }
205 }
234 }
206 }
235 }
@@ -214,7 +243,7 void ASM_compress_reorganize_and_divide(
214 int offsetCompressed;
243 int offsetCompressed;
215 int k;
244 int k;
216
245
217 // build data
246 // BUILD DATA
218 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
247 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
219 {
248 {
220 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
249 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
@@ -231,8 +260,10 void ASM_compress_reorganize_and_divide(
231 {
260 {
232 compressed_spec_mat[offsetCompressed ] =
261 compressed_spec_mat[offsetCompressed ] =
233 ( compressed_spec_mat[ offsetCompressed ]
262 ( compressed_spec_mat[ offsetCompressed ]
234 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
263 + averaged_spec_mat[ offsetASM + k ] );
235 }
264 }
265 compressed_spec_mat[ offsetCompressed ] =
266 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
236 }
267 }
237 }
268 }
238 }
269 }
@@ -108,6 +108,9 rtems_task Init( rtems_task_argument ign
108 init_parameter_dump();
108 init_parameter_dump();
109 init_local_mode_parameters();
109 init_local_mode_parameters();
110 init_housekeeping_parameters();
110 init_housekeeping_parameters();
111 init_k_coefficients_f0();
112 init_k_coefficients_f1();
113 init_k_coefficients_f2();
111
114
112 // waveform picker initialization
115 // waveform picker initialization
113 WFP_init_rings(); // initialize the waveform rings
116 WFP_init_rings(); // initialize the waveform rings
@@ -215,6 +218,8 rtems_task Init( rtems_task_argument ign
215
218
216 BOOT_PRINTF("delete INIT\n")
219 BOOT_PRINTF("delete INIT\n")
217
220
221 // test_TCH();
222
218 status = rtems_task_delete(RTEMS_SELF);
223 status = rtems_task_delete(RTEMS_SELF);
219
224
220 }
225 }
@@ -225,7 +225,7 rtems_task hous_task(rtems_task_argument
225
225
226 spacewire_update_statistics();
226 spacewire_update_statistics();
227
227
228 // get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
228 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230
230
231 // SEND PACKET
231 // SEND PACKET
@@ -443,107 +443,20 void send_dumb_hk( void )
443
443
444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
445 {
445 {
446 unsigned long long int localTime_asLong;
446 unsigned char* v_ptr;
447 unsigned long long int f3_0_AcquisitionTime_asLong;
447 unsigned char* e1_ptr;
448 unsigned long long int f3_1_AcquisitionTime_asLong;
448 unsigned char* e2_ptr;
449 unsigned long long int deltaT;
450 unsigned long long int deltaT_f3_0;
451 unsigned long long int deltaT_f3_1;
452 unsigned char *bufferPtr;
453
454 unsigned int offset_in_samples;
455 unsigned int offset_in_bytes;
456 unsigned char f3;
457
458 bufferPtr = NULL;
459 deltaT = 0;
460 deltaT_f3_0 = 0xffffffff;
461 deltaT_f3_1 = 0xffffffff;
462 f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
463
464 if (lfrCurrentMode == LFR_MODE_STANDBY)
465 {
466 spacecraft_potential[0] = 0x00;
467 spacecraft_potential[1] = 0x00;
468 spacecraft_potential[2] = 0x00;
469 spacecraft_potential[3] = 0x00;
470 spacecraft_potential[4] = 0x00;
471 spacecraft_potential[5] = 0x00;
472 }
473 else
474 {
475 localTime_asLong = get_acquisition_time( (unsigned char *) &time_management_regs->coarse_time );
476 f3_0_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_0_coarse_time );
477 f3_1_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_1_coarse_time );
478 printf("localTime 0x%llx, f3_0 0x%llx, f3_1 0x%llx\n",
479 localTime_asLong,
480 f3_0_AcquisitionTime_asLong,
481 f3_1_AcquisitionTime_asLong);
482
483 if ( localTime_asLong >= f3_0_AcquisitionTime_asLong )
484 {
485 deltaT_f3_0 = localTime_asLong - f3_0_AcquisitionTime_asLong;
486 }
487
488 if ( localTime_asLong > f3_1_AcquisitionTime_asLong )
489 {
490 deltaT_f3_1 = localTime_asLong - f3_1_AcquisitionTime_asLong;
491 }
492
449
493 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
450 v_ptr = (unsigned char *) &waveform_picker_regs->v;
494 {
451 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
495 if ( deltaT_f3_0 > deltaT_f3_1 )
452 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
496 {
497 deltaT = deltaT_f3_1;
498 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
499 }
500 else
501 {
502 deltaT = deltaT_f3_0;
503 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_0;
504 }
505 }
506 else if ( (deltaT_f3_0 == 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
507 {
508 deltaT = deltaT_f3_1;
509 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
510 }
511 else if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 == 0xffffffff) )
512 {
513 deltaT = deltaT_f3_0;
514 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
515 }
516 else
517 {
518 deltaT = 0xffffffff;
519 }
520
453
521 if ( deltaT == 0xffffffff )
454 spacecraft_potential[0] = v_ptr[2];
522 {
455 spacecraft_potential[1] = v_ptr[3];
523 spacecraft_potential[0] = 0x00;
456 spacecraft_potential[2] = e1_ptr[2];
524 spacecraft_potential[1] = 0x00;
457 spacecraft_potential[3] = e1_ptr[3];
525 spacecraft_potential[2] = 0x00;
458 spacecraft_potential[4] = e2_ptr[2];
526 spacecraft_potential[3] = 0x00;
459 spacecraft_potential[5] = e2_ptr[3];
527 spacecraft_potential[4] = 0x00;
528 spacecraft_potential[5] = 0x00;
529 }
530 else
531 {
532 offset_in_samples = ( (double) deltaT ) / 65536. * f3;
533 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
534 {
535 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
536 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT - 1;
537 }
538 offset_in_bytes = offset_in_samples * NB_WORDS_SWF_BLK * 4;
539 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
540 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
541 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
542 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
543 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
544 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
545 }
546 }
547 }
460 }
548
461
549 void get_cpu_load( unsigned char *resource_statistics )
462 void get_cpu_load( unsigned char *resource_statistics )
@@ -690,8 +690,8 void init_header_cwf( Header_TM_LFR_SCIE
690 header->userApplication = CCSDS_USER_APP;
690 header->userApplication = CCSDS_USER_APP;
691 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
691 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
692 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
692 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
693 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
693 header->packetLength[0] = 0x00;
694 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
694 header->packetLength[1] = 0x00;
695 // DATA FIELD HEADER
695 // DATA FIELD HEADER
696 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
696 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
697 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
697 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
@@ -706,8 +706,8 void init_header_cwf( Header_TM_LFR_SCIE
706 // AUXILIARY DATA HEADER
706 // AUXILIARY DATA HEADER
707 header->sid = 0x00;
707 header->sid = 0x00;
708 header->hkBIA = DEFAULT_HKBIA;
708 header->hkBIA = DEFAULT_HKBIA;
709 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
709 header->blkNr[0] = 0x00;
710 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
710 header->blkNr[1] = 0x00;
711 }
711 }
712
712
713 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header )
713 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header )
@@ -808,6 +808,11 int spw_send_waveform_CWF( ring_node *ri
808 fineTime = ring_node_to_send->fineTime;
808 fineTime = ring_node_to_send->fineTime;
809 dataPtr = (int*) ring_node_to_send->buffer_address;
809 dataPtr = (int*) ring_node_to_send->buffer_address;
810
810
811 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
812 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
813 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
814 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
815
811 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
816 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
812 {
817 {
813 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ];
818 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ];
@@ -974,6 +979,11 int spw_send_waveform_CWF3_light( ring_n
974 fineTime = ring_node_to_send->fineTime;
979 fineTime = ring_node_to_send->fineTime;
975 dataPtr = (char*) ring_node_to_send->buffer_address;
980 dataPtr = (char*) ring_node_to_send->buffer_address;
976
981
982 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
983 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
984 header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
985 header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
986
977 //*********************
987 //*********************
978 // SEND CWF3_light DATA
988 // SEND CWF3_light DATA
979 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
989 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
@@ -24,8 +24,9 float asm_f0_reorganized [ TOTAL_SIZE_
24 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
24 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
25 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
25 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
26 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
26 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
27 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
27
28 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
28 float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352
29 float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704
29
30
30 //************
31 //************
31 // RTEMS TASKS
32 // RTEMS TASKS
@@ -38,6 +39,7 rtems_task avf0_task( rtems_task_argumen
38 rtems_status_code status;
39 rtems_status_code status;
39 rtems_id queue_id_prc0;
40 rtems_id queue_id_prc0;
40 asm_msg msgForMATR;
41 asm_msg msgForMATR;
42 ring_node *nodeForAveraging;
41 ring_node *ring_node_tab[8];
43 ring_node *ring_node_tab[8];
42 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
44 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
43 ring_node_asm *current_ring_node_asm_norm_f0;
45 ring_node_asm *current_ring_node_asm_norm_f0;
@@ -76,23 +78,24 rtems_task avf0_task( rtems_task_argumen
76 msgForMATR.norm = current_ring_node_asm_norm_f0;
78 msgForMATR.norm = current_ring_node_asm_norm_f0;
77 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
79 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
78 msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task
80 msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task
79 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
80 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
81 //
81 //
82 //****************************************
82 //****************************************
83
83
84 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
84 nodeForAveraging = getRingNodeForAveraging( 0 );
85
86 ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging;
85 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
87 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
86 {
88 {
87 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
89 nodeForAveraging = nodeForAveraging->previous;
88 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
90 ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging;
89 }
91 }
90
92
91 // compute the average and store it in the averaged_sm_f1 buffer
93 // compute the average and store it in the averaged_sm_f1 buffer
92 SM_average( current_ring_node_asm_norm_f0->matrix,
94 SM_average( current_ring_node_asm_norm_f0->matrix,
93 current_ring_node_asm_burst_sbm_f0->matrix,
95 current_ring_node_asm_burst_sbm_f0->matrix,
94 ring_node_tab,
96 ring_node_tab,
95 nb_norm_bp1, nb_sbm_bp1 );
97 nb_norm_bp1, nb_sbm_bp1,
98 &msgForMATR );
96
99
97 // update nb_average
100 // update nb_average
98 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
101 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
@@ -157,7 +160,6 rtems_task avf0_task( rtems_task_argumen
157 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
160 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
161 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 {
162 {
160 // PRINTF1("%lld\n", localTime)
161 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
163 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
162 }
164 }
163 }
165 }
@@ -185,10 +187,10 rtems_task prc0_task( rtems_task_argumen
185 rtems_status_code status;
187 rtems_status_code status;
186 rtems_id queue_id;
188 rtems_id queue_id;
187 rtems_id queue_id_q_p0;
189 rtems_id queue_id_q_p0;
188 bp_packet_with_spare packet_norm_bp1_f0;
190 bp_packet_with_spare packet_norm_bp1;
189 bp_packet packet_norm_bp2_f0;
191 bp_packet packet_norm_bp2;
190 bp_packet packet_sbm_bp1_f0;
192 bp_packet packet_sbm_bp1;
191 bp_packet packet_sbm_bp2_f0;
193 bp_packet packet_sbm_bp2;
192 ring_node *current_ring_node_to_send_asm_f0;
194 ring_node *current_ring_node_to_send_asm_f0;
193
195
194 unsigned long long int localTime;
196 unsigned long long int localTime;
@@ -199,10 +201,10 rtems_task prc0_task( rtems_task_argumen
199
201
200 //*************
202 //*************
201 // NORM headers
203 // NORM headers
202 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
204 BP_init_header_with_spare( &packet_norm_bp1.header,
203 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
205 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
204 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
206 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
205 BP_init_header( &packet_norm_bp2_f0.header,
207 BP_init_header( &packet_norm_bp2,
206 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
208 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
207 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
209 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
208
210
@@ -210,28 +212,28 rtems_task prc0_task( rtems_task_argumen
210 // BURST SBM1 and SBM2 headers
212 // BURST SBM1 and SBM2 headers
211 if ( lfrRequestedMode == LFR_MODE_BURST )
213 if ( lfrRequestedMode == LFR_MODE_BURST )
212 {
214 {
213 BP_init_header( &packet_sbm_bp1_f0.header,
215 BP_init_header( &packet_sbm_bp1,
214 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
216 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
217 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
216 BP_init_header( &packet_sbm_bp2_f0.header,
218 BP_init_header( &packet_sbm_bp2,
217 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
219 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
219 }
221 }
220 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
222 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
221 {
223 {
222 BP_init_header( &packet_sbm_bp1_f0.header,
224 BP_init_header( &packet_sbm_bp1,
223 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
225 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
226 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
225 BP_init_header( &packet_sbm_bp2_f0.header,
227 BP_init_header( &packet_sbm_bp2,
226 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
228 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
227 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 }
230 }
229 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
231 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
230 {
232 {
231 BP_init_header( &packet_sbm_bp1_f0.header,
233 BP_init_header( &packet_sbm_bp1,
232 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
234 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
233 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
235 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
234 BP_init_header( &packet_sbm_bp2_f0.header,
236 BP_init_header( &packet_sbm_bp2,
235 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
237 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
236 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
238 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
237 }
239 }
@@ -275,22 +277,22 rtems_task prc0_task( rtems_task_argumen
275 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
277 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
276 ASM_F0_INDICE_START);
278 ASM_F0_INDICE_START);
277 // 2) compute the BP1 set
279 // 2) compute the BP1 set
278 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
280 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
279 // 3) send the BP1 set
281 // 3) send the BP1 set
280 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
282 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
281 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
283 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
282 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
284 BP_send( (char *) &packet_sbm_bp1, queue_id,
283 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
285 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
284 sid);
286 sid);
285 // 4) compute the BP2 set if needed
287 // 4) compute the BP2 set if needed
286 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
288 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
287 {
289 {
288 // 1) compute the BP2 set
290 // 1) compute the BP2 set
289
291 BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data );
290 // 2) send the BP2 set
292 // 2) send the BP2 set
291 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
293 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
292 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
294 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
293 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
295 BP_send( (char *) &packet_sbm_bp2, queue_id,
294 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
296 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
295 sid);
297 sid);
296 }
298 }
@@ -309,23 +311,63 rtems_task prc0_task( rtems_task_argumen
309 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
311 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
310 ASM_F0_INDICE_START );
312 ASM_F0_INDICE_START );
311 // 2) compute the BP1 set
313 // 2) compute the BP1 set
312 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
314 BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
313 // 3) send the BP1 set
315 // 3) send the BP1 set
314 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
316 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
315 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
317 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
316 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
318 BP_send( (char *) &packet_norm_bp1, queue_id,
317 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
319 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
318 SID_NORM_BP1_F0 );
320 SID_NORM_BP1_F0 );
319 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
321 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
320 {
322 {
321 // 1) compute the BP2 set using the same ASM as the one used for BP1
323 // 1) compute the BP2 set using the same ASM as the one used for BP1
322
324 BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data );
323 // 2) send the BP2 set
325 // 2) send the BP2 set
324 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
326 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
325 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
327 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
326 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
328 BP_send( (char *) &packet_norm_bp2, queue_id,
327 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
329 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
328 SID_NORM_BP2_F0);
330 SID_NORM_BP2_F0);
331
332 // < TMP DATA>
333 #define INDEX_COMPRESSED 1
334 unsigned int signif;
335 float significand;
336 unsigned int nbitexp = 6;
337 unsigned int nbitsig = 16 - nbitexp; // number of bits for the significand
338 unsigned int rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
339 int expmax = 32;
340 int expmin = expmax - ((int) (1 << nbitexp)) + 1;
341 int exponent;
342 float auto_a0;
343 exponent = ( (int) ( (packet_norm_bp2.data[INDEX_COMPRESSED * NB_BYTES_PER_BP2] & 0xfc) >> 2) ) + expmin; // [1111 1100]
344 printf("exponent = %x, computed with exp = %x, expmin = %d\n",
345 exponent,
346 (packet_norm_bp2.data[INDEX_COMPRESSED * NB_BYTES_PER_BP2] & 0xfc) >> 2,
347 expmin);
348 signif = ( (packet_norm_bp2.data[INDEX_COMPRESSED * NB_BYTES_PER_BP2] & 0x3) << 8 ) + packet_norm_bp2.data[INDEX_COMPRESSED * NB_BYTES_PER_BP2+1];
349 significand = ( ( (float) signif ) / ( (float) rangesig) + 1) / 2;
350 auto_a0 = significand * pow(2,exponent);
351 printf("(BP2) [%d] compressed = %f *** AUTO A0 = %x, %x, exponent = %x, significand = %f ===> %f\n",
352 INDEX_COMPRESSED,
353 compressed_sm_norm_f0[INDEX_COMPRESSED * NB_VALUES_PER_SM],
354 packet_norm_bp2.data[ INDEX_COMPRESSED * NB_BYTES_PER_BP2],
355 packet_norm_bp2.data[ INDEX_COMPRESSED * NB_BYTES_PER_BP2 + 1],
356 exponent, significand, auto_a0 );
357 // printf("(BP2) 0 = %f, 1 = %f, 2 = %f, 3 = %f, 4 = %f, 5 = %f, 6 = %f, 7 = %f, 8 = %f, 9 = %f, 10 = %f,\n",
358 // compressed_sm_norm_f0[0 * NB_VALUES_PER_SM],
359 // compressed_sm_norm_f0[1 * NB_VALUES_PER_SM],
360 // compressed_sm_norm_f0[2 * NB_VALUES_PER_SM],
361 // compressed_sm_norm_f0[3 * NB_VALUES_PER_SM],
362 // compressed_sm_norm_f0[4 * NB_VALUES_PER_SM],
363 // compressed_sm_norm_f0[5 * NB_VALUES_PER_SM],
364 // compressed_sm_norm_f0[6 * NB_VALUES_PER_SM],
365 // compressed_sm_norm_f0[7 * NB_VALUES_PER_SM],
366 // compressed_sm_norm_f0[8 * NB_VALUES_PER_SM],
367 // compressed_sm_norm_f0[9 * NB_VALUES_PER_SM],
368 // compressed_sm_norm_f0[10 * NB_VALUES_PER_SM]);
369 // </TMP DATA>
370
329 }
371 }
330 }
372 }
331
373
@@ -337,9 +379,25 rtems_task prc0_task( rtems_task_argumen
337 nb_sm_before_f0.norm_bp1 );
379 nb_sm_before_f0.norm_bp1 );
338 // 2) convert the float array in a char array
380 // 2) convert the float array in a char array
339 ASM_convert( asm_f0_reorganized, (char*) current_ring_node_to_send_asm_f0->buffer_address );
381 ASM_convert( asm_f0_reorganized, (char*) current_ring_node_to_send_asm_f0->buffer_address );
340 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTime;
382 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
341 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTime;
383 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
342 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
384 current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
385
386 // < TMP DATA>
387 #define INDEX_TO_LOOK_AT 31
388 float b11;
389 unsigned char *b11_charPtr;
390 b11_charPtr = (unsigned char*) &b11;
391 b11_charPtr[0] = ((unsigned char *) current_ring_node_to_send_asm_f0->buffer_address)[(INDEX_TO_LOOK_AT * NB_VALUES_PER_SM) * 2];
392 b11_charPtr[1] = ((unsigned char *) current_ring_node_to_send_asm_f0->buffer_address)[(INDEX_TO_LOOK_AT * NB_VALUES_PER_SM) * 2 +1];
393 b11_charPtr[2] = 0x00;
394 b11_charPtr[3] = 0x00;
395 printf("(ASM) initial = %f, reorganized and divided = %f, converted = %f\n",
396 incomingMsg->norm->matrix[INDEX_TO_LOOK_AT], // 32 * 96 = 3072 Hz
397 asm_f0_reorganized[ INDEX_TO_LOOK_AT * NB_VALUES_PER_SM ],
398 b11);
399 // </TMP DATA>
400
343 // 3) send the spectral matrix packets
401 // 3) send the spectral matrix packets
344 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
402 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
345 // change asm ring node
403 // change asm ring node
@@ -385,3 +443,56 void reset_nb_sm_f0( unsigned char lfrMo
385 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
443 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
386 }
444 }
387 }
445 }
446
447 void init_k_coefficients_f0( void )
448 {
449 init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 );
450 init_k_coefficients( k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0);
451 }
452
453 void test_TCH( void )
454 {
455 #define NB_BINS_COMPRESSED_MATRIX_TCH 1
456
457 unsigned char LFR_BP1_f0[NB_BINS_COMPRESSED_MATRIX_TCH*NB_BYTES_BP1];
458 unsigned char LFR_BP2_f0[NB_BINS_COMPRESSED_MATRIX_TCH*NB_BYTES_BP2];
459 float k_coefficients[NB_BINS_COMPRESSED_MATRIX_TCH * NB_K_COEFF_PER_BIN];
460
461 float compressed_spectral_matrix_TCH[ NB_BINS_COMPRESSED_MATRIX_TCH * NB_VALUES_PER_SPECTRAL_MATRIX ] = {
462 1.02217712e+06,
463 -8.58216250e+04,
464 -3.22199043e+04,
465 1.01597820e+05,
466 8.10333875e+05,
467 1.19030141e+05,
468 -8.69636688e+05,
469 5.01504031e+05,
470 -1.01948547e+05,
471 1.35475020e+04,
472 -3.67825469e+04,
473 -1.10950273e+05,
474 2.10715000e+04,
475 4.49727383e+04,
476 -4.37282031e+04,
477 3.83337695e+03,
478 1.05317175e+06,
479 -4.04155312e+05,
480 -1.32987891e+05,
481 1.49277250e+05,
482 -4.39122625e+05,
483 9.46006250e+05,
484 2.64386625e+05,
485 3.71843125e+05,
486 3.39770000e+05
487 };
488
489 init_k_coefficients( k_coefficients, NB_BINS_COMPRESSED_MATRIX_TCH );
490
491 printf("\n");
492
493 BP1_set(compressed_spectral_matrix_TCH, k_coefficients, NB_BINS_COMPRESSED_MATRIX_TCH, LFR_BP1_f0);
494
495 printf("\n");
496
497 BP2_set(compressed_spectral_matrix_TCH, NB_BINS_COMPRESSED_MATRIX_TCH, LFR_BP2_f0);
498 }
@@ -11,6 +11,8
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[ ];
15
14 //***
16 //***
15 // F1
17 // F1
16 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 ];
@@ -24,6 +26,9 char asm_f1_char [ TIME_OFFSET
24 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
26 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
25 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
27 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
26
28
29 float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416
30 float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832
31
27 //************
32 //************
28 // RTEMS TASKS
33 // RTEMS TASKS
29
34
@@ -35,7 +40,8 rtems_task avf1_task( rtems_task_argumen
35 rtems_status_code status;
40 rtems_status_code status;
36 rtems_id queue_id_prc1;
41 rtems_id queue_id_prc1;
37 asm_msg msgForMATR;
42 asm_msg msgForMATR;
38 ring_node *ring_node_tab[8];
43 ring_node *nodeForAveraging;
44 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0];
39 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
45 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
40 ring_node_asm *current_ring_node_asm_norm_f1;
46 ring_node_asm *current_ring_node_asm_norm_f1;
41
47
@@ -73,23 +79,24 rtems_task avf1_task( rtems_task_argumen
73 msgForMATR.norm = current_ring_node_asm_norm_f1;
79 msgForMATR.norm = current_ring_node_asm_norm_f1;
74 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
80 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
75 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
81 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
76 msgForMATR.coarseTime = ring_node_for_averaging_sm_f1->coarseTime;
77 msgForMATR.fineTime = ring_node_for_averaging_sm_f1->fineTime;
78 //
82 //
79 //****************************************
83 //****************************************
80
84
81 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
85 nodeForAveraging = getRingNodeForAveraging( 1 );
86
87 ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging;
82 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
88 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
83 {
89 {
84 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
90 nodeForAveraging = nodeForAveraging->previous;
85 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
91 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
86 }
92 }
87
93
88 // compute the average and store it in the averaged_sm_f1 buffer
94 // compute the average and store it in the averaged_sm_f1 buffer
89 SM_average( current_ring_node_asm_norm_f1->matrix,
95 SM_average( current_ring_node_asm_norm_f1->matrix,
90 current_ring_node_asm_burst_sbm_f1->matrix,
96 current_ring_node_asm_burst_sbm_f1->matrix,
91 ring_node_tab,
97 ring_node_tab,
92 nb_norm_bp1, nb_sbm_bp1 );
98 nb_norm_bp1, nb_sbm_bp1,
99 &msgForMATR );
93
100
94 // update nb_average
101 // update nb_average
95 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
102 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
@@ -198,7 +205,7 rtems_task prc1_task( rtems_task_argumen
198 BP_init_header_with_spare( &packet_norm_bp1.header,
205 BP_init_header_with_spare( &packet_norm_bp1.header,
199 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
206 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
200 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
207 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
201 BP_init_header( &packet_norm_bp2.header,
208 BP_init_header( &packet_norm_bp2,
202 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
203 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
210 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
204
211
@@ -206,19 +213,19 rtems_task prc1_task( rtems_task_argumen
206 // BURST and SBM2 headers
213 // BURST and SBM2 headers
207 if ( lfrRequestedMode == LFR_MODE_BURST )
214 if ( lfrRequestedMode == LFR_MODE_BURST )
208 {
215 {
209 BP_init_header( &packet_sbm_bp1.header,
216 BP_init_header( &packet_sbm_bp1,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
217 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
211 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
212 BP_init_header( &packet_sbm_bp2.header,
219 BP_init_header( &packet_sbm_bp2,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
214 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
215 }
222 }
216 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
223 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
217 {
224 {
218 BP_init_header( &packet_sbm_bp1.header,
225 BP_init_header( &packet_sbm_bp1,
219 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
226 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
227 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
221 BP_init_header( &packet_sbm_bp2.header,
228 BP_init_header( &packet_sbm_bp2,
222 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
223 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
230 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
224 }
231 }
@@ -261,10 +268,10 rtems_task prc1_task( rtems_task_argumen
261 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
268 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
262 ASM_F1_INDICE_START);
269 ASM_F1_INDICE_START);
263 // 2) compute the BP1 set
270 // 2) compute the BP1 set
264
271 BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data );
265 // 3) send the BP1 set
272 // 3) send the BP1 set
266 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
273 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
267 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
274 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
268 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
275 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
269 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
276 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
270 sid );
277 sid );
@@ -272,10 +279,10 rtems_task prc1_task( rtems_task_argumen
272 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
279 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
273 {
280 {
274 // 1) compute the BP2 set
281 // 1) compute the BP2 set
275
282 BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_norm_bp2.data );
276 // 2) send the BP2 set
283 // 2) send the BP2 set
277 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
284 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
278 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
285 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
279 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
286 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
280 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
287 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
281 sid );
288 sid );
@@ -295,20 +302,20 rtems_task prc1_task( rtems_task_argumen
295 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
302 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
296 ASM_F0_INDICE_START );
303 ASM_F0_INDICE_START );
297 // 2) compute the BP1 set
304 // 2) compute the BP1 set
298
305 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
299 // 3) send the BP1 set
306 // 3) send the BP1 set
300 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
307 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
301 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
308 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
302 BP_send( (char *) &packet_norm_bp1, queue_id_send,
309 BP_send( (char *) &packet_norm_bp1, queue_id_send,
303 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
310 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
304 SID_NORM_BP1_F1 );
311 SID_NORM_BP1_F1 );
305 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
306 {
313 {
307 // 1) compute the BP2 set
314 // 1) compute the BP2 set
308
315 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
309 // 2) send the BP2 set
316 // 2) send the BP2 set
310 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
317 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
311 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
318 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
312 BP_send( (char *) &packet_norm_bp2, queue_id_send,
319 BP_send( (char *) &packet_norm_bp2, queue_id_send,
313 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
320 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
314 SID_NORM_BP2_F1 );
321 SID_NORM_BP2_F1 );
@@ -323,8 +330,8 rtems_task prc1_task( rtems_task_argumen
323 nb_sm_before_f1.norm_bp1 );
330 nb_sm_before_f1.norm_bp1 );
324 // 2) convert the float array in a char array
331 // 2) convert the float array in a char array
325 ASM_convert( asm_f1_reorganized, (char*) current_ring_node_to_send_asm_f1->buffer_address );
332 ASM_convert( asm_f1_reorganized, (char*) current_ring_node_to_send_asm_f1->buffer_address );
326 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTime;
333 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
327 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTime;
334 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
328 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
335 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
329 // 3) send the spectral matrix packets
336 // 3) send the spectral matrix packets
330 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
337 status = rtems_message_queue_send( queue_id_send, &current_ring_node_to_send_asm_f1, sizeof( ring_node* ) );
@@ -365,3 +372,8 void reset_nb_sm_f1( unsigned char lfrMo
365 }
372 }
366 }
373 }
367
374
375 void init_k_coefficients_f1( void )
376 {
377 init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 );
378 init_k_coefficients( k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1);
379 }
@@ -11,6 +11,8
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[ ];
15
14 //***
16 //***
15 // F2
17 // F2
16 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 ];
@@ -24,6 +26,8 char asm_f2_char [ TIME_OFFSET
24 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
26 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
25 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
27 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
26
28
29 float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384
30
27 //************
31 //************
28 // RTEMS TASKS
32 // RTEMS TASKS
29
33
@@ -35,6 +39,7 rtems_task avf2_task( rtems_task_argumen
35 rtems_status_code status;
39 rtems_status_code status;
36 rtems_id queue_id_prc2;
40 rtems_id queue_id_prc2;
37 asm_msg msgForMATR;
41 asm_msg msgForMATR;
42 ring_node *nodeForAveraging;
38 ring_node_asm *current_ring_node_asm_norm_f2;
43 ring_node_asm *current_ring_node_asm_norm_f2;
39
44
40 unsigned int nb_norm_bp1;
45 unsigned int nb_norm_bp1;
@@ -65,15 +70,28 rtems_task avf2_task( rtems_task_argumen
65 msgForMATR.norm = current_ring_node_asm_norm_f2;
70 msgForMATR.norm = current_ring_node_asm_norm_f2;
66 msgForMATR.burst_sbm = NULL;
71 msgForMATR.burst_sbm = NULL;
67 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
68 msgForMATR.coarseTime = ring_node_for_averaging_sm_f2->coarseTime;
69 msgForMATR.fineTime = ring_node_for_averaging_sm_f2->fineTime;
70 //
73 //
71 //****************************************
74 //****************************************
72
75
76 nodeForAveraging = getRingNodeForAveraging( 2 );
77
78 // printf(" **0** %x . %x", sm_ring_f2[0].coarseTime, sm_ring_f2[0].fineTime);
79 // printf(" **1** %x . %x", sm_ring_f2[1].coarseTime, sm_ring_f2[1].fineTime);
80 // printf(" **2** %x . %x", sm_ring_f2[2].coarseTime, sm_ring_f2[2].fineTime);
81 // printf(" **3** %x . %x", sm_ring_f2[3].coarseTime, sm_ring_f2[3].fineTime);
82 // printf(" **4** %x . %x", sm_ring_f2[4].coarseTime, sm_ring_f2[4].fineTime);
83 // printf(" **5** %x . %x", sm_ring_f2[5].coarseTime, sm_ring_f2[5].fineTime);
84 // printf(" **6** %x . %x", sm_ring_f2[6].coarseTime, sm_ring_f2[6].fineTime);
85 // printf(" **7** %x . %x", sm_ring_f2[7].coarseTime, sm_ring_f2[7].fineTime);
86 // printf(" **8** %x . %x", sm_ring_f2[8].coarseTime, sm_ring_f2[8].fineTime);
87 // printf(" **9** %x . %x", sm_ring_f2[9].coarseTime, sm_ring_f2[9].fineTime);
88 // printf(" **10** %x . %x\n", sm_ring_f2[10].coarseTime, sm_ring_f2[10].fineTime);
89
73 // compute the average and store it in the averaged_sm_f2 buffer
90 // compute the average and store it in the averaged_sm_f2 buffer
74 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
91 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
75 ring_node_for_averaging_sm_f2,
92 nodeForAveraging,
76 nb_norm_bp1 );
93 nb_norm_bp1,
94 &msgForMATR );
77
95
78 // update nb_average
96 // update nb_average
79 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
97 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
@@ -108,7 +126,6 rtems_task avf2_task( rtems_task_argumen
108 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
126 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
109 || (lfrCurrentMode == LFR_MODE_SBM2) )
127 || (lfrCurrentMode == LFR_MODE_SBM2) )
110 {
128 {
111 // PRINTF1("%lld\n", localTime)
112 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
113 }
130 }
114 }
131 }
@@ -135,8 +152,8 rtems_task prc2_task( rtems_task_argumen
135 rtems_status_code status;
152 rtems_status_code status;
136 rtems_id queue_id;
153 rtems_id queue_id;
137 rtems_id queue_id_q_p2;
154 rtems_id queue_id_q_p2;
138 bp_packet packet_norm_bp1_f2;
155 bp_packet packet_norm_bp1;
139 bp_packet packet_norm_bp2_f2;
156 bp_packet packet_norm_bp2;
140 ring_node *current_ring_node_to_send_asm_f2;
157 ring_node *current_ring_node_to_send_asm_f2;
141
158
142 unsigned long long int localTime;
159 unsigned long long int localTime;
@@ -149,10 +166,10 rtems_task prc2_task( rtems_task_argumen
149
166
150 //*************
167 //*************
151 // NORM headers
168 // NORM headers
152 BP_init_header( &packet_norm_bp1_f2.header,
169 BP_init_header( &packet_norm_bp1,
153 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
170 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
154 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
171 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
155 BP_init_header( &packet_norm_bp2_f2.header,
172 BP_init_header( &packet_norm_bp2,
156 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
173 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
157 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
174 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
158
175
@@ -190,21 +207,21 rtems_task prc2_task( rtems_task_argumen
190 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
207 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
191 ASM_F2_INDICE_START );
208 ASM_F2_INDICE_START );
192 // 2) compute the BP1 set
209 // 2) compute the BP1 set
193
210 BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data );
194 // 3) send the BP1 set
211 // 3) send the BP1 set
195 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
212 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
196 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
213 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
197 BP_send( (char *) &packet_norm_bp1_f2, queue_id,
214 BP_send( (char *) &packet_norm_bp1, queue_id,
198 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
215 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
199 SID_NORM_BP1_F2 );
216 SID_NORM_BP1_F2 );
200 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
217 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
201 {
218 {
202 // 1) compute the BP2 set using the same ASM as the one used for BP1
219 // 1) compute the BP2 set using the same ASM as the one used for BP1
203
220 BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data );
204 // 2) send the BP2 set
221 // 2) send the BP2 set
205 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
222 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
206 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
223 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
207 BP_send( (char *) &packet_norm_bp2_f2, queue_id,
224 BP_send( (char *) &packet_norm_bp2, queue_id,
208 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
225 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
209 SID_NORM_BP2_F2 );
226 SID_NORM_BP2_F2 );
210 }
227 }
@@ -218,8 +235,8 rtems_task prc2_task( rtems_task_argumen
218 nb_sm_before_f2.norm_bp1 );
235 nb_sm_before_f2.norm_bp1 );
219 // 2) convert the float array in a char array
236 // 2) convert the float array in a char array
220 ASM_convert( asm_f2_reorganized, (char*) current_ring_node_to_send_asm_f2->buffer_address );
237 ASM_convert( asm_f2_reorganized, (char*) current_ring_node_to_send_asm_f2->buffer_address );
221 current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTime;
238 current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM;
222 current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTime;
239 current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM;
223 current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2;
240 current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2;
224 // 3) send the spectral matrix packets
241 // 3) send the spectral matrix packets
225 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f2, sizeof( ring_node* ) );
242 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f2, sizeof( ring_node* ) );
@@ -242,7 +259,8 void reset_nb_sm_f2( void )
242
259
243 void SM_average_f2( float *averaged_spec_mat_f2,
260 void SM_average_f2( float *averaged_spec_mat_f2,
244 ring_node *ring_node,
261 ring_node *ring_node,
245 unsigned int nbAverageNormF2 )
262 unsigned int nbAverageNormF2,
263 asm_msg *msgForMATR )
246 {
264 {
247 float sum;
265 float sum;
248 unsigned int i;
266 unsigned int i;
@@ -253,6 +271,8 void SM_average_f2( float *averaged_spec
253 if ( (nbAverageNormF2 == 0) )
271 if ( (nbAverageNormF2 == 0) )
254 {
272 {
255 averaged_spec_mat_f2[ i ] = sum;
273 averaged_spec_mat_f2[ i ] = sum;
274 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
275 msgForMATR->fineTimeNORM = ring_node->fineTime;
256 }
276 }
257 else
277 else
258 {
278 {
@@ -260,3 +280,8 void SM_average_f2( float *averaged_spec
260 }
280 }
261 }
281 }
262 }
282 }
283
284 void init_k_coefficients_f2( void )
285 {
286 init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2);
287 }
@@ -27,78 +27,91 ring_node *ring_node_for_averaging_sm_f0
27 ring_node *ring_node_for_averaging_sm_f1;
27 ring_node *ring_node_for_averaging_sm_f1;
28 ring_node *ring_node_for_averaging_sm_f2;
28 ring_node *ring_node_for_averaging_sm_f2;
29
29
30 //
31 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
32 {
33 ring_node *node;
34
35 node = NULL;
36 switch ( frequencyChannel ) {
37 case 0:
38 node = ring_node_for_averaging_sm_f0;
39 break;
40 case 1:
41 node = ring_node_for_averaging_sm_f1;
42 break;
43 case 2:
44 node = ring_node_for_averaging_sm_f2;
45 break;
46 default:
47 break;
48 }
49
50 return node;
51 }
52
30 //***********************************************************
53 //***********************************************************
31 // Interrupt Service Routine for spectral matrices processing
54 // Interrupt Service Routine for spectral matrices processing
32
55
33 void spectral_matrices_isr_f0( void )
56 void spectral_matrices_isr_f0( void )
34 {
57 {
35 unsigned char status;
58 unsigned char status;
36 unsigned long long int time_0;
59 rtems_status_code status_code;
37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
40
60
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
61 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
42
62
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47
48 switch(status)
63 switch(status)
49 {
64 {
50 case 0:
65 case 0:
51 break;
66 break;
52 case 3:
67 case 3:
53 // send a message if two buffers are ready
68 // UNEXPECTED VALUE
54 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
55 if ( time_0 < time_1 )
56 {
57 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
58 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
59 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
60 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
61 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
62 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
63 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
64 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
65 }
66 else
67 {
68 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
69 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
70 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
71 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
72 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
73 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
74 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
75 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
76 }
77 spectral_matrix_regs->status = 0x03; // [0011]
69 spectral_matrix_regs->status = 0x03; // [0011]
70 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
78 break;
71 break;
79 case 1:
72 case 1:
80 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
73 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0->previous;
81 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
82 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
74 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
75 ring_node_for_averaging_sm_f0->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
76 ring_node_for_averaging_sm_f0->fineTime = spectral_matrix_regs->f0_0_fine_time;
83 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
77 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
84 spectral_matrix_regs->status = 0x01; // [0001]
78 spectral_matrix_regs->status = 0x01; // [0000 0001]
79 // if there are enough ring nodes ready, wake up an AVFx task
80 nb_sm_f0 = nb_sm_f0 + 1;
81 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
82 {
83 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
84 {
85 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
86 }
87 nb_sm_f0 = 0;
88 }
85 break;
89 break;
86 case 2:
90 case 2:
87 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
91 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0->previous;
88 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
89 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
92 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
90 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
93 ring_node_for_averaging_sm_f0->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
91 spectral_matrix_regs->status = 0x02; // [0010]
94 ring_node_for_averaging_sm_f0->fineTime = spectral_matrix_regs->f0_1_fine_time;
95 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
96 spectral_matrix_regs->status = 0x02; // [0000 0010]
97 // if there are enough ring nodes ready, wake up an AVFx task
98 nb_sm_f0 = nb_sm_f0 + 1;
99 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
100 {
101 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
102 {
103 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
104 }
105 nb_sm_f0 = 0;
106 }
92 break;
107 break;
93 }
108 }
94 }
109 }
95
110
96 void spectral_matrices_isr_f1( void )
111 void spectral_matrices_isr_f1( void )
97 {
112 {
113 rtems_status_code status_code;
98 unsigned char status;
114 unsigned char status;
99 unsigned long long int time;
100 unsigned long long int syncBit;
101 rtems_status_code status_code;
102
115
103 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
116 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
104
117
@@ -112,22 +125,40 void spectral_matrices_isr_f1( void )
112 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
125 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
113 break;
126 break;
114 case 1:
127 case 1:
115 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
128 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1->previous;
116 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
117 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
118 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
119 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
129 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
130 ring_node_for_averaging_sm_f1->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
131 ring_node_for_averaging_sm_f1->fineTime = spectral_matrix_regs->f1_0_fine_time;
120 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
132 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
121 spectral_matrix_regs->status = 0x04; // [0100]
133 spectral_matrix_regs->status = 0x04; // [0000 0100]
134 // if there are enough ring nodes ready, wake up an AVFx task
135 nb_sm_f1 = nb_sm_f1 + 1;
136 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
137 {
138 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
139 {
140 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
141 }
142 nb_sm_f1 = 0;
143 }
122 break;
144 break;
123 case 2:
145 case 2:
124 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
146 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1->previous;
125 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
126 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
127 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
128 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
147 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
148 ring_node_for_averaging_sm_f1->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
149 ring_node_for_averaging_sm_f1->fineTime = spectral_matrix_regs->f1_1_fine_time;
129 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
150 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
130 spectral_matrix_regs->status = 0x08; // [1000]
151 spectral_matrix_regs->status = 0x08; // [1000 0000]
152 // if there are enough ring nodes ready, wake up an AVFx task
153 nb_sm_f1 = nb_sm_f1 + 1;
154 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
155 {
156 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
157 {
158 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
159 }
160 nb_sm_f1 = 0;
161 }
131 break;
162 break;
132 }
163 }
133 }
164 }
@@ -139,10 +170,6 void spectral_matrices_isr_f2( void )
139
170
140 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
171 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
141
172
142 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
143
144 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
145
146 switch(status)
173 switch(status)
147 {
174 {
148 case 0:
175 case 0:
@@ -153,6 +180,8 void spectral_matrices_isr_f2( void )
153 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
180 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
154 break;
181 break;
155 case 1:
182 case 1:
183 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
184 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
156 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
185 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
157 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
186 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
158 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
187 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
@@ -163,6 +192,8 void spectral_matrices_isr_f2( void )
163 }
192 }
164 break;
193 break;
165 case 2:
194 case 2:
195 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
196 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
166 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
197 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
167 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
198 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
168 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
199 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
@@ -177,14 +208,14 void spectral_matrices_isr_f2( void )
177
208
178 void spectral_matrix_isr_error_handler( void )
209 void spectral_matrix_isr_error_handler( void )
179 {
210 {
180 // rtems_status_code status_code;
211 rtems_status_code status_code;
181
212
182 // if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
213 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
183 // {
214 {
184 // status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
215 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
185 // }
216 }
186
217
187 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
218 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
188 }
219 }
189
220
190 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
221 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
@@ -306,7 +337,7 void SM_reset_current_ring_nodes( void )
306 //*****************
337 //*****************
307 // Basic Parameters
338 // Basic Parameters
308
339
309 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
340 void BP_init_header( bp_packet *header,
310 unsigned int apid, unsigned char sid,
341 unsigned int apid, unsigned char sid,
311 unsigned int packetLength, unsigned char blkNr )
342 unsigned int packetLength, unsigned char blkNr )
312 {
343 {
@@ -325,15 +356,21 void BP_init_header( Header_TM_LFR_SCIEN
325 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
356 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
326 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
357 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
327 header->destinationID = TM_DESTINATION_ID_GROUND;
358 header->destinationID = TM_DESTINATION_ID_GROUND;
359 header->time[0] = 0x00;
360 header->time[1] = 0x00;
361 header->time[2] = 0x00;
362 header->time[3] = 0x00;
363 header->time[4] = 0x00;
364 header->time[5] = 0x00;
328 // AUXILIARY DATA HEADER
365 // AUXILIARY DATA HEADER
329 header->sid = sid;
366 header->sid = sid;
330 header->biaStatusInfo = 0x00;
367 header->biaStatusInfo = 0x00;
331 header->time[0] = 0x00;
368 header->acquisitionTime[0] = 0x00;
332 header->time[0] = 0x00;
369 header->acquisitionTime[1] = 0x00;
333 header->time[0] = 0x00;
370 header->acquisitionTime[2] = 0x00;
334 header->time[0] = 0x00;
371 header->acquisitionTime[3] = 0x00;
335 header->time[0] = 0x00;
372 header->acquisitionTime[4] = 0x00;
336 header->time[0] = 0x00;
373 header->acquisitionTime[5] = 0x00;
337 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
374 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
338 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
375 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
339 }
376 }
@@ -420,10 +457,13 void reset_spectral_matrix_regs( void )
420
457
421 reset_sm_status();
458 reset_sm_status();
422
459
460 // F1
423 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
461 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
424 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
462 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
463 // F2
425 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
464 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
426 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
465 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
466 // F3
427 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
467 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
428 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
468 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
429
469
@@ -453,37 +493,6 unsigned long long int get_acquisition_t
453 return acquisitionTimeAslong;
493 return acquisitionTimeAslong;
454 }
494 }
455
495
456 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
457 ring_node *node_for_averaging, ring_node *ringNode,
458 unsigned long long int time )
459 {
460 unsigned char *timePtr;
461 unsigned char *coarseTimePtr;
462 unsigned char *fineTimePtr;
463 rtems_status_code status_code;
464
465 timePtr = (unsigned char *) &time;
466 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
467 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
468
469 *nb_sm = *nb_sm + 1;
470 if (*nb_sm == nb_sm_before_avf)
471 {
472 node_for_averaging = ringNode;
473 coarseTimePtr[0] = timePtr[2];
474 coarseTimePtr[1] = timePtr[3];
475 coarseTimePtr[2] = timePtr[4];
476 coarseTimePtr[3] = timePtr[5];
477 fineTimePtr[2] = timePtr[6];
478 fineTimePtr[3] = timePtr[7];
479 if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
480 {
481 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
482 }
483 *nb_sm = 0;
484 }
485 }
486
487 unsigned char getSID( rtems_event_set event )
496 unsigned char getSID( rtems_event_set event )
488 {
497 {
489 unsigned char sid;
498 unsigned char sid;
@@ -466,9 +466,6 int stop_current_mode( void )
466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468
468
469 // reset lfr VHDL module
470 reset_lfr();
471
472 // (2) reset waveform picker registers
469 // (2) reset waveform picker registers
473 reset_wfp_burst_enable(); // reset burst and enable bits
470 reset_wfp_burst_enable(); // reset burst and enable bits
474 reset_wfp_status(); // reset all the status bits
471 reset_wfp_status(); // reset all the status bits
@@ -477,6 +474,9 int stop_current_mode( void )
477 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
474 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
478 reset_sm_status();
475 reset_sm_status();
479
476
477 // reset lfr VHDL module
478 reset_lfr();
479
480 reset_extractSWF(); // reset the extractSWF flag to false
480 reset_extractSWF(); // reset the extractSWF flag to false
481
481
482 // (4) clear interruptions
482 // (4) clear interruptions
@@ -769,7 +769,7 void launch_waveform_picker( unsigned ch
769 waveform_picker_regs->start_date = transitionCoarseTime;
769 waveform_picker_regs->start_date = transitionCoarseTime;
770 }
770 }
771
771
772 PRINTF1("commutation coarse time = %d\n", transitionCoarseTime)
772 PRINTF1("commutation coarse time = %x\n", transitionCoarseTime)
773 }
773 }
774
774
775 void launch_spectral_matrix( void )
775 void launch_spectral_matrix( void )
@@ -41,6 +41,50 ring_node ring_node_wf_snap_extracted;
41 //*********************
41 //*********************
42 // Interrupt SubRoutine
42 // Interrupt SubRoutine
43
43
44 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
45 {
46 ring_node *node;
47
48 node = NULL;
49 switch ( frequencyChannel ) {
50 case 1:
51 node = ring_node_to_send_cwf_f1;
52 break;
53 case 2:
54 node = ring_node_to_send_cwf_f2;
55 break;
56 case 3:
57 node = ring_node_to_send_cwf_f3;
58 break;
59 default:
60 break;
61 }
62
63 return node;
64 }
65
66 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
67 {
68 ring_node *node;
69
70 node = NULL;
71 switch ( frequencyChannel ) {
72 case 0:
73 node = ring_node_to_send_swf_f0;
74 break;
75 case 1:
76 node = ring_node_to_send_swf_f1;
77 break;
78 case 2:
79 node = ring_node_to_send_swf_f2;
80 break;
81 default:
82 break;
83 }
84
85 return node;
86 }
87
44 void reset_extractSWF( void )
88 void reset_extractSWF( void )
45 {
89 {
46 extractSWF = false;
90 extractSWF = false;
@@ -157,30 +201,37 inline void waveforms_isr_normal( void )
157
201
158 inline void waveforms_isr_burst( void )
202 inline void waveforms_isr_burst( void )
159 {
203 {
204 unsigned char status;
160 rtems_status_code spare_status;
205 rtems_status_code spare_status;
161
206
162 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
207 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
163 // (1) change the receiving buffer for the waveform picker
208
209 switch(status)
210 {
211 case 1:
164 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
212 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
165 current_ring_node_f2 = current_ring_node_f2->next;
213 current_ring_node_f2 = current_ring_node_f2->next;
166 if ( (waveform_picker_regs->status & 0x10) == 0x10)
167 {
168 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
214 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
169 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
215 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
170 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
216 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
171 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
217 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
218 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
219 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
172 }
220 }
173 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
221 break;
174 {
222 case 2:
223 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
224 current_ring_node_f2 = current_ring_node_f2->next;
175 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
225 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
176 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
226 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
177 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
227 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
178 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
179 }
180 // (2) send an event for the waveforms transmission
181 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
229 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
182 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
230 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
183 }
231 }
232 break;
233 default:
234 break;
184 }
235 }
185 }
236 }
186
237
@@ -442,13 +493,13 rtems_task wfrm_task(rtems_task_argument
442 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
493 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
443 if(resynchronisationEngaged == false)
494 if(resynchronisationEngaged == false)
444 { // engage resynchronisation
495 { // engage resynchronisation
445 // snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->coarseTime );
496 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
446 resynchronisationEngaged = true;
497 resynchronisationEngaged = true;
447 }
498 }
448 else
499 else
449 { // reset delta_snapshot to the nominal value
500 { // reset delta_snapshot to the nominal value
450 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
501 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
451 // set_wfp_delta_snapshot();
502 set_wfp_delta_snapshot();
452 resynchronisationEngaged = false;
503 resynchronisationEngaged = false;
453 }
504 }
454 //
505 //
@@ -532,12 +583,11 rtems_task cwf3_task(rtems_task_argument
532 {
583 {
533 PRINTF("send CWF_LONG_F3\n")
584 PRINTF("send CWF_LONG_F3\n")
534 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
585 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
535 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
586 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f3, sizeof( ring_node* ) );
536 }
587 }
537 else
588 else
538 {
589 {
539 PRINTF("send CWF_F3 (light)\n")
590 PRINTF("send CWF_F3 (light)\n")
540 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_F3;
541 send_waveform_CWF3_light( ring_node_to_send_cwf_f3, &ring_node_cwf3_light, queue_id );
591 send_waveform_CWF3_light( ring_node_to_send_cwf_f3, &ring_node_cwf3_light, queue_id );
542 }
592 }
543
593
@@ -564,6 +614,7 rtems_task cwf2_task(rtems_task_argument
564 rtems_event_set event_out;
614 rtems_event_set event_out;
565 rtems_id queue_id;
615 rtems_id queue_id;
566 rtems_status_code status;
616 rtems_status_code status;
617 ring_node *ring_node_to_send;
567
618
568 status = get_message_queue_id_send( &queue_id );
619 status = get_message_queue_id_send( &queue_id );
569 if (status != RTEMS_SUCCESSFUL)
620 if (status != RTEMS_SUCCESSFUL)
@@ -577,21 +628,26 rtems_task cwf2_task(rtems_task_argument
577 // wait for an RTEMS_EVENT
628 // wait for an RTEMS_EVENT
578 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
629 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
579 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
630 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
631 ring_node_to_send = getRingNodeToSendCWF( 2 );
632 printf("ring_node_to_send_cwf === coarse = %x, fine = %x\n", ring_node_to_send->coarseTime, ring_node_to_send->fineTime);
633 printf("**0** %x . %x", waveform_ring_f2[0].coarseTime, waveform_ring_f2[0].fineTime);
634 printf(" **1** %x . %x", waveform_ring_f2[1].coarseTime, waveform_ring_f2[1].fineTime);
635 printf(" **2** %x . %x", waveform_ring_f2[2].coarseTime, waveform_ring_f2[2].fineTime);
636 printf(" **3** %x . %x", waveform_ring_f2[3].coarseTime, waveform_ring_f2[3].fineTime);
637 printf(" **4** %x . %x\n", waveform_ring_f2[4].coarseTime, waveform_ring_f2[4].fineTime);
580 if (event_out == RTEMS_EVENT_MODE_BURST)
638 if (event_out == RTEMS_EVENT_MODE_BURST)
581 {
639 {
582 // send_waveform_CWF( ring_node_to_send_cwf_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
640 ring_node_to_send->sid = SID_BURST_CWF_F2;
583 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
641 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
584 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
585 }
642 }
586 if (event_out == RTEMS_EVENT_MODE_SBM2)
643 if (event_out == RTEMS_EVENT_MODE_SBM2)
587 {
644 {
588 // send_waveform_CWF( ring_node_to_send_cwf_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
645 ring_node_to_send->sid = SID_SBM2_CWF_F2;
589 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
646 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
590 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
591 // launch snapshot extraction if needed
647 // launch snapshot extraction if needed
592 if (extractSWF == true)
648 if (extractSWF == true)
593 {
649 {
594 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
650 ring_node_to_send_swf_f2 = ring_node_to_send;
595 // extract the snapshot
651 // extract the snapshot
596 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
652 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
597 // send the snapshot when built
653 // send the snapshot when built
@@ -623,7 +679,7 rtems_task cwf1_task(rtems_task_argument
623 rtems_id queue_id;
679 rtems_id queue_id;
624 rtems_status_code status;
680 rtems_status_code status;
625
681
626 // init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
682 ring_node * ring_node_to_send_cwf;
627
683
628 status = get_message_queue_id_send( &queue_id );
684 status = get_message_queue_id_send( &queue_id );
629 if (status != RTEMS_SUCCESSFUL)
685 if (status != RTEMS_SUCCESSFUL)
@@ -637,12 +693,19 rtems_task cwf1_task(rtems_task_argument
637 // wait for an RTEMS_EVENT
693 // wait for an RTEMS_EVENT
638 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
694 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
639 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
695 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
696 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
697 printf("ring_node_to_send_cwf === coarse = %x, fine = %x\n", ring_node_to_send_cwf->coarseTime, ring_node_to_send_cwf->fineTime);
698 printf("**0** %x . %x", waveform_ring_f1[0].coarseTime, waveform_ring_f1[0].fineTime);
699 printf(" **1** %x . %x", waveform_ring_f1[1].coarseTime, waveform_ring_f1[1].fineTime);
700 printf(" **2** %x . %x", waveform_ring_f1[2].coarseTime, waveform_ring_f1[2].fineTime);
701 printf(" **3** %x . %x", waveform_ring_f1[3].coarseTime, waveform_ring_f1[3].fineTime);
702 printf(" **4** %x . %x\n\n", waveform_ring_f1[4].coarseTime, waveform_ring_f1[4].fineTime);
640 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
703 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
641 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f1, sizeof( ring_node* ) );
704 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
642 // launch snapshot extraction if needed
705 // launch snapshot extraction if needed
643 if (extractSWF == true)
706 if (extractSWF == true)
644 {
707 {
645 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
708 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
646 // launch the snapshot extraction
709 // launch the snapshot extraction
647 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
710 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
648 extractSWF = false;
711 extractSWF = false;
@@ -750,18 +813,17 void init_ring(ring_node ring[], unsigne
750
813
751 void WFP_reset_current_ring_nodes( void )
814 void WFP_reset_current_ring_nodes( void )
752 {
815 {
753 current_ring_node_f0 = waveform_ring_f0;
816 current_ring_node_f0 = waveform_ring_f0[0].next;
754 ring_node_to_send_swf_f0 = waveform_ring_f0;
817 current_ring_node_f1 = waveform_ring_f1[0].next;
818 current_ring_node_f2 = waveform_ring_f2[0].next;
819 current_ring_node_f3 = waveform_ring_f3[0].next;
755
820
756 current_ring_node_f1 = waveform_ring_f1;
821 ring_node_to_send_swf_f0 = waveform_ring_f0;
757 ring_node_to_send_cwf_f1 = waveform_ring_f1;
758 ring_node_to_send_swf_f1 = waveform_ring_f1;
822 ring_node_to_send_swf_f1 = waveform_ring_f1;
759
760 current_ring_node_f2 = waveform_ring_f2;
761 ring_node_to_send_cwf_f2 = waveform_ring_f2;
762 ring_node_to_send_swf_f2 = waveform_ring_f2;
823 ring_node_to_send_swf_f2 = waveform_ring_f2;
763
824
764 current_ring_node_f3 = waveform_ring_f3;
825 ring_node_to_send_cwf_f1 = waveform_ring_f1;
826 ring_node_to_send_cwf_f2 = waveform_ring_f2;
765 ring_node_to_send_cwf_f3 = waveform_ring_f3;
827 ring_node_to_send_cwf_f3 = waveform_ring_f3;
766 }
828 }
767
829
@@ -782,13 +844,10 int send_waveform_CWF3_light( ring_node
782 unsigned int i;
844 unsigned int i;
783 int ret;
845 int ret;
784 rtems_status_code status;
846 rtems_status_code status;
785 spw_ioctl_pkt_send spw_ioctl_send_CWF;
847
786 char *sample;
848 char *sample;
787 int *dataPtr;
849 int *dataPtr;
788
850
789 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
790 spw_ioctl_send_CWF.options = 0;
791
792 ret = LFR_DEFAULT;
851 ret = LFR_DEFAULT;
793
852
794 dataPtr = (int*) ring_node_to_send->buffer_address;
853 dataPtr = (int*) ring_node_to_send->buffer_address;
@@ -1076,20 +1135,16 void reset_wfp_status( void )
1076 void reset_wfp_buffer_addresses( void )
1135 void reset_wfp_buffer_addresses( void )
1077 {
1136 {
1078 // F0
1137 // F0
1079 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1138 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08
1080 current_ring_node_f0 = current_ring_node_f0->next;
1081 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1139 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1082 // F1
1140 // F1
1083 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1141 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10
1084 current_ring_node_f1 = current_ring_node_f1->next;
1085 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1142 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1086 // F2
1143 // F2
1087 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1144 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18
1088 current_ring_node_f2 = current_ring_node_f2->next;
1089 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1145 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1090 // F3
1146 // F3
1091 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1147 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20
1092 current_ring_node_f3 = current_ring_node_f3->next;
1093 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1148 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1094 }
1149 }
1095
1150
General Comments 0
You need to be logged in to leave comments. Login now