##// 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
2 da5613aff4446e5c98b3c56bc32ce7008b3e2340 header/lfr_common_headers
1 a309a930a482e851061936696121f4a1cf7005de LFR_basic-parameters
2 2b5dc338fb623046072d6eb98c26ad884e17f95e header/lfr_common_headers
@@ -12,7 +12,7 SWVERSION=-1-0
12 12 DEFINES += SW_VERSION_N1=2 # major
13 13 DEFINES += SW_VERSION_N2=0 # minor
14 14 DEFINES += SW_VERSION_N3=2 # patch
15 DEFINES += SW_VERSION_N4=0 # internal
15 DEFINES += SW_VERSION_N4=1 # internal
16 16
17 17 # <GCOV>
18 18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
@@ -28,6 +28,7 contains( CONFIG, lpp_dpu_destid ) {
28 28 contains( CONFIG, debug_tch ) {
29 29 DEFINES += DEBUG_TCH
30 30 }
31 DEFINES += LSB_FIRST_TCH
31 32
32 33 contains( CONFIG, vhdl_dev ) {
33 34 DEFINES += VHDL_DEV
@@ -64,7 +65,7 INCLUDEPATH += \
64 65 $${PWD}/../header \
65 66 $${PWD}/../header/lfr_common_headers \
66 67 $${PWD}/../header/processing \
67 $${PWD}/../src/LFR_basic-parameters
68 $${PWD}/../LFR_basic-parameters
68 69
69 70 SOURCES += \
70 71 ../src/wf_handler.c \
@@ -81,7 +82,7 SOURCES += \
81 82 ../src/processing/avf1_prc1.c \
82 83 ../src/processing/avf2_prc2.c \
83 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 87 HEADERS += \
87 88 ../header/wf_handler.h \
@@ -99,12 +100,12 HEADERS += \
99 100 ../header/processing/avf2_prc2.h \
100 101 ../header/fsw_params_wf_handler.h \
101 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 103 ../header/lfr_common_headers/ccsds_types.h \
105 104 ../header/lfr_common_headers/fsw_params.h \
106 105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
107 106 ../header/lfr_common_headers/fsw_params_processing.h \
108 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 90 volatile unsigned int f3_1_fine_time; // 0x88
91 91 //
92 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 97 } waveform_picker_regs_0_1_18_t;
94 98
95 99 typedef struct {
@@ -111,7 +115,7 typedef struct {
111 115 volatile unsigned int f1_0_coarse_time; // 0x30
112 116 volatile unsigned int f1_0_fine_time; // 0x34
113 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 120 volatile unsigned int f2_0_coarse_time; // 0x40
117 121 volatile unsigned int f2_0_fine_time; // 0x44
@@ -27,10 +27,11 rtems_task prc0_task( rtems_task_argumen
27 27 // FUNCTIONS
28 28
29 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 34 // EXTERN
33 extern ring_node *ring_node_for_averaging_sm_f0;
34 35 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35 36
36 37 #endif // AVF0_PRC0_H_INCLUDED
@@ -2,6 +2,7
2 2 #define AVF1_PRC1_H
3 3
4 4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5 6
6 7 typedef struct {
7 8 unsigned int norm_bp1;
@@ -24,10 +25,10 rtems_task prc1_task( rtems_task_argumen
24 25 // FUNCTIONS
25 26
26 27 void reset_nb_sm_f1( unsigned char lfrMode );
28 void init_k_coefficients_f1( void );
27 29
28 30 //*******
29 31 // EXTERN
30 extern struct ring_node *ring_node_for_averaging_sm_f1;
31 32 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
32 33
33 34 #endif // AVF1_PRC1_H
@@ -2,6 +2,7
2 2 #define AVF2_PRC2_H
3 3
4 4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5 6
6 7 typedef struct {
7 8 unsigned int norm_bp1;
@@ -18,11 +19,11 rtems_task prc2_task( rtems_task_argumen
18 19 // FUNCTIONS
19 20
20 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 26 // EXTERN
25 extern struct ring_node *ring_node_for_averaging_sm_f2;
26 27 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
27 28
28 29 #endif // AVF2_PRC2_H
@@ -21,7 +21,25 typedef struct ring_node_asm
21 21
22 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 43 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
26 44 } bp_packet;
27 45
@@ -36,8 +54,10 typedef struct
36 54 ring_node_asm *norm;
37 55 ring_node_asm *burst_sbm;
38 56 rtems_event_set event;
39 unsigned int coarseTime;
40 unsigned int fineTime;
57 unsigned int coarseTimeNORM;
58 unsigned int fineTimeNORM;
59 unsigned int coarseTimeSBM;
60 unsigned int fineTimeSBM;
41 61 } asm_msg;
42 62
43 63 extern volatile int sm_f0[ ];
@@ -49,11 +69,13 extern struct param_local_str param_loca
49 69
50 70 // registers
51 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 74 extern rtems_name misc_name[5];
55 75 extern rtems_id Task_id[20]; /* array of task ids */
56 76
77 //
78 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
57 79 // ISR
58 80 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
59 81 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
@@ -71,7 +93,7 void ASM_generic_init_ring(ring_node_asm
71 93 // Basic Parameters
72 94
73 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 97 unsigned int apid, unsigned char sid,
76 98 unsigned int packetLength , unsigned char blkNr);
77 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 109 void reset_spectral_matrix_regs( void );
88 110 void set_time(unsigned char *time, unsigned char *timeInBuffer );
89 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 112 unsigned char getSID( rtems_event_set event );
93 113
94 114 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
@@ -97,11 +117,12 extern rtems_status_code get_message_que
97 117 //***************************************
98 118 // DEFINITIONS OF STATIC INLINE FUNCTIONS
99 119 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
100 ring_node *ring_node_tab[],
101 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
120 ring_node *ring_node_tab[],
121 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
122 asm_msg *msgForMATR );
102 123 static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
103 ring_node *ring_node_tab[],
104 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
124 ring_node *ring_node_tab[],
125 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
105 126 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
106 127 float divider );
107 128 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
@@ -110,8 +131,9 static inline void ASM_compress_reorgani
110 131 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
111 132
112 133 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
113 ring_node *ring_node_tab[],
114 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
134 ring_node *ring_node_tab[],
135 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
136 asm_msg *msgForMATR )
115 137 {
116 138 float sum;
117 139 unsigned int i;
@@ -131,6 +153,10 void SM_average( float *averaged_spec_ma
131 153 {
132 154 averaged_spec_mat_NORM[ i ] = sum;
133 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 161 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
136 162 {
@@ -141,6 +167,8 void SM_average( float *averaged_spec_ma
141 167 {
142 168 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
143 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 173 else
146 174 {
@@ -186,21 +214,22 void ASM_reorganize_and_divide( float *a
186 214 {
187 215 int frequencyBin;
188 216 int asmComponent;
189 unsigned int offsetAveragedSpecMatReorganized;
190 unsigned int offsetAveragedSpecMat;
217 unsigned int offsetASM;
218 unsigned int offsetASMReorganized;
191 219
220 // BUILD DATA
192 221 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
193 222 {
194 223 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
195 224 {
196 offsetAveragedSpecMatReorganized =
225 offsetASMReorganized =
197 226 frequencyBin * NB_VALUES_PER_SM
198 227 + asmComponent;
199 offsetAveragedSpecMat =
228 offsetASM =
200 229 asmComponent * NB_BINS_PER_SM
201 230 + frequencyBin;
202 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
203 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
231 averaged_spec_mat_reorganized[offsetASMReorganized ] =
232 averaged_spec_mat[ offsetASM ] / divider;
204 233 }
205 234 }
206 235 }
@@ -214,7 +243,7 void ASM_compress_reorganize_and_divide(
214 243 int offsetCompressed;
215 244 int k;
216 245
217 // build data
246 // BUILD DATA
218 247 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
219 248 {
220 249 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
@@ -231,8 +260,10 void ASM_compress_reorganize_and_divide(
231 260 {
232 261 compressed_spec_mat[offsetCompressed ] =
233 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 108 init_parameter_dump();
109 109 init_local_mode_parameters();
110 110 init_housekeeping_parameters();
111 init_k_coefficients_f0();
112 init_k_coefficients_f1();
113 init_k_coefficients_f2();
111 114
112 115 // waveform picker initialization
113 116 WFP_init_rings(); // initialize the waveform rings
@@ -215,6 +218,8 rtems_task Init( rtems_task_argument ign
215 218
216 219 BOOT_PRINTF("delete INIT\n")
217 220
221 // test_TCH();
222
218 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 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 229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230 230
231 231 // SEND PACKET
@@ -443,107 +443,20 void send_dumb_hk( void )
443 443
444 444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
445 445 {
446 unsigned long long int localTime_asLong;
447 unsigned long long int f3_0_AcquisitionTime_asLong;
448 unsigned long long int f3_1_AcquisitionTime_asLong;
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 }
446 unsigned char* v_ptr;
447 unsigned char* e1_ptr;
448 unsigned char* e2_ptr;
492 449
493 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
494 {
495 if ( deltaT_f3_0 > deltaT_f3_1 )
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 }
450 v_ptr = (unsigned char *) &waveform_picker_regs->v;
451 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
452 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
520 453
521 if ( deltaT == 0xffffffff )
522 {
523 spacecraft_potential[0] = 0x00;
524 spacecraft_potential[1] = 0x00;
525 spacecraft_potential[2] = 0x00;
526 spacecraft_potential[3] = 0x00;
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 }
454 spacecraft_potential[0] = v_ptr[2];
455 spacecraft_potential[1] = v_ptr[3];
456 spacecraft_potential[2] = e1_ptr[2];
457 spacecraft_potential[3] = e1_ptr[3];
458 spacecraft_potential[4] = e2_ptr[2];
459 spacecraft_potential[5] = e2_ptr[3];
547 460 }
548 461
549 462 void get_cpu_load( unsigned char *resource_statistics )
@@ -690,8 +690,8 void init_header_cwf( Header_TM_LFR_SCIE
690 690 header->userApplication = CCSDS_USER_APP;
691 691 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
692 692 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
693 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
694 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
693 header->packetLength[0] = 0x00;
694 header->packetLength[1] = 0x00;
695 695 // DATA FIELD HEADER
696 696 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
697 697 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
@@ -706,8 +706,8 void init_header_cwf( Header_TM_LFR_SCIE
706 706 // AUXILIARY DATA HEADER
707 707 header->sid = 0x00;
708 708 header->hkBIA = DEFAULT_HKBIA;
709 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
710 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
709 header->blkNr[0] = 0x00;
710 header->blkNr[1] = 0x00;
711 711 }
712 712
713 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 808 fineTime = ring_node_to_send->fineTime;
809 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 816 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
812 817 {
813 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 979 fineTime = ring_node_to_send->fineTime;
975 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 988 // SEND CWF3_light DATA
979 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 24 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
25 25 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
26 26 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
27 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
28 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
27
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 32 // RTEMS TASKS
@@ -38,6 +39,7 rtems_task avf0_task( rtems_task_argumen
38 39 rtems_status_code status;
39 40 rtems_id queue_id_prc0;
40 41 asm_msg msgForMATR;
42 ring_node *nodeForAveraging;
41 43 ring_node *ring_node_tab[8];
42 44 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
43 45 ring_node_asm *current_ring_node_asm_norm_f0;
@@ -76,23 +78,24 rtems_task avf0_task( rtems_task_argumen
76 78 msgForMATR.norm = current_ring_node_asm_norm_f0;
77 79 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
78 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 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;
88 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
89 nodeForAveraging = nodeForAveraging->previous;
90 ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging;
89 91 }
90 92
91 93 // compute the average and store it in the averaged_sm_f1 buffer
92 94 SM_average( current_ring_node_asm_norm_f0->matrix,
93 95 current_ring_node_asm_burst_sbm_f0->matrix,
94 96 ring_node_tab,
95 nb_norm_bp1, nb_sbm_bp1 );
97 nb_norm_bp1, nb_sbm_bp1,
98 &msgForMATR );
96 99
97 100 // update nb_average
98 101 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
@@ -157,7 +160,6 rtems_task avf0_task( rtems_task_argumen
157 160 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 161 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 162 {
160 // PRINTF1("%lld\n", localTime)
161 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 187 rtems_status_code status;
186 188 rtems_id queue_id;
187 189 rtems_id queue_id_q_p0;
188 bp_packet_with_spare packet_norm_bp1_f0;
189 bp_packet packet_norm_bp2_f0;
190 bp_packet packet_sbm_bp1_f0;
191 bp_packet packet_sbm_bp2_f0;
190 bp_packet_with_spare packet_norm_bp1;
191 bp_packet packet_norm_bp2;
192 bp_packet packet_sbm_bp1;
193 bp_packet packet_sbm_bp2;
192 194 ring_node *current_ring_node_to_send_asm_f0;
193 195
194 196 unsigned long long int localTime;
@@ -199,10 +201,10 rtems_task prc0_task( rtems_task_argumen
199 201
200 202 //*************
201 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 205 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
204 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 208 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
207 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 212 // BURST SBM1 and SBM2 headers
211 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 216 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
215 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 219 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
218 220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
219 221 }
220 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 225 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
224 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 228 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
227 229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 230 }
229 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 234 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
233 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 237 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
236 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 277 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
276 278 ASM_F0_INDICE_START);
277 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 281 // 3) send the BP1 set
280 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
281 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
282 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
282 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
283 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
284 BP_send( (char *) &packet_sbm_bp1, queue_id,
283 285 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
284 286 sid);
285 287 // 4) compute the BP2 set if needed
286 288 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
287 289 {
288 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 292 // 2) send the BP2 set
291 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
292 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
293 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
293 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
294 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
295 BP_send( (char *) &packet_sbm_bp2, queue_id,
294 296 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
295 297 sid);
296 298 }
@@ -309,23 +311,63 rtems_task prc0_task( rtems_task_argumen
309 311 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
310 312 ASM_F0_INDICE_START );
311 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 315 // 3) send the BP1 set
314 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
315 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
316 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
316 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
317 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
318 BP_send( (char *) &packet_norm_bp1, queue_id,
317 319 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
318 320 SID_NORM_BP1_F0 );
319 321 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
320 322 {
321 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 325 // 2) send the BP2 set
324 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
325 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
326 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
326 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
327 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
328 BP_send( (char *) &packet_norm_bp2, queue_id,
327 329 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
328 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 379 nb_sm_before_f0.norm_bp1 );
338 380 // 2) convert the float array in a char array
339 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;
341 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTime;
382 current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM;
383 current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM;
342 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 401 // 3) send the spectral matrix packets
344 402 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
345 403 // change asm ring node
@@ -385,3 +443,56 void reset_nb_sm_f0( unsigned char lfrMo
385 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 12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
13 13
14 extern ring_node sm_ring_f1[ ];
15
14 16 //***
15 17 // F1
16 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 26 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
25 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 33 // RTEMS TASKS
29 34
@@ -35,7 +40,8 rtems_task avf1_task( rtems_task_argumen
35 40 rtems_status_code status;
36 41 rtems_id queue_id_prc1;
37 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 45 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
40 46 ring_node_asm *current_ring_node_asm_norm_f1;
41 47
@@ -73,23 +79,24 rtems_task avf1_task( rtems_task_argumen
73 79 msgForMATR.norm = current_ring_node_asm_norm_f1;
74 80 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
75 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 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;
85 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
90 nodeForAveraging = nodeForAveraging->previous;
91 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
86 92 }
87 93
88 94 // compute the average and store it in the averaged_sm_f1 buffer
89 95 SM_average( current_ring_node_asm_norm_f1->matrix,
90 96 current_ring_node_asm_burst_sbm_f1->matrix,
91 97 ring_node_tab,
92 nb_norm_bp1, nb_sbm_bp1 );
98 nb_norm_bp1, nb_sbm_bp1,
99 &msgForMATR );
93 100
94 101 // update nb_average
95 102 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
@@ -198,7 +205,7 rtems_task prc1_task( rtems_task_argumen
198 205 BP_init_header_with_spare( &packet_norm_bp1.header,
199 206 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
200 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 209 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
203 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 213 // BURST and SBM2 headers
207 214 if ( lfrRequestedMode == LFR_MODE_BURST )
208 215 {
209 BP_init_header( &packet_sbm_bp1.header,
216 BP_init_header( &packet_sbm_bp1,
210 217 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
211 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 220 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
214 221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
215 222 }
216 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 226 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
220 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 229 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
223 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 268 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
262 269 ASM_F1_INDICE_START);
263 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 272 // 3) send the BP1 set
266 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
267 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
273 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
274 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
268 275 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
269 276 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
270 277 sid );
@@ -272,10 +279,10 rtems_task prc1_task( rtems_task_argumen
272 279 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
273 280 {
274 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 283 // 2) send the BP2 set
277 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
278 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
284 set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
285 set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
279 286 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
280 287 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
281 288 sid );
@@ -295,20 +302,20 rtems_task prc1_task( rtems_task_argumen
295 302 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
296 303 ASM_F0_INDICE_START );
297 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 306 // 3) send the BP1 set
300 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
301 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
307 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
308 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
302 309 BP_send( (char *) &packet_norm_bp1, queue_id_send,
303 310 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
304 311 SID_NORM_BP1_F1 );
305 312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
306 313 {
307 314 // 1) compute the BP2 set
308
315 BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data );
309 316 // 2) send the BP2 set
310 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
311 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
317 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
318 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
312 319 BP_send( (char *) &packet_norm_bp2, queue_id_send,
313 320 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
314 321 SID_NORM_BP2_F1 );
@@ -323,8 +330,8 rtems_task prc1_task( rtems_task_argumen
323 330 nb_sm_before_f1.norm_bp1 );
324 331 // 2) convert the float array in a char array
325 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;
327 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTime;
333 current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM;
334 current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM;
328 335 current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1;
329 336 // 3) send the spectral matrix packets
330 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,19 +11,23
11 11
12 12 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
13 13
14 extern ring_node sm_ring_f2[ ];
15
14 16 //***
15 17 // F2
16 18 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
17 19 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
18 20
19 ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ];
20 int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ];
21 ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ];
22 int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ];
21 23
22 24 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
23 25 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
24 26 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
25 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 32 // RTEMS TASKS
29 33
@@ -35,6 +39,7 rtems_task avf2_task( rtems_task_argumen
35 39 rtems_status_code status;
36 40 rtems_id queue_id_prc2;
37 41 asm_msg msgForMATR;
42 ring_node *nodeForAveraging;
38 43 ring_node_asm *current_ring_node_asm_norm_f2;
39 44
40 45 unsigned int nb_norm_bp1;
@@ -65,15 +70,28 rtems_task avf2_task( rtems_task_argumen
65 70 msgForMATR.norm = current_ring_node_asm_norm_f2;
66 71 msgForMATR.burst_sbm = NULL;
67 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 90 // compute the average and store it in the averaged_sm_f2 buffer
74 91 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
75 ring_node_for_averaging_sm_f2,
76 nb_norm_bp1 );
92 nodeForAveraging,
93 nb_norm_bp1,
94 &msgForMATR );
77 95
78 96 // update nb_average
79 97 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
@@ -108,7 +126,6 rtems_task avf2_task( rtems_task_argumen
108 126 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
109 127 || (lfrCurrentMode == LFR_MODE_SBM2) )
110 128 {
111 // PRINTF1("%lld\n", localTime)
112 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 152 rtems_status_code status;
136 153 rtems_id queue_id;
137 154 rtems_id queue_id_q_p2;
138 bp_packet packet_norm_bp1_f2;
139 bp_packet packet_norm_bp2_f2;
155 bp_packet packet_norm_bp1;
156 bp_packet packet_norm_bp2;
140 157 ring_node *current_ring_node_to_send_asm_f2;
141 158
142 159 unsigned long long int localTime;
@@ -149,10 +166,10 rtems_task prc2_task( rtems_task_argumen
149 166
150 167 //*************
151 168 // NORM headers
152 BP_init_header( &packet_norm_bp1_f2.header,
169 BP_init_header( &packet_norm_bp1,
153 170 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
154 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 173 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
157 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 207 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
191 208 ASM_F2_INDICE_START );
192 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 211 // 3) send the BP1 set
195 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
196 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
197 BP_send( (char *) &packet_norm_bp1_f2, queue_id,
212 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
213 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
214 BP_send( (char *) &packet_norm_bp1, queue_id,
198 215 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
199 216 SID_NORM_BP1_F2 );
200 217 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
201 218 {
202 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 221 // 2) send the BP2 set
205 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
206 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
207 BP_send( (char *) &packet_norm_bp2_f2, queue_id,
222 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
223 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
224 BP_send( (char *) &packet_norm_bp2, queue_id,
208 225 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
209 226 SID_NORM_BP2_F2 );
210 227 }
@@ -218,8 +235,8 rtems_task prc2_task( rtems_task_argumen
218 235 nb_sm_before_f2.norm_bp1 );
219 236 // 2) convert the float array in a char array
220 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;
222 current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTime;
238 current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM;
239 current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM;
223 240 current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2;
224 241 // 3) send the spectral matrix packets
225 242 status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f2, sizeof( ring_node* ) );
@@ -241,8 +258,9 void reset_nb_sm_f2( void )
241 258 }
242 259
243 260 void SM_average_f2( float *averaged_spec_mat_f2,
244 ring_node *ring_node,
245 unsigned int nbAverageNormF2 )
261 ring_node *ring_node,
262 unsigned int nbAverageNormF2,
263 asm_msg *msgForMATR )
246 264 {
247 265 float sum;
248 266 unsigned int i;
@@ -253,6 +271,8 void SM_average_f2( float *averaged_spec
253 271 if ( (nbAverageNormF2 == 0) )
254 272 {
255 273 averaged_spec_mat_f2[ i ] = sum;
274 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
275 msgForMATR->fineTimeNORM = ring_node->fineTime;
256 276 }
257 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 27 ring_node *ring_node_for_averaging_sm_f1;
28 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 54 // Interrupt Service Routine for spectral matrices processing
32 55
33 56 void spectral_matrices_isr_f0( void )
34 57 {
35 58 unsigned char status;
36 unsigned long long int time_0;
37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
59 rtems_status_code status_code;
40 60
41 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 63 switch(status)
49 64 {
50 65 case 0:
51 66 break;
52 67 case 3:
53 // send a message if two buffers are ready
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 }
68 // UNEXPECTED VALUE
77 69 spectral_matrix_regs->status = 0x03; // [0011]
70 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
78 71 break;
79 72 case 1:
80 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
81 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
73 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0->previous;
82 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 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 89 break;
86 90 case 2:
87 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
88 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
91 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0->previous;
89 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;
91 spectral_matrix_regs->status = 0x02; // [0010]
93 ring_node_for_averaging_sm_f0->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
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 107 break;
93 108 }
94 109 }
95 110
96 111 void spectral_matrices_isr_f1( void )
97 112 {
113 rtems_status_code status_code;
98 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 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 125 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
113 126 break;
114 127 case 1:
115 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
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);
128 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1->previous;
119 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 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 144 break;
123 145 case 2:
124 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
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);
146 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1->previous;
128 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 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 162 break;
132 163 }
133 164 }
@@ -139,10 +170,6 void spectral_matrices_isr_f2( void )
139 170
140 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 173 switch(status)
147 174 {
148 175 case 0:
@@ -153,6 +180,8 void spectral_matrices_isr_f2( void )
153 180 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
154 181 break;
155 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 185 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
157 186 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
158 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 193 break;
165 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 197 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
167 198 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
168 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 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]
183 // {
184 // status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
185 // }
213 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
214 {
215 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
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 221 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
@@ -306,7 +337,7 void SM_reset_current_ring_nodes( void )
306 337 //*****************
307 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 341 unsigned int apid, unsigned char sid,
311 342 unsigned int packetLength, unsigned char blkNr )
312 343 {
@@ -325,15 +356,21 void BP_init_header( Header_TM_LFR_SCIEN
325 356 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
326 357 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
327 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 365 // AUXILIARY DATA HEADER
329 366 header->sid = sid;
330 367 header->biaStatusInfo = 0x00;
331 header->time[0] = 0x00;
332 header->time[0] = 0x00;
333 header->time[0] = 0x00;
334 header->time[0] = 0x00;
335 header->time[0] = 0x00;
336 header->time[0] = 0x00;
368 header->acquisitionTime[0] = 0x00;
369 header->acquisitionTime[1] = 0x00;
370 header->acquisitionTime[2] = 0x00;
371 header->acquisitionTime[3] = 0x00;
372 header->acquisitionTime[4] = 0x00;
373 header->acquisitionTime[5] = 0x00;
337 374 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
338 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 458 reset_sm_status();
422 459
460 // F1
423 461 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
424 462 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
463 // F2
425 464 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
426 465 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
466 // F3
427 467 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
428 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 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 496 unsigned char getSID( rtems_event_set event )
488 497 {
489 498 unsigned char sid;
@@ -466,9 +466,6 int stop_current_mode( void )
466 466 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 467 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 468
469 // reset lfr VHDL module
470 reset_lfr();
471
472 469 // (2) reset waveform picker registers
473 470 reset_wfp_burst_enable(); // reset burst and enable bits
474 471 reset_wfp_status(); // reset all the status bits
@@ -477,6 +474,9 int stop_current_mode( void )
477 474 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
478 475 reset_sm_status();
479 476
477 // reset lfr VHDL module
478 reset_lfr();
479
480 480 reset_extractSWF(); // reset the extractSWF flag to false
481 481
482 482 // (4) clear interruptions
@@ -769,7 +769,7 void launch_waveform_picker( unsigned ch
769 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 775 void launch_spectral_matrix( void )
@@ -41,6 +41,50 ring_node ring_node_wf_snap_extracted;
41 41 //*********************
42 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 88 void reset_extractSWF( void )
45 89 {
46 90 extractSWF = false;
@@ -157,30 +201,37 inline void waveforms_isr_normal( void )
157 201
158 202 inline void waveforms_isr_burst( void )
159 203 {
204 unsigned char status;
160 205 rtems_status_code spare_status;
161 206
162 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
163 // (1) change the receiving buffer for the waveform picker
207 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
208
209 switch(status)
210 {
211 case 1:
164 212 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
165 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;
169 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;
171 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
172 }
173 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
174 {
175 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;
177 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]
179 }
180 // (2) send an event for the waveforms transmission
214 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
215 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
216 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
217 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
181 218 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
182 219 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
183 220 }
221 break;
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;
225 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
226 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
227 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
229 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
230 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
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 493 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
443 494 if(resynchronisationEngaged == false)
444 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 497 resynchronisationEngaged = true;
447 498 }
448 499 else
449 500 { // reset delta_snapshot to the nominal value
450 501 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
451 // set_wfp_delta_snapshot();
502 set_wfp_delta_snapshot();
452 503 resynchronisationEngaged = false;
453 504 }
454 505 //
@@ -532,12 +583,11 rtems_task cwf3_task(rtems_task_argument
532 583 {
533 584 PRINTF("send CWF_LONG_F3\n")
534 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 588 else
538 589 {
539 590 PRINTF("send CWF_F3 (light)\n")
540 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_F3;
541 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 614 rtems_event_set event_out;
565 615 rtems_id queue_id;
566 616 rtems_status_code status;
617 ring_node *ring_node_to_send;
567 618
568 619 status = get_message_queue_id_send( &queue_id );
569 620 if (status != RTEMS_SUCCESSFUL)
@@ -577,21 +628,26 rtems_task cwf2_task(rtems_task_argument
577 628 // wait for an RTEMS_EVENT
578 629 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
579 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 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 );
583 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
584 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
640 ring_node_to_send->sid = SID_BURST_CWF_F2;
641 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
585 642 }
586 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 );
589 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
590 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
645 ring_node_to_send->sid = SID_SBM2_CWF_F2;
646 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
591 647 // launch snapshot extraction if needed
592 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 651 // extract the snapshot
596 652 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
597 653 // send the snapshot when built
@@ -623,7 +679,7 rtems_task cwf1_task(rtems_task_argument
623 679 rtems_id queue_id;
624 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 684 status = get_message_queue_id_send( &queue_id );
629 685 if (status != RTEMS_SUCCESSFUL)
@@ -637,12 +693,19 rtems_task cwf1_task(rtems_task_argument
637 693 // wait for an RTEMS_EVENT
638 694 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
639 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 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 705 // launch snapshot extraction if needed
643 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 709 // launch the snapshot extraction
647 710 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
648 711 extractSWF = false;
@@ -750,18 +813,17 void init_ring(ring_node ring[], unsigne
750 813
751 814 void WFP_reset_current_ring_nodes( void )
752 815 {
753 current_ring_node_f0 = waveform_ring_f0;
754 ring_node_to_send_swf_f0 = waveform_ring_f0;
816 current_ring_node_f0 = waveform_ring_f0[0].next;
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;
757 ring_node_to_send_cwf_f1 = waveform_ring_f1;
821 ring_node_to_send_swf_f0 = waveform_ring_f0;
758 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 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 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 844 unsigned int i;
783 845 int ret;
784 846 rtems_status_code status;
785 spw_ioctl_pkt_send spw_ioctl_send_CWF;
847
786 848 char *sample;
787 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 851 ret = LFR_DEFAULT;
793 852
794 853 dataPtr = (int*) ring_node_to_send->buffer_address;
@@ -1076,21 +1135,17 void reset_wfp_status( void )
1076 1135 void reset_wfp_buffer_addresses( void )
1077 1136 {
1078 1137 // F0
1079 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->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
1138 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08
1139 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1082 1140 // F1
1083 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->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
1141 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10
1142 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1086 1143 // F2
1087 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->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
1144 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18
1145 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1090 1146 // F3
1091 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->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
1147 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20
1148 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1094 1149 }
1095 1150
1096 1151 void reset_waveform_picker_regs( void )
General Comments 0
You need to be logged in to leave comments. Login now