@@ -1,329 +1,329 | |||||
1 | #ifndef FSW_PROCESSING_H_INCLUDED |
|
1 | #ifndef FSW_PROCESSING_H_INCLUDED | |
2 | #define FSW_PROCESSING_H_INCLUDED |
|
2 | #define FSW_PROCESSING_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <grspw.h> |
|
5 | #include <grspw.h> | |
6 | #include <math.h> |
|
6 | #include <math.h> | |
7 | #include <stdlib.h> // abs() is in the stdlib |
|
7 | #include <stdlib.h> // abs() is in the stdlib | |
8 |
#include <stdio.h> |
|
8 | #include <stdio.h> | |
9 | #include <math.h> |
|
9 | #include <math.h> | |
10 | #include <grlib_regs.h> |
|
10 | #include <grlib_regs.h> | |
11 |
|
11 | |||
12 | #include "fsw_params.h" |
|
12 | #include "fsw_params.h" | |
13 |
|
13 | |||
14 | typedef struct ring_node_asm |
|
14 | typedef struct ring_node_asm | |
15 | { |
|
15 | { | |
16 | struct ring_node_asm *next; |
|
16 | struct ring_node_asm *next; | |
17 | float matrix[ TOTAL_SIZE_SM ]; |
|
17 | float matrix[ TOTAL_SIZE_SM ]; | |
18 | unsigned int status; |
|
18 | unsigned int status; | |
19 | } ring_node_asm; |
|
19 | } ring_node_asm; | |
20 |
|
20 | |||
21 | typedef struct |
|
21 | typedef struct | |
22 | { |
|
22 | { | |
23 | unsigned char targetLogicalAddress; |
|
23 | unsigned char targetLogicalAddress; | |
24 | unsigned char protocolIdentifier; |
|
24 | unsigned char protocolIdentifier; | |
25 | unsigned char reserved; |
|
25 | unsigned char reserved; | |
26 | unsigned char userApplication; |
|
26 | unsigned char userApplication; | |
27 | unsigned char packetID[2]; |
|
27 | unsigned char packetID[2]; | |
28 | unsigned char packetSequenceControl[2]; |
|
28 | unsigned char packetSequenceControl[2]; | |
29 | unsigned char packetLength[2]; |
|
29 | unsigned char packetLength[2]; | |
30 | // DATA FIELD HEADER |
|
30 | // DATA FIELD HEADER | |
31 | unsigned char spare1_pusVersion_spare2; |
|
31 | unsigned char spare1_pusVersion_spare2; | |
32 | unsigned char serviceType; |
|
32 | unsigned char serviceType; | |
33 | unsigned char serviceSubType; |
|
33 | unsigned char serviceSubType; | |
34 | unsigned char destinationID; |
|
34 | unsigned char destinationID; | |
35 | unsigned char time[6]; |
|
35 | unsigned char time[6]; | |
36 | // AUXILIARY HEADER |
|
36 | // AUXILIARY HEADER | |
37 | unsigned char sid; |
|
37 | unsigned char sid; | |
38 | unsigned char biaStatusInfo; |
|
38 | unsigned char biaStatusInfo; | |
39 | unsigned char sy_lfr_common_parameters_spare; |
|
39 | unsigned char sy_lfr_common_parameters_spare; | |
40 | unsigned char sy_lfr_common_parameters; |
|
40 | unsigned char sy_lfr_common_parameters; | |
41 | unsigned char acquisitionTime[6]; |
|
41 | unsigned char acquisitionTime[6]; | |
42 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
42 | unsigned char pa_lfr_bp_blk_nr[2]; | |
43 | // SOURCE DATA |
|
43 | // SOURCE DATA | |
44 | unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
44 | unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] | |
45 | } bp_packet; |
|
45 | } bp_packet; | |
46 |
|
46 | |||
47 | typedef struct |
|
47 | typedef struct | |
48 | { |
|
48 | { | |
49 | unsigned char targetLogicalAddress; |
|
49 | unsigned char targetLogicalAddress; | |
50 | unsigned char protocolIdentifier; |
|
50 | unsigned char protocolIdentifier; | |
51 | unsigned char reserved; |
|
51 | unsigned char reserved; | |
52 | unsigned char userApplication; |
|
52 | unsigned char userApplication; | |
53 | unsigned char packetID[2]; |
|
53 | unsigned char packetID[2]; | |
54 | unsigned char packetSequenceControl[2]; |
|
54 | unsigned char packetSequenceControl[2]; | |
55 | unsigned char packetLength[2]; |
|
55 | unsigned char packetLength[2]; | |
56 | // DATA FIELD HEADER |
|
56 | // DATA FIELD HEADER | |
57 | unsigned char spare1_pusVersion_spare2; |
|
57 | unsigned char spare1_pusVersion_spare2; | |
58 | unsigned char serviceType; |
|
58 | unsigned char serviceType; | |
59 | unsigned char serviceSubType; |
|
59 | unsigned char serviceSubType; | |
60 | unsigned char destinationID; |
|
60 | unsigned char destinationID; | |
61 | unsigned char time[6]; |
|
61 | unsigned char time[6]; | |
62 | // AUXILIARY HEADER |
|
62 | // AUXILIARY HEADER | |
63 | unsigned char sid; |
|
63 | unsigned char sid; | |
64 | unsigned char biaStatusInfo; |
|
64 | unsigned char biaStatusInfo; | |
65 | unsigned char sy_lfr_common_parameters_spare; |
|
65 | unsigned char sy_lfr_common_parameters_spare; | |
66 | unsigned char sy_lfr_common_parameters; |
|
66 | unsigned char sy_lfr_common_parameters; | |
67 | unsigned char acquisitionTime[6]; |
|
67 | unsigned char acquisitionTime[6]; | |
68 | unsigned char source_data_spare; |
|
68 | unsigned char source_data_spare; | |
69 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
69 | unsigned char pa_lfr_bp_blk_nr[2]; | |
70 | // SOURCE DATA |
|
70 | // SOURCE DATA | |
71 | unsigned char data[ 143 ]; // 13 bins * 11 Bytes |
|
71 | unsigned char data[ 143 ]; // 13 bins * 11 Bytes | |
72 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
72 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 | |
73 |
|
73 | |||
74 | typedef struct asm_msg |
|
74 | typedef struct asm_msg | |
75 | { |
|
75 | { | |
76 | ring_node_asm *norm; |
|
76 | ring_node_asm *norm; | |
77 | ring_node_asm *burst_sbm; |
|
77 | ring_node_asm *burst_sbm; | |
78 | rtems_event_set event; |
|
78 | rtems_event_set event; | |
79 | unsigned int coarseTimeNORM; |
|
79 | unsigned int coarseTimeNORM; | |
80 | unsigned int fineTimeNORM; |
|
80 | unsigned int fineTimeNORM; | |
81 | unsigned int coarseTimeSBM; |
|
81 | unsigned int coarseTimeSBM; | |
82 | unsigned int fineTimeSBM; |
|
82 | unsigned int fineTimeSBM; | |
83 | } asm_msg; |
|
83 | } asm_msg; | |
84 |
|
84 | |||
85 | extern volatile int sm_f0[ ]; |
|
85 | extern volatile int sm_f0[ ]; | |
86 | extern volatile int sm_f1[ ]; |
|
86 | extern volatile int sm_f1[ ]; | |
87 | extern volatile int sm_f2[ ]; |
|
87 | extern volatile int sm_f2[ ]; | |
88 |
|
88 | |||
89 | // parameters |
|
89 | // parameters | |
90 | extern struct param_local_str param_local; |
|
90 | extern struct param_local_str param_local; | |
91 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
91 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
92 |
|
92 | |||
93 | // registers |
|
93 | // registers | |
94 | extern time_management_regs_t *time_management_regs; |
|
94 | extern time_management_regs_t *time_management_regs; | |
95 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; |
|
95 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; | |
96 |
|
96 | |||
97 | extern rtems_name misc_name[5]; |
|
97 | extern rtems_name misc_name[5]; | |
98 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
98 | extern rtems_id Task_id[20]; /* array of task ids */ | |
99 |
|
99 | |||
100 | // |
|
100 | // | |
101 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); |
|
101 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); | |
102 | // ISR |
|
102 | // ISR | |
103 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
103 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); | |
104 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); |
|
104 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); | |
105 |
|
105 | |||
106 | //****************** |
|
106 | //****************** | |
107 | // Spectral Matrices |
|
107 | // Spectral Matrices | |
108 | void reset_nb_sm( void ); |
|
108 | void reset_nb_sm( void ); | |
109 | // SM |
|
109 | // SM | |
110 | void SM_init_rings( void ); |
|
110 | void SM_init_rings( void ); | |
111 | void SM_reset_current_ring_nodes( void ); |
|
111 | void SM_reset_current_ring_nodes( void ); | |
112 | // ASM |
|
112 | // ASM | |
113 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); |
|
113 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); | |
114 |
|
114 | |||
115 | //***************** |
|
115 | //***************** | |
116 | // Basic Parameters |
|
116 | // Basic Parameters | |
117 |
|
117 | |||
118 | void BP_reset_current_ring_nodes( void ); |
|
118 | void BP_reset_current_ring_nodes( void ); | |
119 | void BP_init_header(bp_packet *packet, |
|
119 | void BP_init_header(bp_packet *packet, | |
120 | unsigned int apid, unsigned char sid, |
|
120 | unsigned int apid, unsigned char sid, | |
121 | unsigned int packetLength , unsigned char blkNr); |
|
121 | unsigned int packetLength , unsigned char blkNr); | |
122 | void BP_init_header_with_spare(bp_packet_with_spare *packet, |
|
122 | void BP_init_header_with_spare(bp_packet_with_spare *packet, | |
123 | unsigned int apid, unsigned char sid, |
|
123 | unsigned int apid, unsigned char sid, | |
124 | unsigned int packetLength, unsigned char blkNr ); |
|
124 | unsigned int packetLength, unsigned char blkNr ); | |
125 | void BP_send( char *data, |
|
125 | void BP_send( char *data, | |
126 | rtems_id queue_id , |
|
126 | rtems_id queue_id , | |
127 | unsigned int nbBytesToSend , unsigned int sid ); |
|
127 | unsigned int nbBytesToSend , unsigned int sid ); | |
128 |
|
128 | |||
129 | //****************** |
|
129 | //****************** | |
130 | // general functions |
|
130 | // general functions | |
131 | void reset_sm_status( void ); |
|
131 | void reset_sm_status( void ); | |
132 | void reset_spectral_matrix_regs( void ); |
|
132 | void reset_spectral_matrix_regs( void ); | |
133 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
133 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); | |
134 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); |
|
134 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); | |
135 | unsigned char getSID( rtems_event_set event ); |
|
135 | unsigned char getSID( rtems_event_set event ); | |
136 |
|
136 | |||
137 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
137 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); | |
138 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
138 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); | |
139 |
|
139 | |||
140 | //*************************************** |
|
140 | //*************************************** | |
141 | // DEFINITIONS OF STATIC INLINE FUNCTIONS |
|
141 | // DEFINITIONS OF STATIC INLINE FUNCTIONS | |
142 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
142 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
143 | ring_node *ring_node_tab[], |
|
143 | ring_node *ring_node_tab[], | |
144 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
144 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
145 | asm_msg *msgForMATR ); |
|
145 | asm_msg *msgForMATR ); | |
146 |
|
146 | |||
147 | static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
147 | static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
148 | ring_node *ring_node_tab[], |
|
148 | ring_node *ring_node_tab[], | |
149 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
149 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
150 | asm_msg *msgForMATR ); |
|
150 | asm_msg *msgForMATR ); | |
151 |
|
151 | |||
152 | void ASM_patch( float *inputASM, float *outputASM ); |
|
152 | void ASM_patch( float *inputASM, float *outputASM ); | |
153 |
|
153 | |||
154 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); |
|
154 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); | |
155 |
|
155 | |||
156 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
156 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, | |
157 | float divider ); |
|
157 | float divider ); | |
158 |
|
158 | |||
159 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
159 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, | |
160 | float divider, |
|
160 | float divider, | |
161 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
161 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); | |
162 |
|
162 | |||
163 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
163 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); | |
164 |
|
164 | |||
165 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
165 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
166 | ring_node *ring_node_tab[], |
|
166 | ring_node *ring_node_tab[], | |
167 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
167 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
168 | asm_msg *msgForMATR ) |
|
168 | asm_msg *msgForMATR ) | |
169 | { |
|
169 | { | |
170 | float sum; |
|
170 | float sum; | |
171 | unsigned int i; |
|
171 | unsigned int i; | |
172 |
|
172 | |||
173 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
173 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
174 | { |
|
174 | { | |
175 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] |
|
175 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] | |
176 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] |
|
176 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] | |
177 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] |
|
177 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] | |
178 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] |
|
178 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] | |
179 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] |
|
179 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] | |
180 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] |
|
180 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] | |
181 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] |
|
181 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] | |
182 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; |
|
182 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; | |
183 |
|
183 | |||
184 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
184 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) | |
185 | { |
|
185 | { | |
186 | averaged_spec_mat_NORM[ i ] = sum; |
|
186 | averaged_spec_mat_NORM[ i ] = sum; | |
187 | averaged_spec_mat_SBM[ i ] = sum; |
|
187 | averaged_spec_mat_SBM[ i ] = sum; | |
188 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
188 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
189 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
189 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
190 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
190 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
191 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
191 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
192 | } |
|
192 | } | |
193 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
193 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) | |
194 | { |
|
194 | { | |
195 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
195 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); | |
196 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
196 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); | |
197 | } |
|
197 | } | |
198 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
198 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) | |
199 | { |
|
199 | { | |
200 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
200 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); | |
201 | averaged_spec_mat_SBM[ i ] = sum; |
|
201 | averaged_spec_mat_SBM[ i ] = sum; | |
202 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
202 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
203 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
203 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
204 | } |
|
204 | } | |
205 | else |
|
205 | else | |
206 | { |
|
206 | { | |
207 | averaged_spec_mat_NORM[ i ] = sum; |
|
207 | averaged_spec_mat_NORM[ i ] = sum; | |
208 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
208 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); | |
209 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
209 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
210 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
210 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
211 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) |
|
211 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) | |
212 | } |
|
212 | } | |
213 | } |
|
213 | } | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
216 | void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
217 | ring_node *ring_node_tab[], |
|
217 | ring_node *ring_node_tab[], | |
218 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
218 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
219 | asm_msg *msgForMATR ) |
|
219 | asm_msg *msgForMATR ) | |
220 | { |
|
220 | { | |
221 | float sum; |
|
221 | float sum; | |
222 | unsigned int i; |
|
222 | unsigned int i; | |
223 |
|
223 | |||
224 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
224 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
225 | { |
|
225 | { | |
226 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]; |
|
226 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]; | |
227 | averaged_spec_mat_NORM[ i ] = sum; |
|
227 | averaged_spec_mat_NORM[ i ] = sum; | |
228 | averaged_spec_mat_SBM[ i ] = sum; |
|
228 | averaged_spec_mat_SBM[ i ] = sum; | |
229 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
229 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
230 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
230 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
231 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
231 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
232 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
232 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
236 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) | |
237 | { |
|
237 | { | |
238 | int frequencyBin; |
|
238 | int frequencyBin; | |
239 | int asmComponent; |
|
239 | int asmComponent; | |
240 | unsigned int offsetASM; |
|
240 | unsigned int offsetASM; | |
241 | unsigned int offsetASMReorganized; |
|
241 | unsigned int offsetASMReorganized; | |
242 |
|
242 | |||
243 | // BUILD DATA |
|
243 | // BUILD DATA | |
244 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
244 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
245 | { |
|
245 | { | |
246 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
246 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) | |
247 | { |
|
247 | { | |
248 | offsetASMReorganized = |
|
248 | offsetASMReorganized = | |
249 | frequencyBin * NB_VALUES_PER_SM |
|
249 | frequencyBin * NB_VALUES_PER_SM | |
250 | + asmComponent; |
|
250 | + asmComponent; | |
251 | offsetASM = |
|
251 | offsetASM = | |
252 | asmComponent * NB_BINS_PER_SM |
|
252 | asmComponent * NB_BINS_PER_SM | |
253 | + frequencyBin; |
|
253 | + frequencyBin; | |
254 | averaged_spec_mat_reorganized[offsetASMReorganized ] = |
|
254 | averaged_spec_mat_reorganized[offsetASMReorganized ] = | |
255 | averaged_spec_mat[ offsetASM ] / divider; |
|
255 | averaged_spec_mat[ offsetASM ] / divider; | |
256 | } |
|
256 | } | |
257 | } |
|
257 | } | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
260 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
261 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
261 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) | |
262 | { |
|
262 | { | |
263 | int frequencyBin; |
|
263 | int frequencyBin; | |
264 | int asmComponent; |
|
264 | int asmComponent; | |
265 | int offsetASM; |
|
265 | int offsetASM; | |
266 | int offsetCompressed; |
|
266 | int offsetCompressed; | |
267 | int k; |
|
267 | int k; | |
268 |
|
268 | |||
269 | // BUILD DATA |
|
269 | // BUILD DATA | |
270 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
270 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
271 | { |
|
271 | { | |
272 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
272 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
273 | { |
|
273 | { | |
274 | offsetCompressed = // NO TIME OFFSET |
|
274 | offsetCompressed = // NO TIME OFFSET | |
275 | frequencyBin * NB_VALUES_PER_SM |
|
275 | frequencyBin * NB_VALUES_PER_SM | |
276 | + asmComponent; |
|
276 | + asmComponent; | |
277 | offsetASM = // NO TIME OFFSET |
|
277 | offsetASM = // NO TIME OFFSET | |
278 | asmComponent * NB_BINS_PER_SM |
|
278 | asmComponent * NB_BINS_PER_SM | |
279 | + ASMIndexStart |
|
279 | + ASMIndexStart | |
280 | + frequencyBin * nbBinsToAverage; |
|
280 | + frequencyBin * nbBinsToAverage; | |
281 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
281 | compressed_spec_mat[ offsetCompressed ] = 0; | |
282 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
282 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
283 | { |
|
283 | { | |
284 | compressed_spec_mat[offsetCompressed ] = |
|
284 | compressed_spec_mat[offsetCompressed ] = | |
285 | ( compressed_spec_mat[ offsetCompressed ] |
|
285 | ( compressed_spec_mat[ offsetCompressed ] | |
286 | + averaged_spec_mat[ offsetASM + k ] ); |
|
286 | + averaged_spec_mat[ offsetASM + k ] ); | |
287 | } |
|
287 | } | |
288 | compressed_spec_mat[ offsetCompressed ] = |
|
288 | compressed_spec_mat[ offsetCompressed ] = | |
289 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
289 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 | } |
|
292 | } | |
293 |
|
293 | |||
294 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
294 | void ASM_convert( volatile float *input_matrix, char *output_matrix) | |
295 | { |
|
295 | { | |
296 | unsigned int frequencyBin; |
|
296 | unsigned int frequencyBin; | |
297 | unsigned int asmComponent; |
|
297 | unsigned int asmComponent; | |
298 | char * pt_char_input; |
|
298 | char * pt_char_input; | |
299 | char * pt_char_output; |
|
299 | char * pt_char_output; | |
300 | unsigned int offsetInput; |
|
300 | unsigned int offsetInput; | |
301 | unsigned int offsetOutput; |
|
301 | unsigned int offsetOutput; | |
302 |
|
302 | |||
303 | pt_char_input = (char*) &input_matrix; |
|
303 | pt_char_input = (char*) &input_matrix; | |
304 | pt_char_output = (char*) &output_matrix; |
|
304 | pt_char_output = (char*) &output_matrix; | |
305 |
|
305 | |||
306 | // convert all other data |
|
306 | // convert all other data | |
307 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
307 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) | |
308 | { |
|
308 | { | |
309 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
309 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) | |
310 | { |
|
310 | { | |
311 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; |
|
311 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; | |
312 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; |
|
312 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; | |
313 | pt_char_input = (char*) &input_matrix [ offsetInput ]; |
|
313 | pt_char_input = (char*) &input_matrix [ offsetInput ]; | |
314 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; |
|
314 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; | |
315 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
315 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float | |
316 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
316 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float | |
317 | } |
|
317 | } | |
318 | } |
|
318 | } | |
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, |
|
321 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, | |
322 | float divider, |
|
322 | float divider, | |
323 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
323 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); | |
324 |
|
324 | |||
325 | int getFBinMask(int k); |
|
325 | int getFBinMask(int k); | |
326 |
|
326 | |||
327 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); |
|
327 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); | |
328 |
|
328 | |||
329 | #endif // FSW_PROCESSING_H_INCLUDED |
|
329 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -1,71 +1,72 | |||||
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "wf_handler.h" |
|
8 | #include "wf_handler.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "fsw_misc.h" |
|
10 | #include "fsw_misc.h" | |
11 | #include "basic_parameters_params.h" |
|
11 | #include "basic_parameters_params.h" | |
12 | #include "avf0_prc0.h" |
|
12 | #include "avf0_prc0.h" | |
13 |
|
13 | |||
14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
14 | #define FLOAT_EQUAL_ZERO 0.001 | |
15 |
|
15 | |||
16 | extern unsigned short sequenceCounterParameterDump; |
|
16 | extern unsigned short sequenceCounterParameterDump; | |
|
17 | extern unsigned short sequenceCounters_TM_DUMP[]; | |||
17 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
18 | extern float k_coeff_intercalib_f0_norm[ ]; | |
18 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
19 | extern float k_coeff_intercalib_f0_sbm[ ]; | |
19 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
20 | extern float k_coeff_intercalib_f1_norm[ ]; | |
20 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
21 | extern float k_coeff_intercalib_f1_sbm[ ]; | |
21 | extern float k_coeff_intercalib_f2[ ]; |
|
22 | extern float k_coeff_intercalib_f2[ ]; | |
22 |
|
23 | |||
23 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
24 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
24 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
25 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
25 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
26 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
26 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
27 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
27 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
28 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
28 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
29 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
29 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
30 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
31 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
31 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
32 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
32 |
|
33 | |||
33 | // NORMAL |
|
34 | // NORMAL | |
34 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
35 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
35 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
36 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); | |
36 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
37 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); | |
37 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
38 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); | |
38 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
39 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
39 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
40 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
40 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
41 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); | |
41 |
|
42 | |||
42 | // BURST |
|
43 | // BURST | |
43 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
44 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
44 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
45 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
45 |
|
46 | |||
46 | // SBM1 |
|
47 | // SBM1 | |
47 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
48 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
48 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
49 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
49 |
|
50 | |||
50 | // SBM2 |
|
51 | // SBM2 | |
51 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
52 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
52 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
53 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
53 |
|
54 | |||
54 | // TC_LFR_UPDATE_INFO |
|
55 | // TC_LFR_UPDATE_INFO | |
55 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
56 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); | |
56 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
57 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); | |
57 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
58 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); | |
58 |
|
59 | |||
59 | // FBINS_MASK |
|
60 | // FBINS_MASK | |
60 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
61 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); | |
61 |
|
62 | |||
62 | // KCOEFFICIENTS |
|
63 | // KCOEFFICIENTS | |
63 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
64 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
64 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
65 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); | |
65 |
|
66 | |||
66 | void init_parameter_dump( void ); |
|
67 | void init_parameter_dump( void ); | |
67 | void init_kcoefficients_dump( void ); |
|
68 | void init_kcoefficients_dump( void ); | |
68 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
69 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); | |
69 | void print_k_coeff(); |
|
70 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); | |
70 |
|
71 | |||
71 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
|
72 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,79 +1,79 | |||||
1 | /** Global variables of the LFR flight software. |
|
1 | /** Global variables of the LFR flight software. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * Among global variables, there are: |
|
6 | * Among global variables, there are: | |
7 | * - RTEMS names and id. |
|
7 | * - RTEMS names and id. | |
8 | * - APB configuration registers. |
|
8 | * - APB configuration registers. | |
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. |
|
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. | |
10 | * - spectral matrices buffesr, used by the hardware module to store data. |
|
10 | * - spectral matrices buffesr, used by the hardware module to store data. | |
11 | * - variable related to LFR modes parameters. |
|
11 | * - variable related to LFR modes parameters. | |
12 | * - the global HK packet buffer. |
|
12 | * - the global HK packet buffer. | |
13 | * - the global dump parameter buffer. |
|
13 | * - the global dump parameter buffer. | |
14 | * |
|
14 | * | |
15 | */ |
|
15 | */ | |
16 |
|
16 | |||
17 | #include <rtems.h> |
|
17 | #include <rtems.h> | |
18 | #include <grspw.h> |
|
18 | #include <grspw.h> | |
19 |
|
19 | |||
20 | #include "ccsds_types.h" |
|
20 | #include "ccsds_types.h" | |
21 | #include "grlib_regs.h" |
|
21 | #include "grlib_regs.h" | |
22 | #include "fsw_params.h" |
|
22 | #include "fsw_params.h" | |
23 | #include "fsw_params_wf_handler.h" |
|
23 | #include "fsw_params_wf_handler.h" | |
24 |
|
24 | |||
25 | // RTEMS GLOBAL VARIABLES |
|
25 | // RTEMS GLOBAL VARIABLES | |
26 | rtems_name misc_name[5]; |
|
26 | rtems_name misc_name[5]; | |
27 | rtems_name Task_name[20]; /* array of task names */ |
|
27 | rtems_name Task_name[20]; /* array of task names */ | |
28 | rtems_id Task_id[20]; /* array of task ids */ |
|
28 | rtems_id Task_id[20]; /* array of task ids */ | |
29 | int fdSPW = 0; |
|
29 | int fdSPW = 0; | |
30 | int fdUART = 0; |
|
30 | int fdUART = 0; | |
31 | unsigned char lfrCurrentMode; |
|
31 | unsigned char lfrCurrentMode; | |
32 | unsigned char pa_bia_status_info; |
|
32 | unsigned char pa_bia_status_info; | |
33 |
|
33 | |||
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 |
|
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 | |
35 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words |
|
35 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words | |
36 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 |
|
36 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 | |
37 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words |
|
37 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words | |
38 | // F0 F1 F2 F3 |
|
38 | // F0 F1 F2 F3 | |
39 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
39 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
40 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
40 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
41 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
41 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
42 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
42 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
43 |
|
43 | |||
44 | //*********************************** |
|
44 | //*********************************** | |
45 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
45 | // SPECTRAL MATRICES GLOBAL VARIABLES | |
46 |
|
46 | |||
47 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 |
|
47 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 | |
48 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
48 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
49 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
49 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
50 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
50 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
51 |
|
51 | |||
52 | // APB CONFIGURATION REGISTERS |
|
52 | // APB CONFIGURATION REGISTERS | |
53 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
53 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; | |
54 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
54 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |
55 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
55 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; | |
56 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
56 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; | |
57 |
|
57 | |||
58 | // MODE PARAMETERS |
|
58 | // MODE PARAMETERS | |
59 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
59 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
60 | struct param_local_str param_local; |
|
60 | struct param_local_str param_local; | |
61 |
|
61 | |||
62 | // HK PACKETS |
|
62 | // HK PACKETS | |
63 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
63 | Packet_TM_LFR_HK_t housekeeping_packet; | |
64 | // message queues occupancy |
|
64 | // message queues occupancy | |
65 | unsigned char hk_lfr_q_sd_fifo_size_max; |
|
65 | unsigned char hk_lfr_q_sd_fifo_size_max; | |
66 | unsigned char hk_lfr_q_rv_fifo_size_max; |
|
66 | unsigned char hk_lfr_q_rv_fifo_size_max; | |
67 | unsigned char hk_lfr_q_p0_fifo_size_max; |
|
67 | unsigned char hk_lfr_q_p0_fifo_size_max; | |
68 | unsigned char hk_lfr_q_p1_fifo_size_max; |
|
68 | unsigned char hk_lfr_q_p1_fifo_size_max; | |
69 | unsigned char hk_lfr_q_p2_fifo_size_max; |
|
69 | unsigned char hk_lfr_q_p2_fifo_size_max; | |
70 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
70 | // sequence counters are incremented by APID (PID + CAT) and destination ID | |
71 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
71 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | |
72 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
72 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
73 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; |
|
73 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; | |
|
74 | unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID]; | |||
74 | unsigned short sequenceCounterHK; |
|
75 | unsigned short sequenceCounterHK; | |
75 | unsigned short sequenceCounterParameterDump; |
|
|||
76 | spw_stats spacewire_stats; |
|
76 | spw_stats spacewire_stats; | |
77 | spw_stats spacewire_stats_backup; |
|
77 | spw_stats spacewire_stats_backup; | |
78 |
|
78 | |||
79 |
|
79 |
@@ -1,872 +1,872 | |||||
1 | /** This is the RTEMS initialization module. |
|
1 | /** This is the RTEMS initialization module. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * This module contains two very different information: |
|
6 | * This module contains two very different information: | |
7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
7 | * - specific instructions to configure the compilation of the RTEMS executive | |
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task | |
9 | * |
|
9 | * | |
10 | */ |
|
10 | */ | |
11 |
|
11 | |||
12 | //************************* |
|
12 | //************************* | |
13 | // GPL reminder to be added |
|
13 | // GPL reminder to be added | |
14 | //************************* |
|
14 | //************************* | |
15 |
|
15 | |||
16 | #include <rtems.h> |
|
16 | #include <rtems.h> | |
17 |
|
17 | |||
18 | /* configuration information */ |
|
18 | /* configuration information */ | |
19 |
|
19 | |||
20 | #define CONFIGURE_INIT |
|
20 | #define CONFIGURE_INIT | |
21 |
|
21 | |||
22 | #include <bsp.h> /* for device driver prototypes */ |
|
22 | #include <bsp.h> /* for device driver prototypes */ | |
23 |
|
23 | |||
24 | /* configuration information */ |
|
24 | /* configuration information */ | |
25 |
|
25 | |||
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
28 |
|
28 | |||
29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
29 | #define CONFIGURE_MAXIMUM_TASKS 20 | |
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) | |
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) | |
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 | |
40 | #ifdef PRINT_STACK_REPORT |
|
40 | #ifdef PRINT_STACK_REPORT | |
41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
41 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
42 | #endif |
|
42 | #endif | |
43 |
|
43 | |||
44 | #include <rtems/confdefs.h> |
|
44 | #include <rtems/confdefs.h> | |
45 |
|
45 | |||
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
47 | #ifdef RTEMS_DRVMGR_STARTUP |
|
47 | #ifdef RTEMS_DRVMGR_STARTUP | |
48 | #ifdef LEON3 |
|
48 | #ifdef LEON3 | |
49 | /* Add Timer and UART Driver */ |
|
49 | /* Add Timer and UART Driver */ | |
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
52 | #endif |
|
52 | #endif | |
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
55 | #endif |
|
55 | #endif | |
56 | #endif |
|
56 | #endif | |
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
58 | #include <drvmgr/drvmgr_confdefs.h> |
|
58 | #include <drvmgr/drvmgr_confdefs.h> | |
59 | #endif |
|
59 | #endif | |
60 |
|
60 | |||
61 | #include "fsw_init.h" |
|
61 | #include "fsw_init.h" | |
62 | #include "fsw_config.c" |
|
62 | #include "fsw_config.c" | |
63 | #include "GscMemoryLPP.hpp" |
|
63 | #include "GscMemoryLPP.hpp" | |
64 |
|
64 | |||
65 | void initCache() |
|
65 | void initCache() | |
66 | { |
|
66 | { | |
67 | unsigned int cacheControlRegister; |
|
67 | unsigned int cacheControlRegister; | |
68 |
|
68 | |||
69 | cacheControlRegister = getCacheControlRegister(); |
|
69 | cacheControlRegister = getCacheControlRegister(); | |
70 |
|
|
70 | PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister) | |
71 |
|
71 | |||
72 | resetCacheControlRegister(); |
|
72 | resetCacheControlRegister(); | |
73 |
|
73 | |||
74 | enableInstructionCache(); |
|
74 | enableInstructionCache(); | |
75 | enableDataCache(); |
|
75 | enableDataCache(); | |
76 | enableInstructionBurstFetch(); |
|
76 | enableInstructionBurstFetch(); | |
77 |
|
77 | |||
78 | cacheControlRegister = getCacheControlRegister(); |
|
78 | cacheControlRegister = getCacheControlRegister(); | |
79 |
|
|
79 | PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister) | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | rtems_task Init( rtems_task_argument ignored ) |
|
82 | rtems_task Init( rtems_task_argument ignored ) | |
83 | { |
|
83 | { | |
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. | |
85 | * |
|
85 | * | |
86 | * @param unused is the starting argument of the RTEMS task |
|
86 | * @param unused is the starting argument of the RTEMS task | |
87 | * |
|
87 | * | |
88 | * The INIT task create and run all other RTEMS tasks. |
|
88 | * The INIT task create and run all other RTEMS tasks. | |
89 | * |
|
89 | * | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | //*********** |
|
92 | //*********** | |
93 | // INIT CACHE |
|
93 | // INIT CACHE | |
94 |
|
94 | |||
95 | unsigned char *vhdlVersion; |
|
95 | unsigned char *vhdlVersion; | |
96 |
|
96 | |||
97 | reset_lfr(); |
|
97 | reset_lfr(); | |
98 |
|
98 | |||
99 | reset_local_time(); |
|
99 | reset_local_time(); | |
100 |
|
100 | |||
101 | rtems_cpu_usage_reset(); |
|
101 | rtems_cpu_usage_reset(); | |
102 |
|
102 | |||
103 | rtems_status_code status; |
|
103 | rtems_status_code status; | |
104 | rtems_status_code status_spw; |
|
104 | rtems_status_code status_spw; | |
105 | rtems_isr_entry old_isr_handler; |
|
105 | rtems_isr_entry old_isr_handler; | |
106 |
|
106 | |||
107 | // UART settings |
|
107 | // UART settings | |
108 | send_console_outputs_on_apbuart_port(); |
|
108 | send_console_outputs_on_apbuart_port(); | |
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
110 | enable_apbuart_transmitter(); |
|
110 | enable_apbuart_transmitter(); | |
111 |
|
111 | |||
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | PRINTF("\n\n\n\n\n") |
|
115 | PRINTF("\n\n\n\n\n") | |
116 |
|
116 | |||
117 | initCache(); |
|
117 | initCache(); | |
118 |
|
118 | |||
119 | PRINTF("*************************\n") |
|
119 | PRINTF("*************************\n") | |
120 | PRINTF("** LFR Flight Software **\n") |
|
120 | PRINTF("** LFR Flight Software **\n") | |
121 | PRINTF1("** %d.", SW_VERSION_N1) |
|
121 | PRINTF1("** %d.", SW_VERSION_N1) | |
122 | PRINTF1("%d." , SW_VERSION_N2) |
|
122 | PRINTF1("%d." , SW_VERSION_N2) | |
123 | PRINTF1("%d." , SW_VERSION_N3) |
|
123 | PRINTF1("%d." , SW_VERSION_N3) | |
124 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
124 | PRINTF1("%d **\n", SW_VERSION_N4) | |
125 |
|
125 | |||
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
127 | PRINTF("** VHDL **\n") |
|
127 | PRINTF("** VHDL **\n") | |
128 | PRINTF1("** %d.", vhdlVersion[1]) |
|
128 | PRINTF1("** %d.", vhdlVersion[1]) | |
129 | PRINTF1("%d." , vhdlVersion[2]) |
|
129 | PRINTF1("%d." , vhdlVersion[2]) | |
130 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
130 | PRINTF1("%d **\n", vhdlVersion[3]) | |
131 | PRINTF("*************************\n") |
|
131 | PRINTF("*************************\n") | |
132 | PRINTF("\n\n") |
|
132 | PRINTF("\n\n") | |
133 |
|
133 | |||
134 | init_parameter_dump(); |
|
134 | init_parameter_dump(); | |
135 | init_kcoefficients_dump(); |
|
135 | init_kcoefficients_dump(); | |
136 | init_local_mode_parameters(); |
|
136 | init_local_mode_parameters(); | |
137 | init_housekeeping_parameters(); |
|
137 | init_housekeeping_parameters(); | |
138 | init_k_coefficients_prc0(); |
|
138 | init_k_coefficients_prc0(); | |
139 | init_k_coefficients_prc1(); |
|
139 | init_k_coefficients_prc1(); | |
140 | init_k_coefficients_prc2(); |
|
140 | init_k_coefficients_prc2(); | |
141 | pa_bia_status_info = 0x00; |
|
141 | pa_bia_status_info = 0x00; | |
142 |
|
142 | |||
143 | // waveform picker initialization |
|
143 | // waveform picker initialization | |
144 | WFP_init_rings(); // initialize the waveform rings |
|
144 | WFP_init_rings(); // initialize the waveform rings | |
145 | WFP_reset_current_ring_nodes(); |
|
145 | WFP_reset_current_ring_nodes(); | |
146 | reset_waveform_picker_regs(); |
|
146 | reset_waveform_picker_regs(); | |
147 |
|
147 | |||
148 | // spectral matrices initialization |
|
148 | // spectral matrices initialization | |
149 | SM_init_rings(); // initialize spectral matrices rings |
|
149 | SM_init_rings(); // initialize spectral matrices rings | |
150 | SM_reset_current_ring_nodes(); |
|
150 | SM_reset_current_ring_nodes(); | |
151 | reset_spectral_matrix_regs(); |
|
151 | reset_spectral_matrix_regs(); | |
152 |
|
152 | |||
153 | // configure calibration |
|
153 | // configure calibration | |
154 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
154 | configureCalibration( false ); // true means interleaved mode, false is for normal mode | |
155 |
|
155 | |||
156 | updateLFRCurrentMode(); |
|
156 | updateLFRCurrentMode(); | |
157 |
|
157 | |||
158 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
158 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
159 |
|
159 | |||
160 | create_names(); // create all names |
|
160 | create_names(); // create all names | |
161 |
|
161 | |||
162 | status = create_message_queues(); // create message queues |
|
162 | status = create_message_queues(); // create message queues | |
163 | if (status != RTEMS_SUCCESSFUL) |
|
163 | if (status != RTEMS_SUCCESSFUL) | |
164 | { |
|
164 | { | |
165 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
165 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | status = create_all_tasks(); // create all tasks |
|
168 | status = create_all_tasks(); // create all tasks | |
169 | if (status != RTEMS_SUCCESSFUL) |
|
169 | if (status != RTEMS_SUCCESSFUL) | |
170 | { |
|
170 | { | |
171 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
171 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | // ************************** |
|
174 | // ************************** | |
175 | // <SPACEWIRE INITIALIZATION> |
|
175 | // <SPACEWIRE INITIALIZATION> | |
176 | grspw_timecode_callback = &timecode_irq_handler; |
|
176 | grspw_timecode_callback = &timecode_irq_handler; | |
177 |
|
177 | |||
178 | status_spw = spacewire_open_link(); // (1) open the link |
|
178 | status_spw = spacewire_open_link(); // (1) open the link | |
179 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
179 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
180 | { |
|
180 | { | |
181 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
181 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
184 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
185 | { |
|
185 | { | |
186 | status_spw = spacewire_configure_link( fdSPW ); |
|
186 | status_spw = spacewire_configure_link( fdSPW ); | |
187 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
187 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
188 | { |
|
188 | { | |
189 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
189 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
193 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
194 | { |
|
194 | { | |
195 | status_spw = spacewire_start_link( fdSPW ); |
|
195 | status_spw = spacewire_start_link( fdSPW ); | |
196 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
196 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
197 | { |
|
197 | { | |
198 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
198 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) | |
199 | } |
|
199 | } | |
200 | } |
|
200 | } | |
201 | // </SPACEWIRE INITIALIZATION> |
|
201 | // </SPACEWIRE INITIALIZATION> | |
202 | // *************************** |
|
202 | // *************************** | |
203 |
|
203 | |||
204 | status = start_all_tasks(); // start all tasks |
|
204 | status = start_all_tasks(); // start all tasks | |
205 | if (status != RTEMS_SUCCESSFUL) |
|
205 | if (status != RTEMS_SUCCESSFUL) | |
206 | { |
|
206 | { | |
207 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
207 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
210 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization | |
211 | status = start_recv_send_tasks(); |
|
211 | status = start_recv_send_tasks(); | |
212 | if ( status != RTEMS_SUCCESSFUL ) |
|
212 | if ( status != RTEMS_SUCCESSFUL ) | |
213 | { |
|
213 | { | |
214 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
214 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | // suspend science tasks, they will be restarted later depending on the mode |
|
217 | // suspend science tasks, they will be restarted later depending on the mode | |
218 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
218 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
219 | if (status != RTEMS_SUCCESSFUL) |
|
219 | if (status != RTEMS_SUCCESSFUL) | |
220 | { |
|
220 | { | |
221 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
221 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | //****************************** |
|
224 | //****************************** | |
225 | // <SPECTRAL MATRICES SIMULATOR> |
|
225 | // <SPECTRAL MATRICES SIMULATOR> | |
226 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
226 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); | |
227 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
227 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |
228 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
228 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); | |
229 | // </SPECTRAL MATRICES SIMULATOR> |
|
229 | // </SPECTRAL MATRICES SIMULATOR> | |
230 | //******************************* |
|
230 | //******************************* | |
231 |
|
231 | |||
232 | // configure IRQ handling for the waveform picker unit |
|
232 | // configure IRQ handling for the waveform picker unit | |
233 | status = rtems_interrupt_catch( waveforms_isr, |
|
233 | status = rtems_interrupt_catch( waveforms_isr, | |
234 | IRQ_SPARC_WAVEFORM_PICKER, |
|
234 | IRQ_SPARC_WAVEFORM_PICKER, | |
235 | &old_isr_handler) ; |
|
235 | &old_isr_handler) ; | |
236 | // configure IRQ handling for the spectral matrices unit |
|
236 | // configure IRQ handling for the spectral matrices unit | |
237 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
237 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
238 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
238 | IRQ_SPARC_SPECTRAL_MATRIX, | |
239 | &old_isr_handler) ; |
|
239 | &old_isr_handler) ; | |
240 |
|
240 | |||
241 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
241 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery | |
242 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
242 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
243 | { |
|
243 | { | |
244 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
244 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
245 | if ( status != RTEMS_SUCCESSFUL ) { |
|
245 | if ( status != RTEMS_SUCCESSFUL ) { | |
246 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
246 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | BOOT_PRINTF("delete INIT\n") |
|
250 | BOOT_PRINTF("delete INIT\n") | |
251 |
|
251 | |||
252 | set_hk_lfr_sc_potential_flag( true ); |
|
252 | set_hk_lfr_sc_potential_flag( true ); | |
253 |
|
253 | |||
254 | status = rtems_task_delete(RTEMS_SELF); |
|
254 | status = rtems_task_delete(RTEMS_SELF); | |
255 |
|
255 | |||
256 | } |
|
256 | } | |
257 |
|
257 | |||
258 | void init_local_mode_parameters( void ) |
|
258 | void init_local_mode_parameters( void ) | |
259 | { |
|
259 | { | |
260 | /** This function initialize the param_local global variable with default values. |
|
260 | /** This function initialize the param_local global variable with default values. | |
261 | * |
|
261 | * | |
262 | */ |
|
262 | */ | |
263 |
|
263 | |||
264 | unsigned int i; |
|
264 | unsigned int i; | |
265 |
|
265 | |||
266 | // LOCAL PARAMETERS |
|
266 | // LOCAL PARAMETERS | |
267 |
|
267 | |||
268 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
268 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
269 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
269 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
270 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
270 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
271 |
|
271 | |||
272 | // init sequence counters |
|
272 | // init sequence counters | |
273 |
|
273 | |||
274 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
274 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
275 | { |
|
275 | { | |
276 | sequenceCounters_TC_EXE[i] = 0x00; |
|
276 | sequenceCounters_TC_EXE[i] = 0x00; | |
|
277 | sequenceCounters_TM_DUMP[i] = 0x00; | |||
277 | } |
|
278 | } | |
278 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
279 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
279 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
280 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
280 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
281 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
281 | sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
|||
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | void reset_local_time( void ) |
|
284 | void reset_local_time( void ) | |
285 | { |
|
285 | { | |
286 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 |
|
286 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 | |
287 | } |
|
287 | } | |
288 |
|
288 | |||
289 | void create_names( void ) // create all names for tasks and queues |
|
289 | void create_names( void ) // create all names for tasks and queues | |
290 | { |
|
290 | { | |
291 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
291 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
292 | * |
|
292 | * | |
293 | * @return RTEMS directive status codes: |
|
293 | * @return RTEMS directive status codes: | |
294 | * - RTEMS_SUCCESSFUL - successful completion |
|
294 | * - RTEMS_SUCCESSFUL - successful completion | |
295 | * |
|
295 | * | |
296 | */ |
|
296 | */ | |
297 |
|
297 | |||
298 | // task names |
|
298 | // task names | |
299 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
299 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
300 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
300 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
301 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
301 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
302 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
302 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
303 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
303 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
304 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
304 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
305 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
305 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
306 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
306 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
307 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
307 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
308 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
308 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); | |
309 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
309 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
310 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
310 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
311 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
311 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
312 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
312 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
313 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
313 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
314 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
314 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); | |
315 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
315 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); | |
316 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
316 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); | |
317 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
317 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); | |
318 |
|
318 | |||
319 | // rate monotonic period names |
|
319 | // rate monotonic period names | |
320 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
320 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
321 |
|
321 | |||
322 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
322 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
323 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
323 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
324 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
324 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); | |
325 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
325 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); | |
326 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
326 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | int create_all_tasks( void ) // create all tasks which run in the software |
|
329 | int create_all_tasks( void ) // create all tasks which run in the software | |
330 | { |
|
330 | { | |
331 | /** This function creates all RTEMS tasks used in the software. |
|
331 | /** This function creates all RTEMS tasks used in the software. | |
332 | * |
|
332 | * | |
333 | * @return RTEMS directive status codes: |
|
333 | * @return RTEMS directive status codes: | |
334 | * - RTEMS_SUCCESSFUL - task created successfully |
|
334 | * - RTEMS_SUCCESSFUL - task created successfully | |
335 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
335 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
336 | * - RTEMS_INVALID_NAME - invalid task name |
|
336 | * - RTEMS_INVALID_NAME - invalid task name | |
337 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
337 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
338 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
338 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
339 | * - RTEMS_TOO_MANY - too many tasks created |
|
339 | * - RTEMS_TOO_MANY - too many tasks created | |
340 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
340 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
341 | * - RTEMS_TOO_MANY - too many global objects |
|
341 | * - RTEMS_TOO_MANY - too many global objects | |
342 | * |
|
342 | * | |
343 | */ |
|
343 | */ | |
344 |
|
344 | |||
345 | rtems_status_code status; |
|
345 | rtems_status_code status; | |
346 |
|
346 | |||
347 | //********** |
|
347 | //********** | |
348 | // SPACEWIRE |
|
348 | // SPACEWIRE | |
349 | // RECV |
|
349 | // RECV | |
350 | status = rtems_task_create( |
|
350 | status = rtems_task_create( | |
351 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
351 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
352 | RTEMS_DEFAULT_MODES, |
|
352 | RTEMS_DEFAULT_MODES, | |
353 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
353 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
354 | ); |
|
354 | ); | |
355 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
355 | if (status == RTEMS_SUCCESSFUL) // SEND | |
356 | { |
|
356 | { | |
357 | status = rtems_task_create( |
|
357 | status = rtems_task_create( | |
358 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
358 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, | |
359 | RTEMS_DEFAULT_MODES, |
|
359 | RTEMS_DEFAULT_MODES, | |
360 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
360 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] | |
361 | ); |
|
361 | ); | |
362 | } |
|
362 | } | |
363 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
363 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
364 | { |
|
364 | { | |
365 | status = rtems_task_create( |
|
365 | status = rtems_task_create( | |
366 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
366 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
367 | RTEMS_DEFAULT_MODES, |
|
367 | RTEMS_DEFAULT_MODES, | |
368 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
368 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
369 | ); |
|
369 | ); | |
370 | } |
|
370 | } | |
371 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
371 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
372 | { |
|
372 | { | |
373 | status = rtems_task_create( |
|
373 | status = rtems_task_create( | |
374 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
374 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
375 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
375 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
376 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
376 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
377 | ); |
|
377 | ); | |
378 | } |
|
378 | } | |
379 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
379 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
380 | { |
|
380 | { | |
381 | status = rtems_task_create( |
|
381 | status = rtems_task_create( | |
382 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
382 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
383 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
383 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
384 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
384 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
385 | ); |
|
385 | ); | |
386 | } |
|
386 | } | |
387 |
|
387 | |||
388 | //****************** |
|
388 | //****************** | |
389 | // SPECTRAL MATRICES |
|
389 | // SPECTRAL MATRICES | |
390 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
390 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
391 | { |
|
391 | { | |
392 | status = rtems_task_create( |
|
392 | status = rtems_task_create( | |
393 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
393 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
394 | RTEMS_DEFAULT_MODES, |
|
394 | RTEMS_DEFAULT_MODES, | |
395 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
395 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
396 | ); |
|
396 | ); | |
397 | } |
|
397 | } | |
398 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
398 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
399 | { |
|
399 | { | |
400 | status = rtems_task_create( |
|
400 | status = rtems_task_create( | |
401 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
401 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, | |
402 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
402 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
403 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
403 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] | |
404 | ); |
|
404 | ); | |
405 | } |
|
405 | } | |
406 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
406 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
407 | { |
|
407 | { | |
408 | status = rtems_task_create( |
|
408 | status = rtems_task_create( | |
409 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
409 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, | |
410 | RTEMS_DEFAULT_MODES, |
|
410 | RTEMS_DEFAULT_MODES, | |
411 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
411 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] | |
412 | ); |
|
412 | ); | |
413 | } |
|
413 | } | |
414 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
414 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
415 | { |
|
415 | { | |
416 | status = rtems_task_create( |
|
416 | status = rtems_task_create( | |
417 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
417 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, | |
418 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
418 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
419 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
419 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] | |
420 | ); |
|
420 | ); | |
421 | } |
|
421 | } | |
422 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
422 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
423 | { |
|
423 | { | |
424 | status = rtems_task_create( |
|
424 | status = rtems_task_create( | |
425 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
425 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, | |
426 | RTEMS_DEFAULT_MODES, |
|
426 | RTEMS_DEFAULT_MODES, | |
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] | |
428 | ); |
|
428 | ); | |
429 | } |
|
429 | } | |
430 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
430 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
431 | { |
|
431 | { | |
432 | status = rtems_task_create( |
|
432 | status = rtems_task_create( | |
433 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
433 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, | |
434 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
434 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
435 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
435 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] | |
436 | ); |
|
436 | ); | |
437 | } |
|
437 | } | |
438 |
|
438 | |||
439 | //**************** |
|
439 | //**************** | |
440 | // WAVEFORM PICKER |
|
440 | // WAVEFORM PICKER | |
441 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
441 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
442 | { |
|
442 | { | |
443 | status = rtems_task_create( |
|
443 | status = rtems_task_create( | |
444 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
444 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
445 | RTEMS_DEFAULT_MODES, |
|
445 | RTEMS_DEFAULT_MODES, | |
446 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
446 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
447 | ); |
|
447 | ); | |
448 | } |
|
448 | } | |
449 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
449 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
450 | { |
|
450 | { | |
451 | status = rtems_task_create( |
|
451 | status = rtems_task_create( | |
452 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
452 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
453 | RTEMS_DEFAULT_MODES, |
|
453 | RTEMS_DEFAULT_MODES, | |
454 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
454 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
455 | ); |
|
455 | ); | |
456 | } |
|
456 | } | |
457 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
457 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
458 | { |
|
458 | { | |
459 | status = rtems_task_create( |
|
459 | status = rtems_task_create( | |
460 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
460 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
461 | RTEMS_DEFAULT_MODES, |
|
461 | RTEMS_DEFAULT_MODES, | |
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
463 | ); |
|
463 | ); | |
464 | } |
|
464 | } | |
465 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
465 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
466 | { |
|
466 | { | |
467 | status = rtems_task_create( |
|
467 | status = rtems_task_create( | |
468 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
468 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
469 | RTEMS_DEFAULT_MODES, |
|
469 | RTEMS_DEFAULT_MODES, | |
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
471 | ); |
|
471 | ); | |
472 | } |
|
472 | } | |
473 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
473 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
474 | { |
|
474 | { | |
475 | status = rtems_task_create( |
|
475 | status = rtems_task_create( | |
476 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
476 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, | |
477 | RTEMS_DEFAULT_MODES, |
|
477 | RTEMS_DEFAULT_MODES, | |
478 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
478 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] | |
479 | ); |
|
479 | ); | |
480 | } |
|
480 | } | |
481 |
|
481 | |||
482 | //***** |
|
482 | //***** | |
483 | // MISC |
|
483 | // MISC | |
484 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
484 | if (status == RTEMS_SUCCESSFUL) // STAT | |
485 | { |
|
485 | { | |
486 | status = rtems_task_create( |
|
486 | status = rtems_task_create( | |
487 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
487 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
488 | RTEMS_DEFAULT_MODES, |
|
488 | RTEMS_DEFAULT_MODES, | |
489 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
489 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
490 | ); |
|
490 | ); | |
491 | } |
|
491 | } | |
492 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
492 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
493 | { |
|
493 | { | |
494 | status = rtems_task_create( |
|
494 | status = rtems_task_create( | |
495 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
495 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
496 | RTEMS_DEFAULT_MODES, |
|
496 | RTEMS_DEFAULT_MODES, | |
497 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
497 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
498 | ); |
|
498 | ); | |
499 | } |
|
499 | } | |
500 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
500 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
501 | { |
|
501 | { | |
502 | status = rtems_task_create( |
|
502 | status = rtems_task_create( | |
503 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
503 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
504 | RTEMS_DEFAULT_MODES, |
|
504 | RTEMS_DEFAULT_MODES, | |
505 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
505 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] | |
506 | ); |
|
506 | ); | |
507 | } |
|
507 | } | |
508 |
|
508 | |||
509 | return status; |
|
509 | return status; | |
510 | } |
|
510 | } | |
511 |
|
511 | |||
512 | int start_recv_send_tasks( void ) |
|
512 | int start_recv_send_tasks( void ) | |
513 | { |
|
513 | { | |
514 | rtems_status_code status; |
|
514 | rtems_status_code status; | |
515 |
|
515 | |||
516 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
516 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
517 | if (status!=RTEMS_SUCCESSFUL) { |
|
517 | if (status!=RTEMS_SUCCESSFUL) { | |
518 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
518 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
519 | } |
|
519 | } | |
520 |
|
520 | |||
521 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
521 | if (status == RTEMS_SUCCESSFUL) // SEND | |
522 | { |
|
522 | { | |
523 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
523 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
524 | if (status!=RTEMS_SUCCESSFUL) { |
|
524 | if (status!=RTEMS_SUCCESSFUL) { | |
525 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
525 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
526 | } |
|
526 | } | |
527 | } |
|
527 | } | |
528 |
|
528 | |||
529 | return status; |
|
529 | return status; | |
530 | } |
|
530 | } | |
531 |
|
531 | |||
532 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
532 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
533 | { |
|
533 | { | |
534 | /** This function starts all RTEMS tasks used in the software. |
|
534 | /** This function starts all RTEMS tasks used in the software. | |
535 | * |
|
535 | * | |
536 | * @return RTEMS directive status codes: |
|
536 | * @return RTEMS directive status codes: | |
537 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
537 | * - RTEMS_SUCCESSFUL - ask started successfully | |
538 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
538 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
539 | * - RTEMS_INVALID_ID - invalid task id |
|
539 | * - RTEMS_INVALID_ID - invalid task id | |
540 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
540 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
541 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
541 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
542 | * |
|
542 | * | |
543 | */ |
|
543 | */ | |
544 | // starts all the tasks fot eh flight software |
|
544 | // starts all the tasks fot eh flight software | |
545 |
|
545 | |||
546 | rtems_status_code status; |
|
546 | rtems_status_code status; | |
547 |
|
547 | |||
548 | //********** |
|
548 | //********** | |
549 | // SPACEWIRE |
|
549 | // SPACEWIRE | |
550 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
550 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
551 | if (status!=RTEMS_SUCCESSFUL) { |
|
551 | if (status!=RTEMS_SUCCESSFUL) { | |
552 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
552 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
553 | } |
|
553 | } | |
554 |
|
554 | |||
555 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
555 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
556 | { |
|
556 | { | |
557 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
557 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
558 | if (status!=RTEMS_SUCCESSFUL) { |
|
558 | if (status!=RTEMS_SUCCESSFUL) { | |
559 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
559 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
560 | } |
|
560 | } | |
561 | } |
|
561 | } | |
562 |
|
562 | |||
563 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
563 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
564 | { |
|
564 | { | |
565 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
565 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
566 | if (status!=RTEMS_SUCCESSFUL) { |
|
566 | if (status!=RTEMS_SUCCESSFUL) { | |
567 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
567 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
568 | } |
|
568 | } | |
569 | } |
|
569 | } | |
570 |
|
570 | |||
571 | //****************** |
|
571 | //****************** | |
572 | // SPECTRAL MATRICES |
|
572 | // SPECTRAL MATRICES | |
573 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
573 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
574 | { |
|
574 | { | |
575 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
575 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); | |
576 | if (status!=RTEMS_SUCCESSFUL) { |
|
576 | if (status!=RTEMS_SUCCESSFUL) { | |
577 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
577 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
578 | } |
|
578 | } | |
579 | } |
|
579 | } | |
580 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
580 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
581 | { |
|
581 | { | |
582 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
582 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); | |
583 | if (status!=RTEMS_SUCCESSFUL) { |
|
583 | if (status!=RTEMS_SUCCESSFUL) { | |
584 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
584 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") | |
585 | } |
|
585 | } | |
586 | } |
|
586 | } | |
587 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
587 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
588 | { |
|
588 | { | |
589 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
589 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); | |
590 | if (status!=RTEMS_SUCCESSFUL) { |
|
590 | if (status!=RTEMS_SUCCESSFUL) { | |
591 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
591 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") | |
592 | } |
|
592 | } | |
593 | } |
|
593 | } | |
594 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
594 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
595 | { |
|
595 | { | |
596 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
596 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); | |
597 | if (status!=RTEMS_SUCCESSFUL) { |
|
597 | if (status!=RTEMS_SUCCESSFUL) { | |
598 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
598 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") | |
599 | } |
|
599 | } | |
600 | } |
|
600 | } | |
601 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
601 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
602 | { |
|
602 | { | |
603 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
603 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); | |
604 | if (status!=RTEMS_SUCCESSFUL) { |
|
604 | if (status!=RTEMS_SUCCESSFUL) { | |
605 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
605 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") | |
606 | } |
|
606 | } | |
607 | } |
|
607 | } | |
608 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
608 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
609 | { |
|
609 | { | |
610 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
610 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); | |
611 | if (status!=RTEMS_SUCCESSFUL) { |
|
611 | if (status!=RTEMS_SUCCESSFUL) { | |
612 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
612 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") | |
613 | } |
|
613 | } | |
614 | } |
|
614 | } | |
615 |
|
615 | |||
616 | //**************** |
|
616 | //**************** | |
617 | // WAVEFORM PICKER |
|
617 | // WAVEFORM PICKER | |
618 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
618 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
619 | { |
|
619 | { | |
620 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
620 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
621 | if (status!=RTEMS_SUCCESSFUL) { |
|
621 | if (status!=RTEMS_SUCCESSFUL) { | |
622 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
622 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
623 | } |
|
623 | } | |
624 | } |
|
624 | } | |
625 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
625 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
626 | { |
|
626 | { | |
627 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
627 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
628 | if (status!=RTEMS_SUCCESSFUL) { |
|
628 | if (status!=RTEMS_SUCCESSFUL) { | |
629 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
629 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
630 | } |
|
630 | } | |
631 | } |
|
631 | } | |
632 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
632 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
633 | { |
|
633 | { | |
634 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
634 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
635 | if (status!=RTEMS_SUCCESSFUL) { |
|
635 | if (status!=RTEMS_SUCCESSFUL) { | |
636 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
636 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
637 | } |
|
637 | } | |
638 | } |
|
638 | } | |
639 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
639 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
640 | { |
|
640 | { | |
641 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
641 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
642 | if (status!=RTEMS_SUCCESSFUL) { |
|
642 | if (status!=RTEMS_SUCCESSFUL) { | |
643 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
643 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
644 | } |
|
644 | } | |
645 | } |
|
645 | } | |
646 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
646 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
647 | { |
|
647 | { | |
648 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
648 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); | |
649 | if (status!=RTEMS_SUCCESSFUL) { |
|
649 | if (status!=RTEMS_SUCCESSFUL) { | |
650 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
650 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") | |
651 | } |
|
651 | } | |
652 | } |
|
652 | } | |
653 |
|
653 | |||
654 | //***** |
|
654 | //***** | |
655 | // MISC |
|
655 | // MISC | |
656 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
656 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
657 | { |
|
657 | { | |
658 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
658 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
659 | if (status!=RTEMS_SUCCESSFUL) { |
|
659 | if (status!=RTEMS_SUCCESSFUL) { | |
660 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
660 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
661 | } |
|
661 | } | |
662 | } |
|
662 | } | |
663 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
663 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
664 | { |
|
664 | { | |
665 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
665 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
666 | if (status!=RTEMS_SUCCESSFUL) { |
|
666 | if (status!=RTEMS_SUCCESSFUL) { | |
667 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
667 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
668 | } |
|
668 | } | |
669 | } |
|
669 | } | |
670 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
670 | if (status == RTEMS_SUCCESSFUL) // STAT | |
671 | { |
|
671 | { | |
672 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
672 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
673 | if (status!=RTEMS_SUCCESSFUL) { |
|
673 | if (status!=RTEMS_SUCCESSFUL) { | |
674 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
674 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
675 | } |
|
675 | } | |
676 | } |
|
676 | } | |
677 |
|
677 | |||
678 | return status; |
|
678 | return status; | |
679 | } |
|
679 | } | |
680 |
|
680 | |||
681 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
681 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
682 | { |
|
682 | { | |
683 | rtems_status_code status_recv; |
|
683 | rtems_status_code status_recv; | |
684 | rtems_status_code status_send; |
|
684 | rtems_status_code status_send; | |
685 | rtems_status_code status_q_p0; |
|
685 | rtems_status_code status_q_p0; | |
686 | rtems_status_code status_q_p1; |
|
686 | rtems_status_code status_q_p1; | |
687 | rtems_status_code status_q_p2; |
|
687 | rtems_status_code status_q_p2; | |
688 | rtems_status_code ret; |
|
688 | rtems_status_code ret; | |
689 | rtems_id queue_id; |
|
689 | rtems_id queue_id; | |
690 |
|
690 | |||
691 | //**************************************** |
|
691 | //**************************************** | |
692 | // create the queue for handling valid TCs |
|
692 | // create the queue for handling valid TCs | |
693 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
693 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
694 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
694 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
695 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
695 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
696 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
696 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
697 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
697 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
698 | } |
|
698 | } | |
699 |
|
699 | |||
700 | //************************************************ |
|
700 | //************************************************ | |
701 | // create the queue for handling TM packet sending |
|
701 | // create the queue for handling TM packet sending | |
702 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
702 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
703 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
703 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
704 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
704 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
705 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
705 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
706 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
706 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
707 | } |
|
707 | } | |
708 |
|
708 | |||
709 | //***************************************************************************** |
|
709 | //***************************************************************************** | |
710 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
710 | // create the queue for handling averaged spectral matrices for processing @ f0 | |
711 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
711 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], | |
712 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
712 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, | |
713 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
713 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
714 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
714 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { | |
715 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
715 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) | |
716 | } |
|
716 | } | |
717 |
|
717 | |||
718 | //***************************************************************************** |
|
718 | //***************************************************************************** | |
719 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
719 | // create the queue for handling averaged spectral matrices for processing @ f1 | |
720 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
720 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], | |
721 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
721 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, | |
722 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
722 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
723 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
723 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { | |
724 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
724 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) | |
725 | } |
|
725 | } | |
726 |
|
726 | |||
727 | //***************************************************************************** |
|
727 | //***************************************************************************** | |
728 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
728 | // create the queue for handling averaged spectral matrices for processing @ f2 | |
729 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
729 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], | |
730 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
730 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, | |
731 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
731 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
732 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
732 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { | |
733 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
733 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) | |
734 | } |
|
734 | } | |
735 |
|
735 | |||
736 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
736 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
737 | { |
|
737 | { | |
738 | ret = status_recv; |
|
738 | ret = status_recv; | |
739 | } |
|
739 | } | |
740 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
740 | else if( status_send != RTEMS_SUCCESSFUL ) | |
741 | { |
|
741 | { | |
742 | ret = status_send; |
|
742 | ret = status_send; | |
743 | } |
|
743 | } | |
744 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
744 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) | |
745 | { |
|
745 | { | |
746 | ret = status_q_p0; |
|
746 | ret = status_q_p0; | |
747 | } |
|
747 | } | |
748 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
748 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) | |
749 | { |
|
749 | { | |
750 | ret = status_q_p1; |
|
750 | ret = status_q_p1; | |
751 | } |
|
751 | } | |
752 | else |
|
752 | else | |
753 | { |
|
753 | { | |
754 | ret = status_q_p2; |
|
754 | ret = status_q_p2; | |
755 | } |
|
755 | } | |
756 |
|
756 | |||
757 | return ret; |
|
757 | return ret; | |
758 | } |
|
758 | } | |
759 |
|
759 | |||
760 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
760 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) | |
761 | { |
|
761 | { | |
762 | rtems_status_code status; |
|
762 | rtems_status_code status; | |
763 | rtems_name queue_name; |
|
763 | rtems_name queue_name; | |
764 |
|
764 | |||
765 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
765 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
766 |
|
766 | |||
767 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
767 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
768 |
|
768 | |||
769 | return status; |
|
769 | return status; | |
770 | } |
|
770 | } | |
771 |
|
771 | |||
772 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
772 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) | |
773 | { |
|
773 | { | |
774 | rtems_status_code status; |
|
774 | rtems_status_code status; | |
775 | rtems_name queue_name; |
|
775 | rtems_name queue_name; | |
776 |
|
776 | |||
777 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
777 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
778 |
|
778 | |||
779 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
779 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
780 |
|
780 | |||
781 | return status; |
|
781 | return status; | |
782 | } |
|
782 | } | |
783 |
|
783 | |||
784 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
784 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) | |
785 | { |
|
785 | { | |
786 | rtems_status_code status; |
|
786 | rtems_status_code status; | |
787 | rtems_name queue_name; |
|
787 | rtems_name queue_name; | |
788 |
|
788 | |||
789 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
789 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); | |
790 |
|
790 | |||
791 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
791 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
792 |
|
792 | |||
793 | return status; |
|
793 | return status; | |
794 | } |
|
794 | } | |
795 |
|
795 | |||
796 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
796 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) | |
797 | { |
|
797 | { | |
798 | rtems_status_code status; |
|
798 | rtems_status_code status; | |
799 | rtems_name queue_name; |
|
799 | rtems_name queue_name; | |
800 |
|
800 | |||
801 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
801 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); | |
802 |
|
802 | |||
803 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
803 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
804 |
|
804 | |||
805 | return status; |
|
805 | return status; | |
806 | } |
|
806 | } | |
807 |
|
807 | |||
808 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
808 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) | |
809 | { |
|
809 | { | |
810 | rtems_status_code status; |
|
810 | rtems_status_code status; | |
811 | rtems_name queue_name; |
|
811 | rtems_name queue_name; | |
812 |
|
812 | |||
813 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
813 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); | |
814 |
|
814 | |||
815 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
815 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
816 |
|
816 | |||
817 | return status; |
|
817 | return status; | |
818 | } |
|
818 | } | |
819 |
|
819 | |||
820 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) |
|
820 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) | |
821 | { |
|
821 | { | |
822 | u_int32_t count; |
|
822 | u_int32_t count; | |
823 | rtems_status_code status; |
|
823 | rtems_status_code status; | |
824 |
|
824 | |||
825 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
825 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
826 |
|
826 | |||
827 | count = count + 1; |
|
827 | count = count + 1; | |
828 |
|
828 | |||
829 | if (status != RTEMS_SUCCESSFUL) |
|
829 | if (status != RTEMS_SUCCESSFUL) | |
830 | { |
|
830 | { | |
831 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
831 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) | |
832 | } |
|
832 | } | |
833 | else |
|
833 | else | |
834 | { |
|
834 | { | |
835 | if (count > *fifo_size_max) |
|
835 | if (count > *fifo_size_max) | |
836 | { |
|
836 | { | |
837 | *fifo_size_max = count; |
|
837 | *fifo_size_max = count; | |
838 | } |
|
838 | } | |
839 | } |
|
839 | } | |
840 | } |
|
840 | } | |
841 |
|
841 | |||
842 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) |
|
842 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) | |
843 | { |
|
843 | { | |
844 | unsigned char i; |
|
844 | unsigned char i; | |
845 |
|
845 | |||
846 | //*************** |
|
846 | //*************** | |
847 | // BUFFER ADDRESS |
|
847 | // BUFFER ADDRESS | |
848 | for(i=0; i<nbNodes; i++) |
|
848 | for(i=0; i<nbNodes; i++) | |
849 | { |
|
849 | { | |
850 | ring[i].coarseTime = 0xffffffff; |
|
850 | ring[i].coarseTime = 0xffffffff; | |
851 | ring[i].fineTime = 0xffffffff; |
|
851 | ring[i].fineTime = 0xffffffff; | |
852 | ring[i].sid = 0x00; |
|
852 | ring[i].sid = 0x00; | |
853 | ring[i].status = 0x00; |
|
853 | ring[i].status = 0x00; | |
854 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
854 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; | |
855 | } |
|
855 | } | |
856 |
|
856 | |||
857 | //***** |
|
857 | //***** | |
858 | // NEXT |
|
858 | // NEXT | |
859 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
859 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; | |
860 | for(i=0; i<nbNodes-1; i++) |
|
860 | for(i=0; i<nbNodes-1; i++) | |
861 | { |
|
861 | { | |
862 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
862 | ring[i].next = (ring_node*) &ring[ i + 1 ]; | |
863 | } |
|
863 | } | |
864 |
|
864 | |||
865 | //********* |
|
865 | //********* | |
866 | // PREVIOUS |
|
866 | // PREVIOUS | |
867 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
867 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; | |
868 | for(i=1; i<nbNodes; i++) |
|
868 | for(i=1; i<nbNodes; i++) | |
869 | { |
|
869 | { | |
870 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
870 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; | |
871 | } |
|
871 | } | |
872 | } |
|
872 | } |
@@ -1,571 +1,570 | |||||
1 | /** General usage functions and RTEMS tasks. |
|
1 | /** General usage functions and RTEMS tasks. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 |
|
9 | |||
10 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
10 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, | |
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
12 | { |
|
12 | { | |
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
14 | * |
|
14 | * | |
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
18 | * @param interrupt_level is the interrupt level that the timer drives. |
|
18 | * @param interrupt_level is the interrupt level that the timer drives. | |
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
20 | * |
|
20 | * | |
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
22 | * |
|
22 | * | |
23 | */ |
|
23 | */ | |
24 |
|
24 | |||
25 | rtems_status_code status; |
|
25 | rtems_status_code status; | |
26 | rtems_isr_entry old_isr_handler; |
|
26 | rtems_isr_entry old_isr_handler; | |
27 |
|
27 | |||
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register |
|
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register | |
29 |
|
29 | |||
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
31 | if (status!=RTEMS_SUCCESSFUL) |
|
31 | if (status!=RTEMS_SUCCESSFUL) | |
32 | { |
|
32 | { | |
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); |
|
36 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
39 | void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) | |
40 | { |
|
40 | { | |
41 | /** This function starts a GPTIMER timer. |
|
41 | /** This function starts a GPTIMER timer. | |
42 | * |
|
42 | * | |
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
45 | * |
|
45 | * | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register | |
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer | |
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart | |
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
55 | void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) | |
56 | { |
|
56 | { | |
57 | /** This function stops a GPTIMER timer. |
|
57 | /** This function stops a GPTIMER timer. | |
58 | * |
|
58 | * | |
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
61 | * |
|
61 | * | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer | |
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable | |
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) |
|
69 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) | |
70 | { |
|
70 | { | |
71 | /** This function sets the clock divider of a GPTIMER timer. |
|
71 | /** This function sets the clock divider of a GPTIMER timer. | |
72 | * |
|
72 | * | |
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
76 | * |
|
76 | * | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port | |
83 | { |
|
83 | { | |
84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
85 |
|
85 | |||
86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
87 |
|
87 | |||
88 | return 0; |
|
88 | return 0; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
92 | { |
|
92 | { | |
93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
94 |
|
94 | |||
95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; |
|
95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; | |
96 |
|
96 | |||
97 | return 0; |
|
97 | return 0; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
101 | { |
|
101 | { | |
102 | /** This function sets the scaler reload register of the apbuart module |
|
102 | /** This function sets the scaler reload register of the apbuart module | |
103 | * |
|
103 | * | |
104 | * @param regs is the address of the apbuart registers in memory |
|
104 | * @param regs is the address of the apbuart registers in memory | |
105 | * @param value is the value that will be stored in the scaler register |
|
105 | * @param value is the value that will be stored in the scaler register | |
106 | * |
|
106 | * | |
107 | * The value shall be set by the software to get data on the serial interface. |
|
107 | * The value shall be set by the software to get data on the serial interface. | |
108 | * |
|
108 | * | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
112 |
|
112 | |||
113 | apbuart_regs->scaler = value; |
|
113 | apbuart_regs->scaler = value; | |
114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | //************ |
|
117 | //************ | |
118 | // RTEMS TASKS |
|
118 | // RTEMS TASKS | |
119 |
|
119 | |||
120 | rtems_task stat_task(rtems_task_argument argument) |
|
120 | rtems_task stat_task(rtems_task_argument argument) | |
121 | { |
|
121 | { | |
122 | int i; |
|
122 | int i; | |
123 | int j; |
|
123 | int j; | |
124 | i = 0; |
|
124 | i = 0; | |
125 | j = 0; |
|
125 | j = 0; | |
126 | BOOT_PRINTF("in STAT *** \n") |
|
126 | BOOT_PRINTF("in STAT *** \n") | |
127 | while(1){ |
|
127 | while(1){ | |
128 | rtems_task_wake_after(1000); |
|
128 | rtems_task_wake_after(1000); | |
129 | PRINTF1("%d\n", j) |
|
129 | PRINTF1("%d\n", j) | |
130 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
130 | if (i == CPU_USAGE_REPORT_PERIOD) { | |
131 | // #ifdef PRINT_TASK_STATISTICS |
|
131 | // #ifdef PRINT_TASK_STATISTICS | |
132 | // rtems_cpu_usage_report(); |
|
132 | // rtems_cpu_usage_report(); | |
133 | // rtems_cpu_usage_reset(); |
|
133 | // rtems_cpu_usage_reset(); | |
134 | // #endif |
|
134 | // #endif | |
135 | i = 0; |
|
135 | i = 0; | |
136 | } |
|
136 | } | |
137 | else i++; |
|
137 | else i++; | |
138 | j++; |
|
138 | j++; | |
139 | } |
|
139 | } | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | rtems_task hous_task(rtems_task_argument argument) |
|
142 | rtems_task hous_task(rtems_task_argument argument) | |
143 | { |
|
143 | { | |
144 | rtems_status_code status; |
|
144 | rtems_status_code status; | |
145 | rtems_status_code spare_status; |
|
145 | rtems_status_code spare_status; | |
146 | rtems_id queue_id; |
|
146 | rtems_id queue_id; | |
147 | rtems_rate_monotonic_period_status period_status; |
|
147 | rtems_rate_monotonic_period_status period_status; | |
148 |
|
148 | |||
149 | status = get_message_queue_id_send( &queue_id ); |
|
149 | status = get_message_queue_id_send( &queue_id ); | |
150 | if (status != RTEMS_SUCCESSFUL) |
|
150 | if (status != RTEMS_SUCCESSFUL) | |
151 | { |
|
151 | { | |
152 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
152 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | BOOT_PRINTF("in HOUS ***\n") |
|
155 | BOOT_PRINTF("in HOUS ***\n") | |
156 |
|
156 | |||
157 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
157 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
158 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
158 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
159 | if( status != RTEMS_SUCCESSFUL ) { |
|
159 | if( status != RTEMS_SUCCESSFUL ) { | |
160 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
160 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) | |
161 | } |
|
161 | } | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | status = rtems_rate_monotonic_cancel(HK_id); |
|
164 | status = rtems_rate_monotonic_cancel(HK_id); | |
165 | if( status != RTEMS_SUCCESSFUL ) { |
|
165 | if( status != RTEMS_SUCCESSFUL ) { | |
166 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
166 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) | |
167 | } |
|
167 | } | |
168 | else { |
|
168 | else { | |
169 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
169 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | // startup phase |
|
172 | // startup phase | |
173 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
173 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
174 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
174 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
175 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
175 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
176 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
176 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
177 | { |
|
177 | { | |
178 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization |
|
178 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization | |
179 | { |
|
179 | { | |
180 | break; // break if LFR is synchronized |
|
180 | break; // break if LFR is synchronized | |
181 | } |
|
181 | } | |
182 | else |
|
182 | else | |
183 | { |
|
183 | { | |
184 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
184 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
185 | // sched_yield(); |
|
185 | // sched_yield(); | |
186 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms |
|
186 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | status = rtems_rate_monotonic_cancel(HK_id); |
|
189 | status = rtems_rate_monotonic_cancel(HK_id); | |
190 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
190 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
191 |
|
191 | |||
192 | set_hk_lfr_reset_cause( POWER_ON ); |
|
192 | set_hk_lfr_reset_cause( POWER_ON ); | |
193 |
|
193 | |||
194 | while(1){ // launch the rate monotonic task |
|
194 | while(1){ // launch the rate monotonic task | |
195 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
195 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
196 | if ( status != RTEMS_SUCCESSFUL ) { |
|
196 | if ( status != RTEMS_SUCCESSFUL ) { | |
197 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
197 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
198 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
198 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
199 | } |
|
199 | } | |
200 | else { |
|
200 | else { | |
201 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); |
|
201 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); | |
202 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); |
|
202 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); | |
203 | increment_seq_counter( &sequenceCounterHK ); |
|
203 | increment_seq_counter( &sequenceCounterHK ); | |
204 |
|
204 | |||
205 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
205 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
206 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
206 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
207 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
207 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
208 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
208 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
209 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
209 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
210 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
210 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
211 |
|
211 | |||
212 | spacewire_update_statistics(); |
|
212 | spacewire_update_statistics(); | |
213 |
|
213 | |||
214 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
214 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
215 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
215 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
216 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
216 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
217 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
217 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
218 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
218 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
219 |
|
219 | |||
220 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
220 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
221 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
221 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
222 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
222 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
223 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
223 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
224 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
224 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
225 |
|
225 | |||
226 | // SEND PACKET |
|
226 | // SEND PACKET | |
227 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
227 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
228 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
228 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
229 | if (status != RTEMS_SUCCESSFUL) { |
|
229 | if (status != RTEMS_SUCCESSFUL) { | |
230 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
230 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
231 | } |
|
231 | } | |
232 | } |
|
232 | } | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | PRINTF("in HOUS *** deleting task\n") |
|
235 | PRINTF("in HOUS *** deleting task\n") | |
236 |
|
236 | |||
237 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
237 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
238 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
238 | ||
239 | return; |
|
239 | return; | |
240 | } |
|
240 | } | |
241 |
|
241 | |||
242 | rtems_task dumb_task( rtems_task_argument unused ) |
|
242 | rtems_task dumb_task( rtems_task_argument unused ) | |
243 | { |
|
243 | { | |
244 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
244 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
245 | * |
|
245 | * | |
246 | * @param unused is the starting argument of the RTEMS task |
|
246 | * @param unused is the starting argument of the RTEMS task | |
247 | * |
|
247 | * | |
248 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
248 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
249 | * |
|
249 | * | |
250 | */ |
|
250 | */ | |
251 |
|
251 | |||
252 | unsigned int i; |
|
252 | unsigned int i; | |
253 | unsigned int intEventOut; |
|
253 | unsigned int intEventOut; | |
254 | unsigned int coarse_time = 0; |
|
254 | unsigned int coarse_time = 0; | |
255 | unsigned int fine_time = 0; |
|
255 | unsigned int fine_time = 0; | |
256 | rtems_event_set event_out; |
|
256 | rtems_event_set event_out; | |
257 |
|
257 | |||
258 | char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
258 | char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0 | |
259 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
259 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 | |
260 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 |
|
260 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 | |
261 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
261 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 | |
262 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
262 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 | |
263 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 |
|
263 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 | |
264 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 |
|
264 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 | |
265 | "ready for dump", // RTEMS_EVENT_7 |
|
265 | "ready for dump", // RTEMS_EVENT_7 | |
266 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 |
|
266 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 | |
267 | "tick", // RTEMS_EVENT_9 |
|
267 | "tick", // RTEMS_EVENT_9 | |
268 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 |
|
268 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 | |
269 | "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11 |
|
269 | "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11 | |
270 | }; |
|
270 | }; | |
271 |
|
271 | |||
272 | BOOT_PRINTF("in DUMB *** \n") |
|
272 | BOOT_PRINTF("in DUMB *** \n") | |
273 |
|
273 | |||
274 | while(1){ |
|
274 | while(1){ | |
275 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
275 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
276 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
276 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
277 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, |
|
277 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, | |
278 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
278 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
279 | intEventOut = (unsigned int) event_out; |
|
279 | intEventOut = (unsigned int) event_out; | |
280 | for ( i=0; i<32; i++) |
|
280 | for ( i=0; i<32; i++) | |
281 | { |
|
281 | { | |
282 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
282 | if ( ((intEventOut >> i) & 0x0001) != 0) | |
283 | { |
|
283 | { | |
284 | coarse_time = time_management_regs->coarse_time; |
|
284 | coarse_time = time_management_regs->coarse_time; | |
285 | fine_time = time_management_regs->fine_time; |
|
285 | fine_time = time_management_regs->fine_time; | |
286 | printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); |
|
|||
287 | if (i==8) |
|
286 | if (i==8) | |
288 | { |
|
287 | { | |
289 | } |
|
288 | } | |
290 | if (i==10) |
|
289 | if (i==10) | |
291 | { |
|
290 | { | |
292 | } |
|
291 | } | |
293 | } |
|
292 | } | |
294 | } |
|
293 | } | |
295 | } |
|
294 | } | |
296 | } |
|
295 | } | |
297 |
|
296 | |||
298 | //***************************** |
|
297 | //***************************** | |
299 | // init housekeeping parameters |
|
298 | // init housekeeping parameters | |
300 |
|
299 | |||
301 | void init_housekeeping_parameters( void ) |
|
300 | void init_housekeeping_parameters( void ) | |
302 | { |
|
301 | { | |
303 | /** This function initialize the housekeeping_packet global variable with default values. |
|
302 | /** This function initialize the housekeeping_packet global variable with default values. | |
304 | * |
|
303 | * | |
305 | */ |
|
304 | */ | |
306 |
|
305 | |||
307 | unsigned int i = 0; |
|
306 | unsigned int i = 0; | |
308 | unsigned char *parameters; |
|
307 | unsigned char *parameters; | |
309 | unsigned char sizeOfHK; |
|
308 | unsigned char sizeOfHK; | |
310 |
|
309 | |||
311 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
310 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
312 |
|
311 | |||
313 | parameters = (unsigned char*) &housekeeping_packet; |
|
312 | parameters = (unsigned char*) &housekeeping_packet; | |
314 |
|
313 | |||
315 | for(i = 0; i< sizeOfHK; i++) |
|
314 | for(i = 0; i< sizeOfHK; i++) | |
316 | { |
|
315 | { | |
317 | parameters[i] = 0x00; |
|
316 | parameters[i] = 0x00; | |
318 | } |
|
317 | } | |
319 |
|
318 | |||
320 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
319 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
321 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
320 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
322 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
321 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
323 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
322 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
324 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
323 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
325 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
324 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
326 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
325 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
327 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
326 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
328 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
327 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
329 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
328 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
330 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
329 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
331 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
330 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
332 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
331 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
333 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
332 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
334 | housekeeping_packet.sid = SID_HK; |
|
333 | housekeeping_packet.sid = SID_HK; | |
335 |
|
334 | |||
336 | // init status word |
|
335 | // init status word | |
337 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
336 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
338 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
337 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
339 | // init software version |
|
338 | // init software version | |
340 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
339 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
341 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
340 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
342 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
341 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
343 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
342 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
344 | // init fpga version |
|
343 | // init fpga version | |
345 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
344 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
346 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
345 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
347 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
346 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
348 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
347 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
349 |
|
348 | |||
350 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
349 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
351 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
350 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
352 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
351 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
353 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
352 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
354 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
353 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
355 | } |
|
354 | } | |
356 |
|
355 | |||
357 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
356 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
358 | { |
|
357 | { | |
359 | /** This function increment the sequence counter passes in argument. |
|
358 | /** This function increment the sequence counter passes in argument. | |
360 | * |
|
359 | * | |
361 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
360 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
362 | * |
|
361 | * | |
363 | */ |
|
362 | */ | |
364 |
|
363 | |||
365 | unsigned short segmentation_grouping_flag; |
|
364 | unsigned short segmentation_grouping_flag; | |
366 | unsigned short sequence_cnt; |
|
365 | unsigned short sequence_cnt; | |
367 |
|
366 | |||
368 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 |
|
367 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 | |
369 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] |
|
368 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] | |
370 |
|
369 | |||
371 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
370 | if ( sequence_cnt < SEQ_CNT_MAX) | |
372 | { |
|
371 | { | |
373 | sequence_cnt = sequence_cnt + 1; |
|
372 | sequence_cnt = sequence_cnt + 1; | |
374 | } |
|
373 | } | |
375 | else |
|
374 | else | |
376 | { |
|
375 | { | |
377 | sequence_cnt = 0; |
|
376 | sequence_cnt = 0; | |
378 | } |
|
377 | } | |
379 |
|
378 | |||
380 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
379 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
381 | } |
|
380 | } | |
382 |
|
381 | |||
383 | void getTime( unsigned char *time) |
|
382 | void getTime( unsigned char *time) | |
384 | { |
|
383 | { | |
385 | /** This function write the current local time in the time buffer passed in argument. |
|
384 | /** This function write the current local time in the time buffer passed in argument. | |
386 | * |
|
385 | * | |
387 | */ |
|
386 | */ | |
388 |
|
387 | |||
389 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
388 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
390 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
389 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
391 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
390 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
392 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
391 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
393 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
392 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
394 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
393 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
395 | } |
|
394 | } | |
396 |
|
395 | |||
397 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
396 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
398 | { |
|
397 | { | |
399 | /** This function write the current local time in the time buffer passed in argument. |
|
398 | /** This function write the current local time in the time buffer passed in argument. | |
400 | * |
|
399 | * | |
401 | */ |
|
400 | */ | |
402 | unsigned long long int time; |
|
401 | unsigned long long int time; | |
403 |
|
402 | |||
404 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) |
|
403 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) | |
405 | + time_management_regs->fine_time; |
|
404 | + time_management_regs->fine_time; | |
406 |
|
405 | |||
407 | return time; |
|
406 | return time; | |
408 | } |
|
407 | } | |
409 |
|
408 | |||
410 | void send_dumb_hk( void ) |
|
409 | void send_dumb_hk( void ) | |
411 | { |
|
410 | { | |
412 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
411 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
413 | unsigned char *parameters; |
|
412 | unsigned char *parameters; | |
414 | unsigned int i; |
|
413 | unsigned int i; | |
415 | rtems_id queue_id; |
|
414 | rtems_id queue_id; | |
416 |
|
415 | |||
417 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
416 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
418 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
417 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
419 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
418 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
420 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
419 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
421 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
420 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
422 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
421 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
423 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
422 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
424 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
423 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
425 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
424 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
426 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
425 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
427 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
426 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
428 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
427 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
429 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
428 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
430 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
429 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
431 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
430 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
432 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
431 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
433 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
432 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
434 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
433 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
435 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
434 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
436 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
435 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
437 | dummy_hk_packet.sid = SID_HK; |
|
436 | dummy_hk_packet.sid = SID_HK; | |
438 |
|
437 | |||
439 | // init status word |
|
438 | // init status word | |
440 | dummy_hk_packet.lfr_status_word[0] = 0xff; |
|
439 | dummy_hk_packet.lfr_status_word[0] = 0xff; | |
441 | dummy_hk_packet.lfr_status_word[1] = 0xff; |
|
440 | dummy_hk_packet.lfr_status_word[1] = 0xff; | |
442 | // init software version |
|
441 | // init software version | |
443 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
442 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
444 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
443 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
445 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
444 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
446 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
445 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
447 | // init fpga version |
|
446 | // init fpga version | |
448 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); |
|
447 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); | |
449 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
448 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
450 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
449 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
451 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
450 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
452 |
|
451 | |||
453 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
452 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
454 |
|
453 | |||
455 | for (i=0; i<100; i++) |
|
454 | for (i=0; i<100; i++) | |
456 | { |
|
455 | { | |
457 | parameters[i] = 0xff; |
|
456 | parameters[i] = 0xff; | |
458 | } |
|
457 | } | |
459 |
|
458 | |||
460 | get_message_queue_id_send( &queue_id ); |
|
459 | get_message_queue_id_send( &queue_id ); | |
461 |
|
460 | |||
462 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
461 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
463 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
462 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
464 | } |
|
463 | } | |
465 |
|
464 | |||
466 | void get_temperatures( unsigned char *temperatures ) |
|
465 | void get_temperatures( unsigned char *temperatures ) | |
467 | { |
|
466 | { | |
468 | unsigned char* temp_scm_ptr; |
|
467 | unsigned char* temp_scm_ptr; | |
469 | unsigned char* temp_pcb_ptr; |
|
468 | unsigned char* temp_pcb_ptr; | |
470 | unsigned char* temp_fpga_ptr; |
|
469 | unsigned char* temp_fpga_ptr; | |
471 |
|
470 | |||
472 | // SEL1 SEL0 |
|
471 | // SEL1 SEL0 | |
473 | // 0 0 => PCB |
|
472 | // 0 0 => PCB | |
474 | // 0 1 => FPGA |
|
473 | // 0 1 => FPGA | |
475 | // 1 0 => SCM |
|
474 | // 1 0 => SCM | |
476 |
|
475 | |||
477 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
476 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
478 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
477 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
479 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
478 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
480 |
|
479 | |||
481 | temperatures[0] = temp_scm_ptr[2]; |
|
480 | temperatures[0] = temp_scm_ptr[2]; | |
482 | temperatures[1] = temp_scm_ptr[3]; |
|
481 | temperatures[1] = temp_scm_ptr[3]; | |
483 | temperatures[2] = temp_pcb_ptr[2]; |
|
482 | temperatures[2] = temp_pcb_ptr[2]; | |
484 | temperatures[3] = temp_pcb_ptr[3]; |
|
483 | temperatures[3] = temp_pcb_ptr[3]; | |
485 | temperatures[4] = temp_fpga_ptr[2]; |
|
484 | temperatures[4] = temp_fpga_ptr[2]; | |
486 | temperatures[5] = temp_fpga_ptr[3]; |
|
485 | temperatures[5] = temp_fpga_ptr[3]; | |
487 | } |
|
486 | } | |
488 |
|
487 | |||
489 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
488 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
490 | { |
|
489 | { | |
491 | unsigned char* v_ptr; |
|
490 | unsigned char* v_ptr; | |
492 | unsigned char* e1_ptr; |
|
491 | unsigned char* e1_ptr; | |
493 | unsigned char* e2_ptr; |
|
492 | unsigned char* e2_ptr; | |
494 |
|
493 | |||
495 | v_ptr = (unsigned char *) &waveform_picker_regs->v; |
|
494 | v_ptr = (unsigned char *) &waveform_picker_regs->v; | |
496 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; |
|
495 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; | |
497 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; |
|
496 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; | |
498 |
|
497 | |||
499 | spacecraft_potential[0] = v_ptr[2]; |
|
498 | spacecraft_potential[0] = v_ptr[2]; | |
500 | spacecraft_potential[1] = v_ptr[3]; |
|
499 | spacecraft_potential[1] = v_ptr[3]; | |
501 | spacecraft_potential[2] = e1_ptr[2]; |
|
500 | spacecraft_potential[2] = e1_ptr[2]; | |
502 | spacecraft_potential[3] = e1_ptr[3]; |
|
501 | spacecraft_potential[3] = e1_ptr[3]; | |
503 | spacecraft_potential[4] = e2_ptr[2]; |
|
502 | spacecraft_potential[4] = e2_ptr[2]; | |
504 | spacecraft_potential[5] = e2_ptr[3]; |
|
503 | spacecraft_potential[5] = e2_ptr[3]; | |
505 | } |
|
504 | } | |
506 |
|
505 | |||
507 | void get_cpu_load( unsigned char *resource_statistics ) |
|
506 | void get_cpu_load( unsigned char *resource_statistics ) | |
508 | { |
|
507 | { | |
509 | unsigned char cpu_load; |
|
508 | unsigned char cpu_load; | |
510 |
|
509 | |||
511 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
510 | cpu_load = lfr_rtems_cpu_usage_report(); | |
512 |
|
511 | |||
513 | // HK_LFR_CPU_LOAD |
|
512 | // HK_LFR_CPU_LOAD | |
514 | resource_statistics[0] = cpu_load; |
|
513 | resource_statistics[0] = cpu_load; | |
515 |
|
514 | |||
516 | // HK_LFR_CPU_LOAD_MAX |
|
515 | // HK_LFR_CPU_LOAD_MAX | |
517 | if (cpu_load > resource_statistics[1]) |
|
516 | if (cpu_load > resource_statistics[1]) | |
518 | { |
|
517 | { | |
519 | resource_statistics[1] = cpu_load; |
|
518 | resource_statistics[1] = cpu_load; | |
520 | } |
|
519 | } | |
521 |
|
520 | |||
522 | // CPU_LOAD_AVE |
|
521 | // CPU_LOAD_AVE | |
523 | resource_statistics[2] = 0; |
|
522 | resource_statistics[2] = 0; | |
524 |
|
523 | |||
525 | #ifndef PRINT_TASK_STATISTICS |
|
524 | #ifndef PRINT_TASK_STATISTICS | |
526 | rtems_cpu_usage_reset(); |
|
525 | rtems_cpu_usage_reset(); | |
527 | #endif |
|
526 | #endif | |
528 |
|
527 | |||
529 | } |
|
528 | } | |
530 |
|
529 | |||
531 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
530 | void set_hk_lfr_sc_potential_flag( bool state ) | |
532 | { |
|
531 | { | |
533 | if (state == true) |
|
532 | if (state == true) | |
534 | { |
|
533 | { | |
535 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] |
|
534 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] | |
536 | } |
|
535 | } | |
537 | else |
|
536 | else | |
538 | { |
|
537 | { | |
539 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] |
|
538 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] | |
540 | } |
|
539 | } | |
541 | } |
|
540 | } | |
542 |
|
541 | |||
543 | void set_hk_lfr_mag_fields_flag( bool state ) |
|
542 | void set_hk_lfr_mag_fields_flag( bool state ) | |
544 | { |
|
543 | { | |
545 | if (state == true) |
|
544 | if (state == true) | |
546 | { |
|
545 | { | |
547 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] |
|
546 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] | |
548 | } |
|
547 | } | |
549 | else |
|
548 | else | |
550 | { |
|
549 | { | |
551 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] |
|
550 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] | |
552 | } |
|
551 | } | |
553 | } |
|
552 | } | |
554 |
|
553 | |||
555 | void set_hk_lfr_calib_enable( bool state ) |
|
554 | void set_hk_lfr_calib_enable( bool state ) | |
556 | { |
|
555 | { | |
557 | if (state == true) |
|
556 | if (state == true) | |
558 | { |
|
557 | { | |
559 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] |
|
558 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] | |
560 | } |
|
559 | } | |
561 | else |
|
560 | else | |
562 | { |
|
561 | { | |
563 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] |
|
562 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] | |
564 | } |
|
563 | } | |
565 | } |
|
564 | } | |
566 |
|
565 | |||
567 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
566 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
568 | { |
|
567 | { | |
569 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
568 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
570 | | (lfr_reset_cause & 0x07 ); // [0000 0111] |
|
569 | | (lfr_reset_cause & 0x07 ); // [0000 0111] | |
571 | } |
|
570 | } |
@@ -1,1306 +1,1296 | |||||
1 | /** Functions related to the SpaceWire interface. |
|
1 | /** Functions related to the SpaceWire interface. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle SpaceWire transmissions: |
|
6 | * A group of functions to handle SpaceWire transmissions: | |
7 | * - configuration of the SpaceWire link |
|
7 | * - configuration of the SpaceWire link | |
8 | * - SpaceWire related interruption requests processing |
|
8 | * - SpaceWire related interruption requests processing | |
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task | |
10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
10 | * - reception of TeleCommands by a dedicated RTEMS task | |
11 | * |
|
11 | * | |
12 | */ |
|
12 | */ | |
13 |
|
13 | |||
14 | #include "fsw_spacewire.h" |
|
14 | #include "fsw_spacewire.h" | |
15 |
|
15 | |||
16 | rtems_name semq_name; |
|
16 | rtems_name semq_name; | |
17 | rtems_id semq_id; |
|
17 | rtems_id semq_id; | |
18 |
|
18 | |||
19 | //***************** |
|
19 | //***************** | |
20 | // waveform headers |
|
20 | // waveform headers | |
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; | |
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; |
|
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; | |
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
24 |
|
24 | |||
25 | //*********** |
|
25 | //*********** | |
26 | // RTEMS TASK |
|
26 | // RTEMS TASK | |
27 | rtems_task spiq_task(rtems_task_argument unused) |
|
27 | rtems_task spiq_task(rtems_task_argument unused) | |
28 | { |
|
28 | { | |
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. | |
30 | * |
|
30 | * | |
31 | * @param unused is the starting argument of the RTEMS task |
|
31 | * @param unused is the starting argument of the RTEMS task | |
32 | * |
|
32 | * | |
33 | */ |
|
33 | */ | |
34 |
|
34 | |||
35 | rtems_event_set event_out; |
|
35 | rtems_event_set event_out; | |
36 | rtems_status_code status; |
|
36 | rtems_status_code status; | |
37 | int linkStatus; |
|
37 | int linkStatus; | |
38 |
|
38 | |||
39 | BOOT_PRINTF("in SPIQ *** \n") |
|
39 | BOOT_PRINTF("in SPIQ *** \n") | |
40 |
|
40 | |||
41 | while(true){ |
|
41 | while(true){ | |
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") | |
44 |
|
44 | |||
45 | // [0] SUSPEND RECV AND SEND TASKS |
|
45 | // [0] SUSPEND RECV AND SEND TASKS | |
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); | |
47 | if ( status != RTEMS_SUCCESSFUL ) { |
|
47 | if ( status != RTEMS_SUCCESSFUL ) { | |
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") | |
49 | } |
|
49 | } | |
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); | |
51 | if ( status != RTEMS_SUCCESSFUL ) { |
|
51 | if ( status != RTEMS_SUCCESSFUL ) { | |
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | // [1] CHECK THE LINK |
|
55 | // [1] CHECK THE LINK | |
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) | |
57 | if ( linkStatus != 5) { |
|
57 | if ( linkStatus != 5) { | |
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) | |
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT | |
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) | |
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link | |
65 | { |
|
65 | { | |
66 | spacewire_compute_stats_offsets(); |
|
66 | spacewire_compute_stats_offsets(); | |
67 | status = spacewire_reset_link( ); |
|
67 | status = spacewire_reset_link( ); | |
68 | } |
|
68 | } | |
69 | else // [2.b] in run state, start the link |
|
69 | else // [2.b] in run state, start the link | |
70 | { |
|
70 | { | |
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link | |
72 | if ( status != RTEMS_SUCCESSFUL) |
|
72 | if ( status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) |
|
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS | |
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully | |
80 | { |
|
80 | { | |
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
82 | if ( status != RTEMS_SUCCESSFUL ) { |
|
82 | if ( status != RTEMS_SUCCESSFUL ) { | |
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") | |
84 | } |
|
84 | } | |
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
86 | if ( status != RTEMS_SUCCESSFUL ) { |
|
86 | if ( status != RTEMS_SUCCESSFUL ) { | |
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
90 | else // [3.b] the link is not in run state, go in STANDBY mode | |
91 | { |
|
91 | { | |
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); | |
93 | if ( status != RTEMS_SUCCESSFUL ) { |
|
93 | if ( status != RTEMS_SUCCESSFUL ) { | |
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
95 | } |
|
95 | } | |
96 | // wake the WTDG task up to wait for the link recovery |
|
96 | // wake the WTDG task up to wait for the link recovery | |
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); | |
98 | status = rtems_task_suspend( RTEMS_SELF ); |
|
98 | status = rtems_task_suspend( RTEMS_SELF ); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | rtems_task recv_task( rtems_task_argument unused ) |
|
103 | rtems_task recv_task( rtems_task_argument unused ) | |
104 | { |
|
104 | { | |
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
106 | * |
|
106 | * | |
107 | * @param unused is the starting argument of the RTEMS task |
|
107 | * @param unused is the starting argument of the RTEMS task | |
108 | * |
|
108 | * | |
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
110 | * 1. It reads the incoming data. |
|
110 | * 1. It reads the incoming data. | |
111 | * 2. Launches the acceptance procedure. |
|
111 | * 2. Launches the acceptance procedure. | |
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
113 | * |
|
113 | * | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | int len; |
|
116 | int len; | |
117 | ccsdsTelecommandPacket_t currentTC; |
|
117 | ccsdsTelecommandPacket_t currentTC; | |
118 | unsigned char computed_CRC[ 2 ]; |
|
118 | unsigned char computed_CRC[ 2 ]; | |
119 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
119 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
120 | unsigned char destinationID; |
|
120 | unsigned char destinationID; | |
121 | unsigned int estimatedPacketLength; |
|
121 | unsigned int estimatedPacketLength; | |
122 | unsigned int parserCode; |
|
122 | unsigned int parserCode; | |
123 | rtems_status_code status; |
|
123 | rtems_status_code status; | |
124 | rtems_id queue_recv_id; |
|
124 | rtems_id queue_recv_id; | |
125 | rtems_id queue_send_id; |
|
125 | rtems_id queue_send_id; | |
126 |
|
126 | |||
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
128 |
|
128 | |||
129 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
129 | status = get_message_queue_id_recv( &queue_recv_id ); | |
130 | if (status != RTEMS_SUCCESSFUL) |
|
130 | if (status != RTEMS_SUCCESSFUL) | |
131 | { |
|
131 | { | |
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | status = get_message_queue_id_send( &queue_send_id ); |
|
135 | status = get_message_queue_id_send( &queue_send_id ); | |
136 | if (status != RTEMS_SUCCESSFUL) |
|
136 | if (status != RTEMS_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | BOOT_PRINTF("in RECV *** \n") |
|
141 | BOOT_PRINTF("in RECV *** \n") | |
142 |
|
142 | |||
143 | while(1) |
|
143 | while(1) | |
144 | { |
|
144 | { | |
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
146 | if (len == -1){ // error during the read call |
|
146 | if (len == -1){ // error during the read call | |
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
148 | } |
|
148 | } | |
149 | else { |
|
149 | else { | |
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
151 | PRINTF("in RECV *** packet lenght too short\n") |
|
151 | PRINTF("in RECV *** packet lenght too short\n") | |
152 | } |
|
152 | } | |
153 | else { |
|
153 | else { | |
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); | |
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); | |
157 | // CHECK THE TC |
|
157 | // CHECK THE TC | |
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; | |
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
162 | || (parserCode == WRONG_SRC_ID) ) |
|
162 | || (parserCode == WRONG_SRC_ID) ) | |
163 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
163 | { // send TM_LFR_TC_EXE_CORRUPTED | |
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) | |
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
166 | && |
|
166 | && | |
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
168 | ) |
|
168 | ) | |
169 | { |
|
169 | { | |
170 | if ( parserCode == WRONG_SRC_ID ) |
|
170 | if ( parserCode == WRONG_SRC_ID ) | |
171 | { |
|
171 | { | |
172 | destinationID = SID_TC_GROUND; |
|
172 | destinationID = SID_TC_GROUND; | |
173 | } |
|
173 | } | |
174 | else |
|
174 | else | |
175 | { |
|
175 | { | |
176 | destinationID = currentTC.sourceID; |
|
176 | destinationID = currentTC.sourceID; | |
177 | } |
|
177 | } | |
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
179 | computed_CRC, currentTC_LEN_RCV, |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
180 | destinationID ); |
|
180 | destinationID ); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { // send valid TC to the action launcher |
|
184 | { // send valid TC to the action launcher | |
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); |
|
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); | |
192 |
|
192 | |||
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | rtems_task send_task( rtems_task_argument argument) |
|
196 | rtems_task send_task( rtems_task_argument argument) | |
197 | { |
|
197 | { | |
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
199 | * |
|
199 | * | |
200 | * @param unused is the starting argument of the RTEMS task |
|
200 | * @param unused is the starting argument of the RTEMS task | |
201 | * |
|
201 | * | |
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
206 | * data it contains. |
|
206 | * data it contains. | |
207 | * |
|
207 | * | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | rtems_status_code status; // RTEMS status code |
|
210 | rtems_status_code status; // RTEMS status code | |
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
212 | ring_node *incomingRingNodePtr; |
|
212 | ring_node *incomingRingNodePtr; | |
213 | int ring_node_address; |
|
213 | int ring_node_address; | |
214 | char *charPtr; |
|
214 | char *charPtr; | |
215 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
215 | spw_ioctl_pkt_send *spw_ioctl_send; | |
216 | size_t size; // size of the incoming TC packet |
|
216 | size_t size; // size of the incoming TC packet | |
217 | rtems_id queue_send_id; |
|
217 | rtems_id queue_send_id; | |
218 | unsigned int sid; |
|
218 | unsigned int sid; | |
219 |
|
219 | |||
220 | incomingRingNodePtr = NULL; |
|
220 | incomingRingNodePtr = NULL; | |
221 | ring_node_address = 0; |
|
221 | ring_node_address = 0; | |
222 | charPtr = (char *) &ring_node_address; |
|
222 | charPtr = (char *) &ring_node_address; | |
223 | sid = 0; |
|
223 | sid = 0; | |
224 |
|
224 | |||
225 | init_header_cwf( &headerCWF ); |
|
225 | init_header_cwf( &headerCWF ); | |
226 | init_header_swf( &headerSWF ); |
|
226 | init_header_swf( &headerSWF ); | |
227 | init_header_asm( &headerASM ); |
|
227 | init_header_asm( &headerASM ); | |
228 |
|
228 | |||
229 | status = get_message_queue_id_send( &queue_send_id ); |
|
229 | status = get_message_queue_id_send( &queue_send_id ); | |
230 | if (status != RTEMS_SUCCESSFUL) |
|
230 | if (status != RTEMS_SUCCESSFUL) | |
231 | { |
|
231 | { | |
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | BOOT_PRINTF("in SEND *** \n") |
|
235 | BOOT_PRINTF("in SEND *** \n") | |
236 |
|
236 | |||
237 | while(1) |
|
237 | while(1) | |
238 | { |
|
238 | { | |
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, |
|
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, | |
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
241 |
|
241 | |||
242 | if (status!=RTEMS_SUCCESSFUL) |
|
242 | if (status!=RTEMS_SUCCESSFUL) | |
243 | { |
|
243 | { | |
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
245 | } |
|
245 | } | |
246 | else |
|
246 | else | |
247 | { |
|
247 | { | |
248 | if ( size == sizeof(ring_node*) ) |
|
248 | if ( size == sizeof(ring_node*) ) | |
249 | { |
|
249 | { | |
250 | charPtr[0] = incomingData[0]; |
|
250 | charPtr[0] = incomingData[0]; | |
251 | charPtr[1] = incomingData[1]; |
|
251 | charPtr[1] = incomingData[1]; | |
252 | charPtr[2] = incomingData[2]; |
|
252 | charPtr[2] = incomingData[2]; | |
253 | charPtr[3] = incomingData[3]; |
|
253 | charPtr[3] = incomingData[3]; | |
254 | incomingRingNodePtr = (ring_node*) ring_node_address; |
|
254 | incomingRingNodePtr = (ring_node*) ring_node_address; | |
255 | sid = incomingRingNodePtr->sid; |
|
255 | sid = incomingRingNodePtr->sid; | |
256 | if ( (sid==SID_NORM_CWF_LONG_F3) |
|
256 | if ( (sid==SID_NORM_CWF_LONG_F3) | |
257 | || (sid==SID_BURST_CWF_F2 ) |
|
257 | || (sid==SID_BURST_CWF_F2 ) | |
258 | || (sid==SID_SBM1_CWF_F1 ) |
|
258 | || (sid==SID_SBM1_CWF_F1 ) | |
259 | || (sid==SID_SBM2_CWF_F2 )) |
|
259 | || (sid==SID_SBM2_CWF_F2 )) | |
260 | { |
|
260 | { | |
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); |
|
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); | |
262 | } |
|
262 | } | |
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) |
|
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) | |
264 | { |
|
264 | { | |
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); |
|
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); | |
266 | } |
|
266 | } | |
267 | else if ( (sid==SID_NORM_CWF_F3) ) |
|
267 | else if ( (sid==SID_NORM_CWF_F3) ) | |
268 | { |
|
268 | { | |
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); |
|
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); | |
270 | } |
|
270 | } | |
271 | else if (sid==SID_NORM_ASM_F0) |
|
271 | else if (sid==SID_NORM_ASM_F0) | |
272 | { |
|
272 | { | |
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); |
|
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); | |
274 | } |
|
274 | } | |
275 | else if (sid==SID_NORM_ASM_F1) |
|
275 | else if (sid==SID_NORM_ASM_F1) | |
276 | { |
|
276 | { | |
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); |
|
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); | |
278 | } |
|
278 | } | |
279 | else if (sid==SID_NORM_ASM_F2) |
|
279 | else if (sid==SID_NORM_ASM_F2) | |
280 | { |
|
280 | { | |
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); |
|
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); | |
282 | } |
|
282 | } | |
283 | else if ( sid==TM_CODE_K_DUMP ) |
|
283 | else if ( sid==TM_CODE_K_DUMP ) | |
284 | { |
|
284 | { | |
285 | spw_send_k_dump( incomingRingNodePtr ); |
|
285 | spw_send_k_dump( incomingRingNodePtr ); | |
286 | } |
|
286 | } | |
287 | else |
|
287 | else | |
288 | { |
|
288 | { | |
289 |
|
|
289 | PRINTF1("unexpected sid = %d\n", sid); | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet |
|
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet | |
293 | { |
|
293 | { | |
294 | status = write( fdSPW, incomingData, size ); |
|
294 | status = write( fdSPW, incomingData, size ); | |
295 | if (status == -1){ |
|
295 | if (status == -1){ | |
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
297 | } |
|
297 | } | |
298 | } |
|
298 | } | |
299 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
299 | else // the incoming message is a spw_ioctl_pkt_send structure | |
300 | { |
|
300 | { | |
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
303 | if (status == -1){ |
|
303 | if (status == -1){ | |
304 | printf("size = %d, %x, %x, %x, %x, %x\n", |
|
|||
305 | size, |
|
|||
306 | incomingData[0], |
|
|||
307 | incomingData[1], |
|
|||
308 | incomingData[2], |
|
|||
309 | incomingData[3], |
|
|||
310 | incomingData[4]); |
|
|||
311 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
304 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
312 | } |
|
305 | } | |
313 | } |
|
306 | } | |
314 | } |
|
307 | } | |
315 |
|
308 | |||
316 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); |
|
309 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); | |
317 |
|
310 | |||
318 | } |
|
311 | } | |
319 | } |
|
312 | } | |
320 |
|
313 | |||
321 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
314 | rtems_task wtdg_task( rtems_task_argument argument ) | |
322 | { |
|
315 | { | |
323 | rtems_event_set event_out; |
|
316 | rtems_event_set event_out; | |
324 | rtems_status_code status; |
|
317 | rtems_status_code status; | |
325 | int linkStatus; |
|
318 | int linkStatus; | |
326 |
|
319 | |||
327 | BOOT_PRINTF("in WTDG ***\n") |
|
320 | BOOT_PRINTF("in WTDG ***\n") | |
328 |
|
321 | |||
329 | while(1) |
|
322 | while(1) | |
330 | { |
|
323 | { | |
331 | // wait for an RTEMS_EVENT |
|
324 | // wait for an RTEMS_EVENT | |
332 | rtems_event_receive( RTEMS_EVENT_0, |
|
325 | rtems_event_receive( RTEMS_EVENT_0, | |
333 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
326 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
334 | PRINTF("in WTDG *** wait for the link\n") |
|
327 | PRINTF("in WTDG *** wait for the link\n") | |
335 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
328 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
336 | while( linkStatus != 5) // wait for the link |
|
329 | while( linkStatus != 5) // wait for the link | |
337 | { |
|
330 | { | |
338 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms |
|
331 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms | |
339 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
332 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
340 | } |
|
333 | } | |
341 |
|
334 | |||
342 | status = spacewire_stop_and_start_link( fdSPW ); |
|
335 | status = spacewire_stop_and_start_link( fdSPW ); | |
343 |
|
336 | |||
344 | if (status != RTEMS_SUCCESSFUL) |
|
337 | if (status != RTEMS_SUCCESSFUL) | |
345 | { |
|
338 | { | |
346 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
339 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
347 | } |
|
340 | } | |
348 | else |
|
341 | else | |
349 | { |
|
342 | { | |
350 | PRINTF("in WTDG *** OK link started\n") |
|
343 | PRINTF("in WTDG *** OK link started\n") | |
351 | } |
|
344 | } | |
352 |
|
345 | |||
353 | // restart the SPIQ task |
|
346 | // restart the SPIQ task | |
354 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
347 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
355 | if ( status != RTEMS_SUCCESSFUL ) { |
|
348 | if ( status != RTEMS_SUCCESSFUL ) { | |
356 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
349 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
357 | } |
|
350 | } | |
358 |
|
351 | |||
359 | // restart RECV and SEND |
|
352 | // restart RECV and SEND | |
360 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
353 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
361 | if ( status != RTEMS_SUCCESSFUL ) { |
|
354 | if ( status != RTEMS_SUCCESSFUL ) { | |
362 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
355 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
363 | } |
|
356 | } | |
364 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
357 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
365 | if ( status != RTEMS_SUCCESSFUL ) { |
|
358 | if ( status != RTEMS_SUCCESSFUL ) { | |
366 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
359 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
367 | } |
|
360 | } | |
368 | } |
|
361 | } | |
369 | } |
|
362 | } | |
370 |
|
363 | |||
371 | //**************** |
|
364 | //**************** | |
372 | // OTHER FUNCTIONS |
|
365 | // OTHER FUNCTIONS | |
373 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
366 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] | |
374 | { |
|
367 | { | |
375 | /** This function opens the SpaceWire link. |
|
368 | /** This function opens the SpaceWire link. | |
376 | * |
|
369 | * | |
377 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
370 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
378 | * |
|
371 | * | |
379 | */ |
|
372 | */ | |
380 | rtems_status_code status; |
|
373 | rtems_status_code status; | |
381 |
|
374 | |||
382 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
375 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
383 | if ( fdSPW < 0 ) { |
|
376 | if ( fdSPW < 0 ) { | |
384 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
377 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
385 | } |
|
378 | } | |
386 | else |
|
379 | else | |
387 | { |
|
380 | { | |
388 | status = RTEMS_SUCCESSFUL; |
|
381 | status = RTEMS_SUCCESSFUL; | |
389 | } |
|
382 | } | |
390 |
|
383 | |||
391 | return status; |
|
384 | return status; | |
392 | } |
|
385 | } | |
393 |
|
386 | |||
394 | int spacewire_start_link( int fd ) |
|
387 | int spacewire_start_link( int fd ) | |
395 | { |
|
388 | { | |
396 | rtems_status_code status; |
|
389 | rtems_status_code status; | |
397 |
|
390 | |||
398 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
391 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
399 | // -1 default hardcoded driver timeout |
|
392 | // -1 default hardcoded driver timeout | |
400 |
|
393 | |||
401 | return status; |
|
394 | return status; | |
402 | } |
|
395 | } | |
403 |
|
396 | |||
404 | int spacewire_stop_and_start_link( int fd ) |
|
397 | int spacewire_stop_and_start_link( int fd ) | |
405 | { |
|
398 | { | |
406 | rtems_status_code status; |
|
399 | rtems_status_code status; | |
407 |
|
400 | |||
408 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
401 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
409 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
402 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
410 | // -1 default hardcoded driver timeout |
|
403 | // -1 default hardcoded driver timeout | |
411 |
|
404 | |||
412 | return status; |
|
405 | return status; | |
413 | } |
|
406 | } | |
414 |
|
407 | |||
415 | int spacewire_configure_link( int fd ) |
|
408 | int spacewire_configure_link( int fd ) | |
416 | { |
|
409 | { | |
417 | /** This function configures the SpaceWire link. |
|
410 | /** This function configures the SpaceWire link. | |
418 | * |
|
411 | * | |
419 | * @return GR-RTEMS-DRIVER directive status codes: |
|
412 | * @return GR-RTEMS-DRIVER directive status codes: | |
420 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
413 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
421 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
414 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
422 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
415 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
423 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
416 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
424 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
417 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
425 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
418 | * - 5 EIO - Error when writing to grswp hardware registers. | |
426 | * - 2 ENOENT - No such file or directory |
|
419 | * - 2 ENOENT - No such file or directory | |
427 | */ |
|
420 | */ | |
428 |
|
421 | |||
429 | rtems_status_code status; |
|
422 | rtems_status_code status; | |
430 |
|
423 | |||
431 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
424 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
432 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
425 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
433 |
|
426 | |||
434 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
427 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
435 | if (status!=RTEMS_SUCCESSFUL) { |
|
428 | if (status!=RTEMS_SUCCESSFUL) { | |
436 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
429 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
437 | } |
|
430 | } | |
438 | // |
|
431 | // | |
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
432 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
440 | if (status!=RTEMS_SUCCESSFUL) { |
|
433 | if (status!=RTEMS_SUCCESSFUL) { | |
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
434 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
442 | } |
|
435 | } | |
443 | // |
|
436 | // | |
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
437 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
445 | if (status!=RTEMS_SUCCESSFUL) { |
|
438 | if (status!=RTEMS_SUCCESSFUL) { | |
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
439 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
447 | } |
|
440 | } | |
448 | // |
|
441 | // | |
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
442 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
450 | if (status!=RTEMS_SUCCESSFUL) { |
|
443 | if (status!=RTEMS_SUCCESSFUL) { | |
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
444 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
452 | } |
|
445 | } | |
453 | // |
|
446 | // | |
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks |
|
447 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks | |
455 | if (status!=RTEMS_SUCCESSFUL) { |
|
448 | if (status!=RTEMS_SUCCESSFUL) { | |
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
449 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
457 | } |
|
450 | } | |
458 | // |
|
451 | // | |
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
452 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
460 | if (status!=RTEMS_SUCCESSFUL) { |
|
453 | if (status!=RTEMS_SUCCESSFUL) { | |
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
454 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
462 | } |
|
455 | } | |
463 | // |
|
456 | // | |
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
457 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
465 | if (status!=RTEMS_SUCCESSFUL) { |
|
458 | if (status!=RTEMS_SUCCESSFUL) { | |
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
459 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
467 | } |
|
460 | } | |
468 |
|
461 | |||
469 | return status; |
|
462 | return status; | |
470 | } |
|
463 | } | |
471 |
|
464 | |||
472 | int spacewire_reset_link( void ) |
|
465 | int spacewire_reset_link( void ) | |
473 | { |
|
466 | { | |
474 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
467 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
475 | * |
|
468 | * | |
476 | * @return RTEMS directive status code: |
|
469 | * @return RTEMS directive status code: | |
477 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
470 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
478 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
471 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
479 | * |
|
472 | * | |
480 | */ |
|
473 | */ | |
481 |
|
474 | |||
482 | rtems_status_code status_spw; |
|
475 | rtems_status_code status_spw; | |
483 | rtems_status_code status; |
|
476 | rtems_status_code status; | |
484 | int i; |
|
477 | int i; | |
485 |
|
478 | |||
486 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
479 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
487 | { |
|
480 | { | |
488 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
481 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
489 |
|
482 | |||
490 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
483 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
491 |
|
484 | |||
492 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
485 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
493 |
|
486 | |||
494 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
487 | status_spw = spacewire_stop_and_start_link( fdSPW ); | |
495 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
488 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
496 | { |
|
489 | { | |
497 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
490 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
498 | } |
|
491 | } | |
499 |
|
492 | |||
500 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
493 | if ( status_spw == RTEMS_SUCCESSFUL) | |
501 | { |
|
494 | { | |
502 | break; |
|
495 | break; | |
503 | } |
|
496 | } | |
504 | } |
|
497 | } | |
505 |
|
498 | |||
506 | return status_spw; |
|
499 | return status_spw; | |
507 | } |
|
500 | } | |
508 |
|
501 | |||
509 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
502 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
510 | { |
|
503 | { | |
511 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
504 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
512 | * |
|
505 | * | |
513 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
506 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
514 | * @param regAddr is the address of the GRSPW control register. |
|
507 | * @param regAddr is the address of the GRSPW control register. | |
515 | * |
|
508 | * | |
516 | * NP is the bit 20 of the GRSPW control register. |
|
509 | * NP is the bit 20 of the GRSPW control register. | |
517 | * |
|
510 | * | |
518 | */ |
|
511 | */ | |
519 |
|
512 | |||
520 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
513 | unsigned int *spwptr = (unsigned int*) regAddr; | |
521 |
|
514 | |||
522 | if (val == 1) { |
|
515 | if (val == 1) { | |
523 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
516 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
524 | } |
|
517 | } | |
525 | if (val== 0) { |
|
518 | if (val== 0) { | |
526 | *spwptr = *spwptr & 0xffdfffff; |
|
519 | *spwptr = *spwptr & 0xffdfffff; | |
527 | } |
|
520 | } | |
528 | } |
|
521 | } | |
529 |
|
522 | |||
530 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
523 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
531 | { |
|
524 | { | |
532 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
525 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
533 | * |
|
526 | * | |
534 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
527 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
535 | * @param regAddr is the address of the GRSPW control register. |
|
528 | * @param regAddr is the address of the GRSPW control register. | |
536 | * |
|
529 | * | |
537 | * RE is the bit 16 of the GRSPW control register. |
|
530 | * RE is the bit 16 of the GRSPW control register. | |
538 | * |
|
531 | * | |
539 | */ |
|
532 | */ | |
540 |
|
533 | |||
541 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
534 | unsigned int *spwptr = (unsigned int*) regAddr; | |
542 |
|
535 | |||
543 | if (val == 1) |
|
536 | if (val == 1) | |
544 | { |
|
537 | { | |
545 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
538 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
546 | } |
|
539 | } | |
547 | if (val== 0) |
|
540 | if (val== 0) | |
548 | { |
|
541 | { | |
549 | *spwptr = *spwptr & 0xfffdffff; |
|
542 | *spwptr = *spwptr & 0xfffdffff; | |
550 | } |
|
543 | } | |
551 | } |
|
544 | } | |
552 |
|
545 | |||
553 | void spacewire_compute_stats_offsets( void ) |
|
546 | void spacewire_compute_stats_offsets( void ) | |
554 | { |
|
547 | { | |
555 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
548 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
556 | * |
|
549 | * | |
557 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
550 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
558 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
551 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
559 | * during the open systel call). |
|
552 | * during the open systel call). | |
560 | * |
|
553 | * | |
561 | */ |
|
554 | */ | |
562 |
|
555 | |||
563 | spw_stats spacewire_stats_grspw; |
|
556 | spw_stats spacewire_stats_grspw; | |
564 | rtems_status_code status; |
|
557 | rtems_status_code status; | |
565 |
|
558 | |||
566 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
559 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
567 |
|
560 | |||
568 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
561 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
569 | + spacewire_stats.packets_received; |
|
562 | + spacewire_stats.packets_received; | |
570 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
563 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
571 | + spacewire_stats.packets_sent; |
|
564 | + spacewire_stats.packets_sent; | |
572 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
565 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
573 | + spacewire_stats.parity_err; |
|
566 | + spacewire_stats.parity_err; | |
574 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
567 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
575 | + spacewire_stats.disconnect_err; |
|
568 | + spacewire_stats.disconnect_err; | |
576 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
569 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
577 | + spacewire_stats.escape_err; |
|
570 | + spacewire_stats.escape_err; | |
578 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
571 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
579 | + spacewire_stats.credit_err; |
|
572 | + spacewire_stats.credit_err; | |
580 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
573 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
581 | + spacewire_stats.write_sync_err; |
|
574 | + spacewire_stats.write_sync_err; | |
582 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
575 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
583 | + spacewire_stats.rx_rmap_header_crc_err; |
|
576 | + spacewire_stats.rx_rmap_header_crc_err; | |
584 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
577 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
585 | + spacewire_stats.rx_rmap_data_crc_err; |
|
578 | + spacewire_stats.rx_rmap_data_crc_err; | |
586 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
579 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
587 | + spacewire_stats.early_ep; |
|
580 | + spacewire_stats.early_ep; | |
588 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
581 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
589 | + spacewire_stats.invalid_address; |
|
582 | + spacewire_stats.invalid_address; | |
590 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
583 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
591 | + spacewire_stats.rx_eep_err; |
|
584 | + spacewire_stats.rx_eep_err; | |
592 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
585 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
593 | + spacewire_stats.rx_truncated; |
|
586 | + spacewire_stats.rx_truncated; | |
594 | } |
|
587 | } | |
595 |
|
588 | |||
596 | void spacewire_update_statistics( void ) |
|
589 | void spacewire_update_statistics( void ) | |
597 | { |
|
590 | { | |
598 | rtems_status_code status; |
|
591 | rtems_status_code status; | |
599 | spw_stats spacewire_stats_grspw; |
|
592 | spw_stats spacewire_stats_grspw; | |
600 |
|
593 | |||
601 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
594 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
602 |
|
595 | |||
603 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
596 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
604 | + spacewire_stats_grspw.packets_received; |
|
597 | + spacewire_stats_grspw.packets_received; | |
605 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
598 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
606 | + spacewire_stats_grspw.packets_sent; |
|
599 | + spacewire_stats_grspw.packets_sent; | |
607 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
600 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
608 | + spacewire_stats_grspw.parity_err; |
|
601 | + spacewire_stats_grspw.parity_err; | |
609 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
602 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
610 | + spacewire_stats_grspw.disconnect_err; |
|
603 | + spacewire_stats_grspw.disconnect_err; | |
611 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
604 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
612 | + spacewire_stats_grspw.escape_err; |
|
605 | + spacewire_stats_grspw.escape_err; | |
613 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
606 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
614 | + spacewire_stats_grspw.credit_err; |
|
607 | + spacewire_stats_grspw.credit_err; | |
615 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
608 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
616 | + spacewire_stats_grspw.write_sync_err; |
|
609 | + spacewire_stats_grspw.write_sync_err; | |
617 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
610 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
618 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
611 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
619 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
612 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
620 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
613 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
621 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
614 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
622 | + spacewire_stats_grspw.early_ep; |
|
615 | + spacewire_stats_grspw.early_ep; | |
623 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
616 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
624 | + spacewire_stats_grspw.invalid_address; |
|
617 | + spacewire_stats_grspw.invalid_address; | |
625 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
618 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
626 | + spacewire_stats_grspw.rx_eep_err; |
|
619 | + spacewire_stats_grspw.rx_eep_err; | |
627 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
620 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
628 | + spacewire_stats_grspw.rx_truncated; |
|
621 | + spacewire_stats_grspw.rx_truncated; | |
629 | //spacewire_stats.tx_link_err; |
|
622 | //spacewire_stats.tx_link_err; | |
630 |
|
623 | |||
631 | //**************************** |
|
624 | //**************************** | |
632 | // DPU_SPACEWIRE_IF_STATISTICS |
|
625 | // DPU_SPACEWIRE_IF_STATISTICS | |
633 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
626 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
634 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
627 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
635 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
628 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
636 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
629 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
637 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
630 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
638 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
631 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
639 |
|
632 | |||
640 | //****************************************** |
|
633 | //****************************************** | |
641 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
634 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
642 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
635 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
643 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
636 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
644 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
637 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
645 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
638 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
646 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
639 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
647 |
|
640 | |||
648 | //********************************************* |
|
641 | //********************************************* | |
649 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
642 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
650 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
643 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
651 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
644 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
652 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
645 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
653 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
646 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
654 | } |
|
647 | } | |
655 |
|
648 | |||
656 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
649 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
657 | { |
|
650 | { | |
658 | // a valid timecode has been received, write it in the HK report |
|
651 | // a valid timecode has been received, write it in the HK report | |
659 | unsigned int *grspwPtr; |
|
652 | unsigned int *grspwPtr; | |
660 | unsigned char timecodeCtr; |
|
653 | unsigned char timecodeCtr; | |
661 | unsigned char updateTimeCtr; |
|
654 | unsigned char updateTimeCtr; | |
662 |
|
655 | |||
663 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); |
|
656 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); | |
664 |
|
657 | |||
665 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] |
|
658 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] | |
666 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] |
|
659 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] | |
667 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] |
|
660 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] | |
668 |
|
661 | |||
669 | // update the number of valid timecodes that have been received |
|
662 | // update the number of valid timecodes that have been received | |
670 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) |
|
663 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) | |
671 | { |
|
664 | { | |
672 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; |
|
665 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; | |
673 | } |
|
666 | } | |
674 | else |
|
667 | else | |
675 | { |
|
668 | { | |
676 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; |
|
669 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; | |
677 | } |
|
670 | } | |
678 |
|
671 | |||
679 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 |
|
672 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 | |
680 | if (timecodeCtr != updateTimeCtr) |
|
673 | if (timecodeCtr != updateTimeCtr) | |
681 | { |
|
674 | { | |
682 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) |
|
675 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) | |
683 | { |
|
676 | { | |
684 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; |
|
677 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; | |
685 | } |
|
678 | } | |
686 | else |
|
679 | else | |
687 | { |
|
680 | { | |
688 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; |
|
681 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; | |
689 | } |
|
682 | } | |
690 | } |
|
683 | } | |
691 | } |
|
684 | } | |
692 |
|
685 | |||
693 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
686 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) | |
694 | { |
|
687 | { | |
695 | int linkStatus; |
|
688 | int linkStatus; | |
696 | rtems_status_code status; |
|
689 | rtems_status_code status; | |
697 |
|
690 | |||
698 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
691 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
699 |
|
692 | |||
700 | if ( linkStatus == 5) { |
|
693 | if ( linkStatus == 5) { | |
701 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
694 | PRINTF("in spacewire_reset_link *** link is running\n") | |
702 | status = RTEMS_SUCCESSFUL; |
|
695 | status = RTEMS_SUCCESSFUL; | |
703 | } |
|
696 | } | |
704 | } |
|
697 | } | |
705 |
|
698 | |||
706 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
699 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) | |
707 | { |
|
700 | { | |
708 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
701 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
709 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
702 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
710 | header->reserved = DEFAULT_RESERVED; |
|
703 | header->reserved = DEFAULT_RESERVED; | |
711 | header->userApplication = CCSDS_USER_APP; |
|
704 | header->userApplication = CCSDS_USER_APP; | |
712 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; |
|
705 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; | |
713 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; |
|
706 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; | |
714 | header->packetLength[0] = 0x00; |
|
707 | header->packetLength[0] = 0x00; | |
715 | header->packetLength[1] = 0x00; |
|
708 | header->packetLength[1] = 0x00; | |
716 | // DATA FIELD HEADER |
|
709 | // DATA FIELD HEADER | |
717 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
710 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
718 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
711 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
719 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
712 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
720 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
713 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
721 | header->time[0] = 0x00; |
|
714 | header->time[0] = 0x00; | |
722 | header->time[0] = 0x00; |
|
715 | header->time[0] = 0x00; | |
723 | header->time[0] = 0x00; |
|
716 | header->time[0] = 0x00; | |
724 | header->time[0] = 0x00; |
|
717 | header->time[0] = 0x00; | |
725 | header->time[0] = 0x00; |
|
718 | header->time[0] = 0x00; | |
726 | header->time[0] = 0x00; |
|
719 | header->time[0] = 0x00; | |
727 | // AUXILIARY DATA HEADER |
|
720 | // AUXILIARY DATA HEADER | |
728 | header->sid = 0x00; |
|
721 | header->sid = 0x00; | |
729 | header->hkBIA = DEFAULT_HKBIA; |
|
722 | header->hkBIA = DEFAULT_HKBIA; | |
730 | header->blkNr[0] = 0x00; |
|
723 | header->blkNr[0] = 0x00; | |
731 | header->blkNr[1] = 0x00; |
|
724 | header->blkNr[1] = 0x00; | |
732 | } |
|
725 | } | |
733 |
|
726 | |||
734 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
727 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) | |
735 | { |
|
728 | { | |
736 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
729 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
737 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
730 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
738 | header->reserved = DEFAULT_RESERVED; |
|
731 | header->reserved = DEFAULT_RESERVED; | |
739 | header->userApplication = CCSDS_USER_APP; |
|
732 | header->userApplication = CCSDS_USER_APP; | |
740 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
733 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
741 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
734 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
742 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
735 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
743 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
736 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
744 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
737 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
745 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
738 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
746 | // DATA FIELD HEADER |
|
739 | // DATA FIELD HEADER | |
747 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
740 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
748 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
741 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
749 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
742 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
750 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
743 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
751 | header->time[0] = 0x00; |
|
744 | header->time[0] = 0x00; | |
752 | header->time[0] = 0x00; |
|
745 | header->time[0] = 0x00; | |
753 | header->time[0] = 0x00; |
|
746 | header->time[0] = 0x00; | |
754 | header->time[0] = 0x00; |
|
747 | header->time[0] = 0x00; | |
755 | header->time[0] = 0x00; |
|
748 | header->time[0] = 0x00; | |
756 | header->time[0] = 0x00; |
|
749 | header->time[0] = 0x00; | |
757 | // AUXILIARY DATA HEADER |
|
750 | // AUXILIARY DATA HEADER | |
758 | header->sid = 0x00; |
|
751 | header->sid = 0x00; | |
759 | header->hkBIA = DEFAULT_HKBIA; |
|
752 | header->hkBIA = DEFAULT_HKBIA; | |
760 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
753 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
761 | header->pktNr = 0x00; |
|
754 | header->pktNr = 0x00; | |
762 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
755 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
763 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
756 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
764 | } |
|
757 | } | |
765 |
|
758 | |||
766 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
759 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) | |
767 | { |
|
760 | { | |
768 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
761 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
769 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
762 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
770 | header->reserved = DEFAULT_RESERVED; |
|
763 | header->reserved = DEFAULT_RESERVED; | |
771 | header->userApplication = CCSDS_USER_APP; |
|
764 | header->userApplication = CCSDS_USER_APP; | |
772 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
765 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
773 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
766 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
774 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
767 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
775 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
768 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
776 | header->packetLength[0] = 0x00; |
|
769 | header->packetLength[0] = 0x00; | |
777 | header->packetLength[1] = 0x00; |
|
770 | header->packetLength[1] = 0x00; | |
778 | // DATA FIELD HEADER |
|
771 | // DATA FIELD HEADER | |
779 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
772 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
780 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
773 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
781 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
774 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
782 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
775 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
783 | header->time[0] = 0x00; |
|
776 | header->time[0] = 0x00; | |
784 | header->time[0] = 0x00; |
|
777 | header->time[0] = 0x00; | |
785 | header->time[0] = 0x00; |
|
778 | header->time[0] = 0x00; | |
786 | header->time[0] = 0x00; |
|
779 | header->time[0] = 0x00; | |
787 | header->time[0] = 0x00; |
|
780 | header->time[0] = 0x00; | |
788 | header->time[0] = 0x00; |
|
781 | header->time[0] = 0x00; | |
789 | // AUXILIARY DATA HEADER |
|
782 | // AUXILIARY DATA HEADER | |
790 | header->sid = 0x00; |
|
783 | header->sid = 0x00; | |
791 | header->biaStatusInfo = 0x00; |
|
784 | header->biaStatusInfo = 0x00; | |
792 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
785 | header->pa_lfr_pkt_cnt_asm = 0x00; | |
793 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
786 | header->pa_lfr_pkt_nr_asm = 0x00; | |
794 | header->pa_lfr_asm_blk_nr[0] = 0x00; |
|
787 | header->pa_lfr_asm_blk_nr[0] = 0x00; | |
795 | header->pa_lfr_asm_blk_nr[1] = 0x00; |
|
788 | header->pa_lfr_asm_blk_nr[1] = 0x00; | |
796 | } |
|
789 | } | |
797 |
|
790 | |||
798 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, |
|
791 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, | |
799 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
792 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
800 | { |
|
793 | { | |
801 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
794 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
802 | * |
|
795 | * | |
803 | * @param waveform points to the buffer containing the data that will be send. |
|
796 | * @param waveform points to the buffer containing the data that will be send. | |
804 | * @param sid is the source identifier of the data that will be sent. |
|
797 | * @param sid is the source identifier of the data that will be sent. | |
805 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
798 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
806 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
799 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
807 | * contain information to setup the transmission of the data packets. |
|
800 | * contain information to setup the transmission of the data packets. | |
808 | * |
|
801 | * | |
809 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
802 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
810 | * |
|
803 | * | |
811 | */ |
|
804 | */ | |
812 |
|
805 | |||
813 | unsigned int i; |
|
806 | unsigned int i; | |
814 | int ret; |
|
807 | int ret; | |
815 | unsigned int coarseTime; |
|
808 | unsigned int coarseTime; | |
816 | unsigned int fineTime; |
|
809 | unsigned int fineTime; | |
817 | rtems_status_code status; |
|
810 | rtems_status_code status; | |
818 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
811 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
819 | int *dataPtr; |
|
812 | int *dataPtr; | |
820 | unsigned char sid; |
|
813 | unsigned char sid; | |
821 |
|
814 | |||
822 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
815 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
823 | spw_ioctl_send_CWF.options = 0; |
|
816 | spw_ioctl_send_CWF.options = 0; | |
824 |
|
817 | |||
825 | ret = LFR_DEFAULT; |
|
818 | ret = LFR_DEFAULT; | |
826 | sid = (unsigned char) ring_node_to_send->sid; |
|
819 | sid = (unsigned char) ring_node_to_send->sid; | |
827 |
|
820 | |||
828 | coarseTime = ring_node_to_send->coarseTime; |
|
821 | coarseTime = ring_node_to_send->coarseTime; | |
829 | fineTime = ring_node_to_send->fineTime; |
|
822 | fineTime = ring_node_to_send->fineTime; | |
830 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
823 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
831 |
|
824 | |||
832 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
825 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
833 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
826 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
834 | header->hkBIA = pa_bia_status_info; |
|
827 | header->hkBIA = pa_bia_status_info; | |
835 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
828 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
836 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
829 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
837 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
830 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
838 |
|
831 | |||
839 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
832 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |
840 | { |
|
833 | { | |
841 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
834 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; | |
842 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
835 | spw_ioctl_send_CWF.hdr = (char*) header; | |
843 | // BUILD THE DATA |
|
836 | // BUILD THE DATA | |
844 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
837 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
845 |
|
838 | |||
846 | // SET PACKET SEQUENCE CONTROL |
|
839 | // SET PACKET SEQUENCE CONTROL | |
847 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
840 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
848 |
|
841 | |||
849 | // SET SID |
|
842 | // SET SID | |
850 | header->sid = sid; |
|
843 | header->sid = sid; | |
851 |
|
844 | |||
852 | // SET PACKET TIME |
|
845 | // SET PACKET TIME | |
853 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); |
|
846 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); | |
854 | // |
|
847 | // | |
855 | header->time[0] = header->acquisitionTime[0]; |
|
848 | header->time[0] = header->acquisitionTime[0]; | |
856 | header->time[1] = header->acquisitionTime[1]; |
|
849 | header->time[1] = header->acquisitionTime[1]; | |
857 | header->time[2] = header->acquisitionTime[2]; |
|
850 | header->time[2] = header->acquisitionTime[2]; | |
858 | header->time[3] = header->acquisitionTime[3]; |
|
851 | header->time[3] = header->acquisitionTime[3]; | |
859 | header->time[4] = header->acquisitionTime[4]; |
|
852 | header->time[4] = header->acquisitionTime[4]; | |
860 | header->time[5] = header->acquisitionTime[5]; |
|
853 | header->time[5] = header->acquisitionTime[5]; | |
861 |
|
854 | |||
862 | // SET PACKET ID |
|
855 | // SET PACKET ID | |
863 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
856 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
864 | { |
|
857 | { | |
865 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
858 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); | |
866 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
859 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); | |
867 | } |
|
860 | } | |
868 | else |
|
861 | else | |
869 | { |
|
862 | { | |
870 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
863 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
871 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
864 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
872 | } |
|
865 | } | |
873 |
|
866 | |||
874 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
867 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
875 | if (status != RTEMS_SUCCESSFUL) { |
|
868 | if (status != RTEMS_SUCCESSFUL) { | |
876 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
|||
877 | ret = LFR_DEFAULT; |
|
869 | ret = LFR_DEFAULT; | |
878 | } |
|
870 | } | |
879 | } |
|
871 | } | |
880 |
|
872 | |||
881 | return ret; |
|
873 | return ret; | |
882 | } |
|
874 | } | |
883 |
|
875 | |||
884 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, |
|
876 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, | |
885 | Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
877 | Header_TM_LFR_SCIENCE_SWF_t *header ) | |
886 | { |
|
878 | { | |
887 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
879 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
888 | * |
|
880 | * | |
889 | * @param waveform points to the buffer containing the data that will be send. |
|
881 | * @param waveform points to the buffer containing the data that will be send. | |
890 | * @param sid is the source identifier of the data that will be sent. |
|
882 | * @param sid is the source identifier of the data that will be sent. | |
891 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
883 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
892 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
884 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
893 | * contain information to setup the transmission of the data packets. |
|
885 | * contain information to setup the transmission of the data packets. | |
894 | * |
|
886 | * | |
895 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
887 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
896 | * |
|
888 | * | |
897 | */ |
|
889 | */ | |
898 |
|
890 | |||
899 | unsigned int i; |
|
891 | unsigned int i; | |
900 | int ret; |
|
892 | int ret; | |
901 | unsigned int coarseTime; |
|
893 | unsigned int coarseTime; | |
902 | unsigned int fineTime; |
|
894 | unsigned int fineTime; | |
903 | rtems_status_code status; |
|
895 | rtems_status_code status; | |
904 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
896 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
905 | int *dataPtr; |
|
897 | int *dataPtr; | |
906 | unsigned char sid; |
|
898 | unsigned char sid; | |
907 |
|
899 | |||
908 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; |
|
900 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; | |
909 | spw_ioctl_send_SWF.options = 0; |
|
901 | spw_ioctl_send_SWF.options = 0; | |
910 |
|
902 | |||
911 | ret = LFR_DEFAULT; |
|
903 | ret = LFR_DEFAULT; | |
912 |
|
904 | |||
913 | coarseTime = ring_node_to_send->coarseTime; |
|
905 | coarseTime = ring_node_to_send->coarseTime; | |
914 | fineTime = ring_node_to_send->fineTime; |
|
906 | fineTime = ring_node_to_send->fineTime; | |
915 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
907 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
916 | sid = ring_node_to_send->sid; |
|
908 | sid = ring_node_to_send->sid; | |
917 |
|
909 | |||
918 | header->hkBIA = pa_bia_status_info; |
|
910 | header->hkBIA = pa_bia_status_info; | |
919 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
911 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
920 |
|
912 | |||
921 | for (i=0; i<7; i++) // send waveform |
|
913 | for (i=0; i<7; i++) // send waveform | |
922 | { |
|
914 | { | |
923 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
915 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; | |
924 | spw_ioctl_send_SWF.hdr = (char*) header; |
|
916 | spw_ioctl_send_SWF.hdr = (char*) header; | |
925 |
|
917 | |||
926 | // SET PACKET SEQUENCE CONTROL |
|
918 | // SET PACKET SEQUENCE CONTROL | |
927 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
919 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
928 |
|
920 | |||
929 | // SET PACKET LENGTH AND BLKNR |
|
921 | // SET PACKET LENGTH AND BLKNR | |
930 | if (i == 6) |
|
922 | if (i == 6) | |
931 | { |
|
923 | { | |
932 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
924 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
933 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
925 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
934 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
926 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
935 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
927 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
936 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
928 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
937 | } |
|
929 | } | |
938 | else |
|
930 | else | |
939 | { |
|
931 | { | |
940 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
932 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
941 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
933 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
942 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
934 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
943 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
935 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
944 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
936 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
945 | } |
|
937 | } | |
946 |
|
938 | |||
947 | // SET PACKET TIME |
|
939 | // SET PACKET TIME | |
948 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); |
|
940 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); | |
949 | // |
|
941 | // | |
950 | header->time[0] = header->acquisitionTime[0]; |
|
942 | header->time[0] = header->acquisitionTime[0]; | |
951 | header->time[1] = header->acquisitionTime[1]; |
|
943 | header->time[1] = header->acquisitionTime[1]; | |
952 | header->time[2] = header->acquisitionTime[2]; |
|
944 | header->time[2] = header->acquisitionTime[2]; | |
953 | header->time[3] = header->acquisitionTime[3]; |
|
945 | header->time[3] = header->acquisitionTime[3]; | |
954 | header->time[4] = header->acquisitionTime[4]; |
|
946 | header->time[4] = header->acquisitionTime[4]; | |
955 | header->time[5] = header->acquisitionTime[5]; |
|
947 | header->time[5] = header->acquisitionTime[5]; | |
956 |
|
948 | |||
957 | // SET SID |
|
949 | // SET SID | |
958 | header->sid = sid; |
|
950 | header->sid = sid; | |
959 |
|
951 | |||
960 | // SET PKTNR |
|
952 | // SET PKTNR | |
961 | header->pktNr = i+1; // PKT_NR |
|
953 | header->pktNr = i+1; // PKT_NR | |
962 |
|
954 | |||
963 | // SEND PACKET |
|
955 | // SEND PACKET | |
964 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); |
|
956 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); | |
965 | if (status != RTEMS_SUCCESSFUL) { |
|
957 | if (status != RTEMS_SUCCESSFUL) { | |
966 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
|||
967 | ret = LFR_DEFAULT; |
|
958 | ret = LFR_DEFAULT; | |
968 | } |
|
959 | } | |
969 | } |
|
960 | } | |
970 |
|
961 | |||
971 | return ret; |
|
962 | return ret; | |
972 | } |
|
963 | } | |
973 |
|
964 | |||
974 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, |
|
965 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, | |
975 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
966 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
976 | { |
|
967 | { | |
977 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
968 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
978 | * |
|
969 | * | |
979 | * @param waveform points to the buffer containing the data that will be send. |
|
970 | * @param waveform points to the buffer containing the data that will be send. | |
980 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
971 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
981 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
972 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
982 | * contain information to setup the transmission of the data packets. |
|
973 | * contain information to setup the transmission of the data packets. | |
983 | * |
|
974 | * | |
984 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
975 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
985 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
976 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
986 | * |
|
977 | * | |
987 | */ |
|
978 | */ | |
988 |
|
979 | |||
989 | unsigned int i; |
|
980 | unsigned int i; | |
990 | int ret; |
|
981 | int ret; | |
991 | unsigned int coarseTime; |
|
982 | unsigned int coarseTime; | |
992 | unsigned int fineTime; |
|
983 | unsigned int fineTime; | |
993 | rtems_status_code status; |
|
984 | rtems_status_code status; | |
994 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
985 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
995 | char *dataPtr; |
|
986 | char *dataPtr; | |
996 | unsigned char sid; |
|
987 | unsigned char sid; | |
997 |
|
988 | |||
998 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
989 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
999 | spw_ioctl_send_CWF.options = 0; |
|
990 | spw_ioctl_send_CWF.options = 0; | |
1000 |
|
991 | |||
1001 | ret = LFR_DEFAULT; |
|
992 | ret = LFR_DEFAULT; | |
1002 | sid = ring_node_to_send->sid; |
|
993 | sid = ring_node_to_send->sid; | |
1003 |
|
994 | |||
1004 | coarseTime = ring_node_to_send->coarseTime; |
|
995 | coarseTime = ring_node_to_send->coarseTime; | |
1005 | fineTime = ring_node_to_send->fineTime; |
|
996 | fineTime = ring_node_to_send->fineTime; | |
1006 | dataPtr = (char*) ring_node_to_send->buffer_address; |
|
997 | dataPtr = (char*) ring_node_to_send->buffer_address; | |
1007 |
|
998 | |||
1008 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
999 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
1009 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
1000 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
1010 | header->hkBIA = pa_bia_status_info; |
|
1001 | header->hkBIA = pa_bia_status_info; | |
1011 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1002 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1012 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
1003 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
1013 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
1004 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
1014 |
|
1005 | |||
1015 | //********************* |
|
1006 | //********************* | |
1016 | // SEND CWF3_light DATA |
|
1007 | // SEND CWF3_light DATA | |
1017 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
1008 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | |
1018 | { |
|
1009 | { | |
1019 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
1010 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
1020 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
1011 | spw_ioctl_send_CWF.hdr = (char*) header; | |
1021 | // BUILD THE DATA |
|
1012 | // BUILD THE DATA | |
1022 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
1013 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1023 |
|
1014 | |||
1024 | // SET PACKET SEQUENCE COUNTER |
|
1015 | // SET PACKET SEQUENCE COUNTER | |
1025 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1016 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1026 |
|
1017 | |||
1027 | // SET SID |
|
1018 | // SET SID | |
1028 | header->sid = sid; |
|
1019 | header->sid = sid; | |
1029 |
|
1020 | |||
1030 | // SET PACKET TIME |
|
1021 | // SET PACKET TIME | |
1031 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); |
|
1022 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); | |
1032 | // |
|
1023 | // | |
1033 | header->time[0] = header->acquisitionTime[0]; |
|
1024 | header->time[0] = header->acquisitionTime[0]; | |
1034 | header->time[1] = header->acquisitionTime[1]; |
|
1025 | header->time[1] = header->acquisitionTime[1]; | |
1035 | header->time[2] = header->acquisitionTime[2]; |
|
1026 | header->time[2] = header->acquisitionTime[2]; | |
1036 | header->time[3] = header->acquisitionTime[3]; |
|
1027 | header->time[3] = header->acquisitionTime[3]; | |
1037 | header->time[4] = header->acquisitionTime[4]; |
|
1028 | header->time[4] = header->acquisitionTime[4]; | |
1038 | header->time[5] = header->acquisitionTime[5]; |
|
1029 | header->time[5] = header->acquisitionTime[5]; | |
1039 |
|
1030 | |||
1040 | // SET PACKET ID |
|
1031 | // SET PACKET ID | |
1041 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
1032 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
1042 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
1033 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
1043 |
|
1034 | |||
1044 | // SEND PACKET |
|
1035 | // SEND PACKET | |
1045 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
1036 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
1046 | if (status != RTEMS_SUCCESSFUL) { |
|
1037 | if (status != RTEMS_SUCCESSFUL) { | |
1047 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
|||
1048 | ret = LFR_DEFAULT; |
|
1038 | ret = LFR_DEFAULT; | |
1049 | } |
|
1039 | } | |
1050 | } |
|
1040 | } | |
1051 |
|
1041 | |||
1052 | return ret; |
|
1042 | return ret; | |
1053 | } |
|
1043 | } | |
1054 |
|
1044 | |||
1055 | void spw_send_asm_f0( ring_node *ring_node_to_send, |
|
1045 | void spw_send_asm_f0( ring_node *ring_node_to_send, | |
1056 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1046 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1057 | { |
|
1047 | { | |
1058 | unsigned int i; |
|
1048 | unsigned int i; | |
1059 | unsigned int length = 0; |
|
1049 | unsigned int length = 0; | |
1060 | rtems_status_code status; |
|
1050 | rtems_status_code status; | |
1061 | unsigned int sid; |
|
1051 | unsigned int sid; | |
1062 | float *spectral_matrix; |
|
1052 | float *spectral_matrix; | |
1063 | int coarseTime; |
|
1053 | int coarseTime; | |
1064 | int fineTime; |
|
1054 | int fineTime; | |
1065 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1055 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1066 |
|
1056 | |||
1067 | sid = ring_node_to_send->sid; |
|
1057 | sid = ring_node_to_send->sid; | |
1068 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1058 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1069 | coarseTime = ring_node_to_send->coarseTime; |
|
1059 | coarseTime = ring_node_to_send->coarseTime; | |
1070 | fineTime = ring_node_to_send->fineTime; |
|
1060 | fineTime = ring_node_to_send->fineTime; | |
1071 |
|
1061 | |||
1072 | header->biaStatusInfo = pa_bia_status_info; |
|
1062 | header->biaStatusInfo = pa_bia_status_info; | |
1073 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1063 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1074 |
|
1064 | |||
1075 | for (i=0; i<3; i++) |
|
1065 | for (i=0; i<3; i++) | |
1076 | { |
|
1066 | { | |
1077 | if ((i==0) || (i==1)) |
|
1067 | if ((i==0) || (i==1)) | |
1078 | { |
|
1068 | { | |
1079 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; |
|
1069 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; | |
1080 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1070 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1081 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1071 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1082 | ]; |
|
1072 | ]; | |
1083 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; |
|
1073 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; | |
1084 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1074 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1085 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB |
|
1075 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB | |
1086 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB |
|
1076 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB | |
1087 | } |
|
1077 | } | |
1088 | else |
|
1078 | else | |
1089 | { |
|
1079 | { | |
1090 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; |
|
1080 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; | |
1091 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1081 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1092 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1082 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1093 | ]; |
|
1083 | ]; | |
1094 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; |
|
1084 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; | |
1095 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1085 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1096 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB |
|
1086 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB | |
1097 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB |
|
1087 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB | |
1098 | } |
|
1088 | } | |
1099 |
|
1089 | |||
1100 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1090 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1101 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1091 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1102 | spw_ioctl_send_ASM.options = 0; |
|
1092 | spw_ioctl_send_ASM.options = 0; | |
1103 |
|
1093 | |||
1104 | // (2) BUILD THE HEADER |
|
1094 | // (2) BUILD THE HEADER | |
1105 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1095 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1106 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1096 | header->packetLength[0] = (unsigned char) (length>>8); | |
1107 | header->packetLength[1] = (unsigned char) (length); |
|
1097 | header->packetLength[1] = (unsigned char) (length); | |
1108 | header->sid = (unsigned char) sid; // SID |
|
1098 | header->sid = (unsigned char) sid; // SID | |
1109 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1099 | header->pa_lfr_pkt_cnt_asm = 3; | |
1110 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1100 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1111 |
|
1101 | |||
1112 | // (3) SET PACKET TIME |
|
1102 | // (3) SET PACKET TIME | |
1113 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1103 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1114 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1104 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1115 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1105 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1116 | header->time[3] = (unsigned char) (coarseTime); |
|
1106 | header->time[3] = (unsigned char) (coarseTime); | |
1117 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1107 | header->time[4] = (unsigned char) (fineTime>>8); | |
1118 | header->time[5] = (unsigned char) (fineTime); |
|
1108 | header->time[5] = (unsigned char) (fineTime); | |
1119 | // |
|
1109 | // | |
1120 | header->acquisitionTime[0] = header->time[0]; |
|
1110 | header->acquisitionTime[0] = header->time[0]; | |
1121 | header->acquisitionTime[1] = header->time[1]; |
|
1111 | header->acquisitionTime[1] = header->time[1]; | |
1122 | header->acquisitionTime[2] = header->time[2]; |
|
1112 | header->acquisitionTime[2] = header->time[2]; | |
1123 | header->acquisitionTime[3] = header->time[3]; |
|
1113 | header->acquisitionTime[3] = header->time[3]; | |
1124 | header->acquisitionTime[4] = header->time[4]; |
|
1114 | header->acquisitionTime[4] = header->time[4]; | |
1125 | header->acquisitionTime[5] = header->time[5]; |
|
1115 | header->acquisitionTime[5] = header->time[5]; | |
1126 |
|
1116 | |||
1127 | // (4) SEND PACKET |
|
1117 | // (4) SEND PACKET | |
1128 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1118 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1129 | if (status != RTEMS_SUCCESSFUL) { |
|
1119 | if (status != RTEMS_SUCCESSFUL) { | |
1130 |
|
|
1120 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1131 | } |
|
1121 | } | |
1132 | } |
|
1122 | } | |
1133 | } |
|
1123 | } | |
1134 |
|
1124 | |||
1135 | void spw_send_asm_f1( ring_node *ring_node_to_send, |
|
1125 | void spw_send_asm_f1( ring_node *ring_node_to_send, | |
1136 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1126 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1137 | { |
|
1127 | { | |
1138 | unsigned int i; |
|
1128 | unsigned int i; | |
1139 | unsigned int length = 0; |
|
1129 | unsigned int length = 0; | |
1140 | rtems_status_code status; |
|
1130 | rtems_status_code status; | |
1141 | unsigned int sid; |
|
1131 | unsigned int sid; | |
1142 | float *spectral_matrix; |
|
1132 | float *spectral_matrix; | |
1143 | int coarseTime; |
|
1133 | int coarseTime; | |
1144 | int fineTime; |
|
1134 | int fineTime; | |
1145 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1135 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1146 |
|
1136 | |||
1147 | sid = ring_node_to_send->sid; |
|
1137 | sid = ring_node_to_send->sid; | |
1148 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1138 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1149 | coarseTime = ring_node_to_send->coarseTime; |
|
1139 | coarseTime = ring_node_to_send->coarseTime; | |
1150 | fineTime = ring_node_to_send->fineTime; |
|
1140 | fineTime = ring_node_to_send->fineTime; | |
1151 |
|
1141 | |||
1152 | header->biaStatusInfo = pa_bia_status_info; |
|
1142 | header->biaStatusInfo = pa_bia_status_info; | |
1153 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1143 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1154 |
|
1144 | |||
1155 | for (i=0; i<3; i++) |
|
1145 | for (i=0; i<3; i++) | |
1156 | { |
|
1146 | { | |
1157 | if ((i==0) || (i==1)) |
|
1147 | if ((i==0) || (i==1)) | |
1158 | { |
|
1148 | { | |
1159 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; |
|
1149 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; | |
1160 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1150 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1161 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1151 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1162 | ]; |
|
1152 | ]; | |
1163 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; |
|
1153 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; | |
1164 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1154 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1165 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB |
|
1155 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB | |
1166 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB |
|
1156 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB | |
1167 | } |
|
1157 | } | |
1168 | else |
|
1158 | else | |
1169 | { |
|
1159 | { | |
1170 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; |
|
1160 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; | |
1171 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1161 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1172 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1162 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1173 | ]; |
|
1163 | ]; | |
1174 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; |
|
1164 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; | |
1175 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1165 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1176 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB |
|
1166 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB | |
1177 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB |
|
1167 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB | |
1178 | } |
|
1168 | } | |
1179 |
|
1169 | |||
1180 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1170 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1181 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1171 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1182 | spw_ioctl_send_ASM.options = 0; |
|
1172 | spw_ioctl_send_ASM.options = 0; | |
1183 |
|
1173 | |||
1184 | // (2) BUILD THE HEADER |
|
1174 | // (2) BUILD THE HEADER | |
1185 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1175 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1186 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1176 | header->packetLength[0] = (unsigned char) (length>>8); | |
1187 | header->packetLength[1] = (unsigned char) (length); |
|
1177 | header->packetLength[1] = (unsigned char) (length); | |
1188 | header->sid = (unsigned char) sid; // SID |
|
1178 | header->sid = (unsigned char) sid; // SID | |
1189 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1179 | header->pa_lfr_pkt_cnt_asm = 3; | |
1190 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1180 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1191 |
|
1181 | |||
1192 | // (3) SET PACKET TIME |
|
1182 | // (3) SET PACKET TIME | |
1193 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1183 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1194 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1184 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1195 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1185 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1196 | header->time[3] = (unsigned char) (coarseTime); |
|
1186 | header->time[3] = (unsigned char) (coarseTime); | |
1197 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1187 | header->time[4] = (unsigned char) (fineTime>>8); | |
1198 | header->time[5] = (unsigned char) (fineTime); |
|
1188 | header->time[5] = (unsigned char) (fineTime); | |
1199 | // |
|
1189 | // | |
1200 | header->acquisitionTime[0] = header->time[0]; |
|
1190 | header->acquisitionTime[0] = header->time[0]; | |
1201 | header->acquisitionTime[1] = header->time[1]; |
|
1191 | header->acquisitionTime[1] = header->time[1]; | |
1202 | header->acquisitionTime[2] = header->time[2]; |
|
1192 | header->acquisitionTime[2] = header->time[2]; | |
1203 | header->acquisitionTime[3] = header->time[3]; |
|
1193 | header->acquisitionTime[3] = header->time[3]; | |
1204 | header->acquisitionTime[4] = header->time[4]; |
|
1194 | header->acquisitionTime[4] = header->time[4]; | |
1205 | header->acquisitionTime[5] = header->time[5]; |
|
1195 | header->acquisitionTime[5] = header->time[5]; | |
1206 |
|
1196 | |||
1207 | // (4) SEND PACKET |
|
1197 | // (4) SEND PACKET | |
1208 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1198 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1209 | if (status != RTEMS_SUCCESSFUL) { |
|
1199 | if (status != RTEMS_SUCCESSFUL) { | |
1210 |
|
|
1200 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1211 | } |
|
1201 | } | |
1212 | } |
|
1202 | } | |
1213 | } |
|
1203 | } | |
1214 |
|
1204 | |||
1215 | void spw_send_asm_f2( ring_node *ring_node_to_send, |
|
1205 | void spw_send_asm_f2( ring_node *ring_node_to_send, | |
1216 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1206 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1217 | { |
|
1207 | { | |
1218 | unsigned int i; |
|
1208 | unsigned int i; | |
1219 | unsigned int length = 0; |
|
1209 | unsigned int length = 0; | |
1220 | rtems_status_code status; |
|
1210 | rtems_status_code status; | |
1221 | unsigned int sid; |
|
1211 | unsigned int sid; | |
1222 | float *spectral_matrix; |
|
1212 | float *spectral_matrix; | |
1223 | int coarseTime; |
|
1213 | int coarseTime; | |
1224 | int fineTime; |
|
1214 | int fineTime; | |
1225 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1215 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1226 |
|
1216 | |||
1227 | sid = ring_node_to_send->sid; |
|
1217 | sid = ring_node_to_send->sid; | |
1228 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1218 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1229 | coarseTime = ring_node_to_send->coarseTime; |
|
1219 | coarseTime = ring_node_to_send->coarseTime; | |
1230 | fineTime = ring_node_to_send->fineTime; |
|
1220 | fineTime = ring_node_to_send->fineTime; | |
1231 |
|
1221 | |||
1232 | header->biaStatusInfo = pa_bia_status_info; |
|
1222 | header->biaStatusInfo = pa_bia_status_info; | |
1233 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1223 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1234 |
|
1224 | |||
1235 | for (i=0; i<3; i++) |
|
1225 | for (i=0; i<3; i++) | |
1236 | { |
|
1226 | { | |
1237 |
|
1227 | |||
1238 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; |
|
1228 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; | |
1239 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1229 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1240 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) |
|
1230 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) | |
1241 | ]; |
|
1231 | ]; | |
1242 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
1232 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; | |
1243 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; |
|
1233 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; | |
1244 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
1234 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB | |
1245 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
1235 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB | |
1246 |
|
1236 | |||
1247 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1237 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1248 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1238 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1249 | spw_ioctl_send_ASM.options = 0; |
|
1239 | spw_ioctl_send_ASM.options = 0; | |
1250 |
|
1240 | |||
1251 | // (2) BUILD THE HEADER |
|
1241 | // (2) BUILD THE HEADER | |
1252 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1242 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1253 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1243 | header->packetLength[0] = (unsigned char) (length>>8); | |
1254 | header->packetLength[1] = (unsigned char) (length); |
|
1244 | header->packetLength[1] = (unsigned char) (length); | |
1255 | header->sid = (unsigned char) sid; // SID |
|
1245 | header->sid = (unsigned char) sid; // SID | |
1256 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1246 | header->pa_lfr_pkt_cnt_asm = 3; | |
1257 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1247 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1258 |
|
1248 | |||
1259 | // (3) SET PACKET TIME |
|
1249 | // (3) SET PACKET TIME | |
1260 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1250 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1261 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1251 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1262 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1252 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1263 | header->time[3] = (unsigned char) (coarseTime); |
|
1253 | header->time[3] = (unsigned char) (coarseTime); | |
1264 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1254 | header->time[4] = (unsigned char) (fineTime>>8); | |
1265 | header->time[5] = (unsigned char) (fineTime); |
|
1255 | header->time[5] = (unsigned char) (fineTime); | |
1266 | // |
|
1256 | // | |
1267 | header->acquisitionTime[0] = header->time[0]; |
|
1257 | header->acquisitionTime[0] = header->time[0]; | |
1268 | header->acquisitionTime[1] = header->time[1]; |
|
1258 | header->acquisitionTime[1] = header->time[1]; | |
1269 | header->acquisitionTime[2] = header->time[2]; |
|
1259 | header->acquisitionTime[2] = header->time[2]; | |
1270 | header->acquisitionTime[3] = header->time[3]; |
|
1260 | header->acquisitionTime[3] = header->time[3]; | |
1271 | header->acquisitionTime[4] = header->time[4]; |
|
1261 | header->acquisitionTime[4] = header->time[4]; | |
1272 | header->acquisitionTime[5] = header->time[5]; |
|
1262 | header->acquisitionTime[5] = header->time[5]; | |
1273 |
|
1263 | |||
1274 | // (4) SEND PACKET |
|
1264 | // (4) SEND PACKET | |
1275 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1265 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1276 | if (status != RTEMS_SUCCESSFUL) { |
|
1266 | if (status != RTEMS_SUCCESSFUL) { | |
1277 |
|
|
1267 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1278 | } |
|
1268 | } | |
1279 | } |
|
1269 | } | |
1280 | } |
|
1270 | } | |
1281 |
|
1271 | |||
1282 | void spw_send_k_dump( ring_node *ring_node_to_send ) |
|
1272 | void spw_send_k_dump( ring_node *ring_node_to_send ) | |
1283 | { |
|
1273 | { | |
1284 | rtems_status_code status; |
|
1274 | rtems_status_code status; | |
1285 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; |
|
1275 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; | |
1286 | unsigned int packetLength; |
|
1276 | unsigned int packetLength; | |
1287 | unsigned int size; |
|
1277 | unsigned int size; | |
1288 |
|
1278 | |||
1289 |
|
|
1279 | PRINTF("spw_send_k_dump\n") | |
1290 |
|
1280 | |||
1291 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; |
|
1281 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; | |
1292 |
|
1282 | |||
1293 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; |
|
1283 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; | |
1294 |
|
1284 | |||
1295 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
1285 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
1296 |
|
1286 | |||
1297 |
|
|
1287 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) | |
1298 |
|
1288 | |||
1299 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); |
|
1289 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); | |
1300 |
|
1290 | |||
1301 | if (status == -1){ |
|
1291 | if (status == -1){ | |
1302 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
1292 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
1303 | } |
|
1293 | } | |
1304 |
|
1294 | |||
1305 | ring_node_to_send->status = 0x00; |
|
1295 | ring_node_to_send->status = 0x00; | |
1306 | } |
|
1296 | } |
@@ -1,404 +1,404 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "avf0_prc0.h" |
|
10 | #include "avf0_prc0.h" | |
11 | #include "fsw_processing.h" |
|
11 | #include "fsw_processing.h" | |
12 |
|
12 | |||
13 | nb_sm_before_bp_asm_f0 nb_sm_before_f0; |
|
13 | nb_sm_before_bp_asm_f0 nb_sm_before_f0; | |
14 |
|
14 | |||
15 | //*** |
|
15 | //*** | |
16 | // F0 |
|
16 | // F0 | |
17 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; |
|
17 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; | |
18 | ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; |
|
18 | ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; | |
19 |
|
19 | |||
20 | ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; |
|
20 | ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ]; | |
21 | int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; |
|
21 | int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ]; | |
22 |
|
22 | |||
23 | float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; |
|
23 | float asm_f0_patched_norm [ TOTAL_SIZE_SM ]; | |
24 | float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ]; | |
25 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; |
|
25 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; | |
26 |
|
26 | |||
27 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; |
|
27 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; | |
28 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; |
|
28 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; | |
29 | float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; |
|
29 | float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; | |
30 |
|
30 | |||
31 | float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352 |
|
31 | float k_coeff_intercalib_f0_norm[ NB_BINS_COMPRESSED_SM_F0 * NB_K_COEFF_PER_BIN ]; // 11 * 32 = 352 | |
32 | float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704 |
|
32 | float k_coeff_intercalib_f0_sbm[ NB_BINS_COMPRESSED_SM_SBM_F0 * NB_K_COEFF_PER_BIN ]; // 22 * 32 = 704 | |
33 |
|
33 | |||
34 | //************ |
|
34 | //************ | |
35 | // RTEMS TASKS |
|
35 | // RTEMS TASKS | |
36 |
|
36 | |||
37 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) |
|
37 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) | |
38 | { |
|
38 | { | |
39 | int i; |
|
39 | int i; | |
40 |
|
40 | |||
41 | rtems_event_set event_out; |
|
41 | rtems_event_set event_out; | |
42 | rtems_status_code status; |
|
42 | rtems_status_code status; | |
43 | rtems_id queue_id_prc0; |
|
43 | rtems_id queue_id_prc0; | |
44 | asm_msg msgForMATR; |
|
44 | asm_msg msgForMATR; | |
45 | ring_node *nodeForAveraging; |
|
45 | ring_node *nodeForAveraging; | |
46 | ring_node *ring_node_tab[8]; |
|
46 | ring_node *ring_node_tab[8]; | |
47 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; |
|
47 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; | |
48 | ring_node_asm *current_ring_node_asm_norm_f0; |
|
48 | ring_node_asm *current_ring_node_asm_norm_f0; | |
49 |
|
49 | |||
50 | unsigned int nb_norm_bp1; |
|
50 | unsigned int nb_norm_bp1; | |
51 | unsigned int nb_norm_bp2; |
|
51 | unsigned int nb_norm_bp2; | |
52 | unsigned int nb_norm_asm; |
|
52 | unsigned int nb_norm_asm; | |
53 | unsigned int nb_sbm_bp1; |
|
53 | unsigned int nb_sbm_bp1; | |
54 | unsigned int nb_sbm_bp2; |
|
54 | unsigned int nb_sbm_bp2; | |
55 |
|
55 | |||
56 | nb_norm_bp1 = 0; |
|
56 | nb_norm_bp1 = 0; | |
57 | nb_norm_bp2 = 0; |
|
57 | nb_norm_bp2 = 0; | |
58 | nb_norm_asm = 0; |
|
58 | nb_norm_asm = 0; | |
59 | nb_sbm_bp1 = 0; |
|
59 | nb_sbm_bp1 = 0; | |
60 | nb_sbm_bp2 = 0; |
|
60 | nb_sbm_bp2 = 0; | |
61 |
|
61 | |||
62 | reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
62 | reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
63 | ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); |
|
63 | ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); | |
64 | ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); |
|
64 | ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); | |
65 | current_ring_node_asm_norm_f0 = asm_ring_norm_f0; |
|
65 | current_ring_node_asm_norm_f0 = asm_ring_norm_f0; | |
66 | current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; |
|
66 | current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; | |
67 |
|
67 | |||
68 | BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
68 | BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
69 |
|
69 | |||
70 | status = get_message_queue_id_prc0( &queue_id_prc0 ); |
|
70 | status = get_message_queue_id_prc0( &queue_id_prc0 ); | |
71 | if (status != RTEMS_SUCCESSFUL) |
|
71 | if (status != RTEMS_SUCCESSFUL) | |
72 | { |
|
72 | { | |
73 | PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) |
|
73 | PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | while(1){ |
|
76 | while(1){ | |
77 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
77 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
78 |
|
78 | |||
79 | //**************************************** |
|
79 | //**************************************** | |
80 | // initialize the mesage for the MATR task |
|
80 | // initialize the mesage for the MATR task | |
81 | msgForMATR.norm = current_ring_node_asm_norm_f0; |
|
81 | msgForMATR.norm = current_ring_node_asm_norm_f0; | |
82 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; |
|
82 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; | |
83 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task |
|
83 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC0 task | |
84 | // |
|
84 | // | |
85 | //**************************************** |
|
85 | //**************************************** | |
86 |
|
86 | |||
87 | nodeForAveraging = getRingNodeForAveraging( 0 ); |
|
87 | nodeForAveraging = getRingNodeForAveraging( 0 ); | |
88 |
|
88 | |||
89 | ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging; |
|
89 | ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging; | |
90 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) |
|
90 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) | |
91 | { |
|
91 | { | |
92 | nodeForAveraging = nodeForAveraging->previous; |
|
92 | nodeForAveraging = nodeForAveraging->previous; | |
93 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging; |
|
93 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | // compute the average and store it in the averaged_sm_f1 buffer |
|
96 | // compute the average and store it in the averaged_sm_f1 buffer | |
97 | SM_average( current_ring_node_asm_norm_f0->matrix, |
|
97 | SM_average( current_ring_node_asm_norm_f0->matrix, | |
98 | current_ring_node_asm_burst_sbm_f0->matrix, |
|
98 | current_ring_node_asm_burst_sbm_f0->matrix, | |
99 | ring_node_tab, |
|
99 | ring_node_tab, | |
100 | nb_norm_bp1, nb_sbm_bp1, |
|
100 | nb_norm_bp1, nb_sbm_bp1, | |
101 | &msgForMATR ); |
|
101 | &msgForMATR ); | |
102 |
|
102 | |||
103 | // update nb_average |
|
103 | // update nb_average | |
104 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; |
|
104 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; | |
105 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; |
|
105 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; | |
106 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; |
|
106 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; | |
107 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; |
|
107 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; | |
108 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; |
|
108 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; | |
109 |
|
109 | |||
110 | if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) |
|
110 | if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) | |
111 | { |
|
111 | { | |
112 | nb_sbm_bp1 = 0; |
|
112 | nb_sbm_bp1 = 0; | |
113 | // set another ring for the ASM storage |
|
113 | // set another ring for the ASM storage | |
114 | current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; |
|
114 | current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; | |
115 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
115 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
116 | { |
|
116 | { | |
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0; |
|
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0; | |
118 | } |
|
118 | } | |
119 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
119 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
120 | { |
|
120 | { | |
121 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0; |
|
121 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0; | |
122 | } |
|
122 | } | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) |
|
125 | if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) | |
126 | { |
|
126 | { | |
127 | nb_sbm_bp2 = 0; |
|
127 | nb_sbm_bp2 = 0; | |
128 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
128 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
129 | { |
|
129 | { | |
130 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0; |
|
130 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0; | |
131 | } |
|
131 | } | |
132 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
132 | else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
133 | { |
|
133 | { | |
134 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0; |
|
134 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0; | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) |
|
138 | if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) | |
139 | { |
|
139 | { | |
140 | nb_norm_bp1 = 0; |
|
140 | nb_norm_bp1 = 0; | |
141 | // set another ring for the ASM storage |
|
141 | // set another ring for the ASM storage | |
142 | current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; |
|
142 | current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; | |
143 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
143 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
144 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
144 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
145 | { |
|
145 | { | |
146 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; |
|
146 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; | |
147 | } |
|
147 | } | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) |
|
150 | if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) | |
151 | { |
|
151 | { | |
152 | nb_norm_bp2 = 0; |
|
152 | nb_norm_bp2 = 0; | |
153 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
153 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
154 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
154 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
155 | { |
|
155 | { | |
156 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; |
|
156 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; | |
157 | } |
|
157 | } | |
158 | } |
|
158 | } | |
159 |
|
159 | |||
160 | if (nb_norm_asm == nb_sm_before_f0.norm_asm) |
|
160 | if (nb_norm_asm == nb_sm_before_f0.norm_asm) | |
161 | { |
|
161 | { | |
162 | nb_norm_asm = 0; |
|
162 | nb_norm_asm = 0; | |
163 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
163 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
164 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
164 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
165 | { |
|
165 | { | |
166 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; |
|
166 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; | |
167 | } |
|
167 | } | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | //************************* |
|
170 | //************************* | |
171 | // send the message to MATR |
|
171 | // send the message to MATR | |
172 | if (msgForMATR.event != 0x00) |
|
172 | if (msgForMATR.event != 0x00) | |
173 | { |
|
173 | { | |
174 | status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); |
|
174 | status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | if (status != RTEMS_SUCCESSFUL) { |
|
177 | if (status != RTEMS_SUCCESSFUL) { | |
178 |
|
|
178 | PRINTF1("in AVF0 *** Error sending message to MATR, code %d\n", status) | |
179 | } |
|
179 | } | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) |
|
183 | rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) | |
184 | { |
|
184 | { | |
185 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
185 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
186 | size_t size; // size of the incoming TC packet |
|
186 | size_t size; // size of the incoming TC packet | |
187 | asm_msg *incomingMsg; |
|
187 | asm_msg *incomingMsg; | |
188 | // |
|
188 | // | |
189 | unsigned char sid; |
|
189 | unsigned char sid; | |
190 | rtems_status_code status; |
|
190 | rtems_status_code status; | |
191 | rtems_id queue_id; |
|
191 | rtems_id queue_id; | |
192 | rtems_id queue_id_q_p0; |
|
192 | rtems_id queue_id_q_p0; | |
193 | bp_packet_with_spare packet_norm_bp1; |
|
193 | bp_packet_with_spare packet_norm_bp1; | |
194 | bp_packet packet_norm_bp2; |
|
194 | bp_packet packet_norm_bp2; | |
195 | bp_packet packet_sbm_bp1; |
|
195 | bp_packet packet_sbm_bp1; | |
196 | bp_packet packet_sbm_bp2; |
|
196 | bp_packet packet_sbm_bp2; | |
197 | ring_node *current_ring_node_to_send_asm_f0; |
|
197 | ring_node *current_ring_node_to_send_asm_f0; | |
198 |
|
198 | |||
199 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
199 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
200 | init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); |
|
200 | init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM ); | |
201 | current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; |
|
201 | current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0; | |
202 |
|
202 | |||
203 | //************* |
|
203 | //************* | |
204 | // NORM headers |
|
204 | // NORM headers | |
205 | BP_init_header_with_spare( &packet_norm_bp1, |
|
205 | BP_init_header_with_spare( &packet_norm_bp1, | |
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, |
|
206 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, | |
207 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); |
|
207 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); | |
208 | BP_init_header( &packet_norm_bp2, |
|
208 | BP_init_header( &packet_norm_bp2, | |
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, |
|
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, | |
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); |
|
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); | |
211 |
|
211 | |||
212 | //**************************** |
|
212 | //**************************** | |
213 | // BURST SBM1 and SBM2 headers |
|
213 | // BURST SBM1 and SBM2 headers | |
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) |
|
214 | if ( lfrRequestedMode == LFR_MODE_BURST ) | |
215 | { |
|
215 | { | |
216 | BP_init_header( &packet_sbm_bp1, |
|
216 | BP_init_header( &packet_sbm_bp1, | |
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, |
|
217 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, | |
218 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
218 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
219 | BP_init_header( &packet_sbm_bp2, |
|
219 | BP_init_header( &packet_sbm_bp2, | |
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, |
|
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, | |
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
222 | } |
|
222 | } | |
223 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) |
|
223 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) | |
224 | { |
|
224 | { | |
225 | BP_init_header( &packet_sbm_bp1, |
|
225 | BP_init_header( &packet_sbm_bp1, | |
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, |
|
226 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, | |
227 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
227 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
228 | BP_init_header( &packet_sbm_bp2, |
|
228 | BP_init_header( &packet_sbm_bp2, | |
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, |
|
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, | |
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
231 | } |
|
231 | } | |
232 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
232 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) | |
233 | { |
|
233 | { | |
234 | BP_init_header( &packet_sbm_bp1, |
|
234 | BP_init_header( &packet_sbm_bp1, | |
235 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, |
|
235 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, | |
236 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
236 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
237 | BP_init_header( &packet_sbm_bp2, |
|
237 | BP_init_header( &packet_sbm_bp2, | |
238 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, |
|
238 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, | |
239 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
239 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); | |
240 | } |
|
240 | } | |
241 | else |
|
241 | else | |
242 | { |
|
242 | { | |
243 | PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) |
|
243 | PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 | status = get_message_queue_id_send( &queue_id ); |
|
246 | status = get_message_queue_id_send( &queue_id ); | |
247 | if (status != RTEMS_SUCCESSFUL) |
|
247 | if (status != RTEMS_SUCCESSFUL) | |
248 | { |
|
248 | { | |
249 | PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) |
|
249 | PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) | |
250 | } |
|
250 | } | |
251 | status = get_message_queue_id_prc0( &queue_id_q_p0); |
|
251 | status = get_message_queue_id_prc0( &queue_id_q_p0); | |
252 | if (status != RTEMS_SUCCESSFUL) |
|
252 | if (status != RTEMS_SUCCESSFUL) | |
253 | { |
|
253 | { | |
254 | PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) |
|
254 | PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) | |
255 | } |
|
255 | } | |
256 |
|
256 | |||
257 | BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
257 | BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
258 |
|
258 | |||
259 | while(1){ |
|
259 | while(1){ | |
260 | status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ |
|
260 | status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ | |
261 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
|
261 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 | |
262 |
|
262 | |||
263 | incomingMsg = (asm_msg*) incomingData; |
|
263 | incomingMsg = (asm_msg*) incomingData; | |
264 |
|
264 | |||
265 | ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); |
|
265 | ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm ); | |
266 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); |
|
266 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm ); | |
267 |
|
267 | |||
268 | //**************** |
|
268 | //**************** | |
269 | //**************** |
|
269 | //**************** | |
270 | // BURST SBM1 SBM2 |
|
270 | // BURST SBM1 SBM2 | |
271 | //**************** |
|
271 | //**************** | |
272 | //**************** |
|
272 | //**************** | |
273 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) |
|
273 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) ) | |
274 | { |
|
274 | { | |
275 | sid = getSID( incomingMsg->event ); |
|
275 | sid = getSID( incomingMsg->event ); | |
276 | // 1) compress the matrix for Basic Parameters calculation |
|
276 | // 1) compress the matrix for Basic Parameters calculation | |
277 | ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, |
|
277 | ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0, | |
278 | nb_sm_before_f0.burst_sbm_bp1, |
|
278 | nb_sm_before_f0.burst_sbm_bp1, | |
279 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, |
|
279 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, | |
280 | ASM_F0_INDICE_START); |
|
280 | ASM_F0_INDICE_START); | |
281 | // 2) compute the BP1 set |
|
281 | // 2) compute the BP1 set | |
282 | BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); |
|
282 | BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data ); | |
283 | // 3) send the BP1 set |
|
283 | // 3) send the BP1 set | |
284 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
284 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
285 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
285 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
286 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
286 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
287 | BP_send( (char *) &packet_sbm_bp1, queue_id, |
|
287 | BP_send( (char *) &packet_sbm_bp1, queue_id, | |
288 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, |
|
288 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA, | |
289 | sid); |
|
289 | sid); | |
290 | // 4) compute the BP2 set if needed |
|
290 | // 4) compute the BP2 set if needed | |
291 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) |
|
291 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) ) | |
292 | { |
|
292 | { | |
293 | // 1) compute the BP2 set |
|
293 | // 1) compute the BP2 set | |
294 | BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); |
|
294 | BP2_set( compressed_sm_sbm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp2.data ); | |
295 | // 2) send the BP2 set |
|
295 | // 2) send the BP2 set | |
296 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
296 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
297 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
297 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
298 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
298 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
299 | BP_send( (char *) &packet_sbm_bp2, queue_id, |
|
299 | BP_send( (char *) &packet_sbm_bp2, queue_id, | |
300 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, |
|
300 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA, | |
301 | sid); |
|
301 | sid); | |
302 | } |
|
302 | } | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | //***** |
|
305 | //***** | |
306 | //***** |
|
306 | //***** | |
307 | // NORM |
|
307 | // NORM | |
308 | //***** |
|
308 | //***** | |
309 | //***** |
|
309 | //***** | |
310 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) |
|
310 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) | |
311 | { |
|
311 | { | |
312 | // 1) compress the matrix for Basic Parameters calculation |
|
312 | // 1) compress the matrix for Basic Parameters calculation | |
313 | ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, |
|
313 | ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0, | |
314 | nb_sm_before_f0.norm_bp1, |
|
314 | nb_sm_before_f0.norm_bp1, | |
315 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, |
|
315 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, | |
316 | ASM_F0_INDICE_START ); |
|
316 | ASM_F0_INDICE_START ); | |
317 | // 2) compute the BP1 set |
|
317 | // 2) compute the BP1 set | |
318 | BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); |
|
318 | BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data ); | |
319 | // 3) send the BP1 set |
|
319 | // 3) send the BP1 set | |
320 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
320 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
321 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
321 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
322 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
322 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
323 | BP_send( (char *) &packet_norm_bp1, queue_id, |
|
323 | BP_send( (char *) &packet_norm_bp1, queue_id, | |
324 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, |
|
324 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA, | |
325 | SID_NORM_BP1_F0 ); |
|
325 | SID_NORM_BP1_F0 ); | |
326 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) |
|
326 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) | |
327 | { |
|
327 | { | |
328 | // 1) compute the BP2 set using the same ASM as the one used for BP1 |
|
328 | // 1) compute the BP2 set using the same ASM as the one used for BP1 | |
329 | BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); |
|
329 | BP2_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp2.data ); | |
330 | // 2) send the BP2 set |
|
330 | // 2) send the BP2 set | |
331 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
331 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
332 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
332 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
333 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
333 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
334 | BP_send( (char *) &packet_norm_bp2, queue_id, |
|
334 | BP_send( (char *) &packet_norm_bp2, queue_id, | |
335 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, |
|
335 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA, | |
336 | SID_NORM_BP2_F0); |
|
336 | SID_NORM_BP2_F0); | |
337 | } |
|
337 | } | |
338 | } |
|
338 | } | |
339 |
|
339 | |||
340 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) |
|
340 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) | |
341 | { |
|
341 | { | |
342 | // 1) reorganize the ASM and divide |
|
342 | // 1) reorganize the ASM and divide | |
343 | ASM_reorganize_and_divide( asm_f0_patched_norm, |
|
343 | ASM_reorganize_and_divide( asm_f0_patched_norm, | |
344 | (float*) current_ring_node_to_send_asm_f0->buffer_address, |
|
344 | (float*) current_ring_node_to_send_asm_f0->buffer_address, | |
345 | nb_sm_before_f0.norm_bp1 ); |
|
345 | nb_sm_before_f0.norm_bp1 ); | |
346 | current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; |
|
346 | current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTimeNORM; | |
347 | current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; |
|
347 | current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTimeNORM; | |
348 | current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; |
|
348 | current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0; | |
349 |
|
349 | |||
350 | // 3) send the spectral matrix packets |
|
350 | // 3) send the spectral matrix packets | |
351 | status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); |
|
351 | status = rtems_message_queue_send( queue_id, ¤t_ring_node_to_send_asm_f0, sizeof( ring_node* ) ); | |
352 | // change asm ring node |
|
352 | // change asm ring node | |
353 | current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; |
|
353 | current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next; | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max ); |
|
356 | update_queue_max_count( queue_id_q_p0, &hk_lfr_q_p0_fifo_size_max ); | |
357 |
|
357 | |||
358 | } |
|
358 | } | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | //********** |
|
361 | //********** | |
362 | // FUNCTIONS |
|
362 | // FUNCTIONS | |
363 |
|
363 | |||
364 | void reset_nb_sm_f0( unsigned char lfrMode ) |
|
364 | void reset_nb_sm_f0( unsigned char lfrMode ) | |
365 | { |
|
365 | { | |
366 | nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; |
|
366 | nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; | |
367 | nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; |
|
367 | nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; | |
368 | nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; |
|
368 | nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; | |
369 | nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit |
|
369 | nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit | |
370 | nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; |
|
370 | nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; | |
371 | nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; |
|
371 | nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; | |
372 | nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; |
|
372 | nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; | |
373 | nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; |
|
373 | nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; | |
374 | nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; |
|
374 | nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; | |
375 |
|
375 | |||
376 | if (lfrMode == LFR_MODE_SBM1) |
|
376 | if (lfrMode == LFR_MODE_SBM1) | |
377 | { |
|
377 | { | |
378 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; |
|
378 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; | |
379 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; |
|
379 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; | |
380 | } |
|
380 | } | |
381 | else if (lfrMode == LFR_MODE_SBM2) |
|
381 | else if (lfrMode == LFR_MODE_SBM2) | |
382 | { |
|
382 | { | |
383 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; |
|
383 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; | |
384 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; |
|
384 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; | |
385 | } |
|
385 | } | |
386 | else if (lfrMode == LFR_MODE_BURST) |
|
386 | else if (lfrMode == LFR_MODE_BURST) | |
387 | { |
|
387 | { | |
388 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
|
388 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; | |
389 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
|
389 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; | |
390 | } |
|
390 | } | |
391 | else |
|
391 | else | |
392 | { |
|
392 | { | |
393 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; |
|
393 | nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; | |
394 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; |
|
394 | nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; | |
395 | } |
|
395 | } | |
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | void init_k_coefficients_prc0( void ) |
|
398 | void init_k_coefficients_prc0( void ) | |
399 | { |
|
399 | { | |
400 | init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); |
|
400 | init_k_coefficients( k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0 ); | |
401 |
|
401 | |||
402 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0); |
|
402 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f0_norm, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_F0); | |
403 | } |
|
403 | } | |
404 |
|
404 |
@@ -1,390 +1,390 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "avf1_prc1.h" |
|
10 | #include "avf1_prc1.h" | |
11 |
|
11 | |||
12 | nb_sm_before_bp_asm_f1 nb_sm_before_f1; |
|
12 | nb_sm_before_bp_asm_f1 nb_sm_before_f1; | |
13 |
|
13 | |||
14 | extern ring_node sm_ring_f1[ ]; |
|
14 | extern ring_node sm_ring_f1[ ]; | |
15 |
|
15 | |||
16 | //*** |
|
16 | //*** | |
17 | // F1 |
|
17 | // F1 | |
18 | ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ]; |
|
18 | ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ]; | |
19 | ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ]; |
|
19 | ring_node_asm asm_ring_burst_sbm_f1 [ NB_RING_NODES_ASM_BURST_SBM_F1 ]; | |
20 |
|
20 | |||
21 | ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ]; |
|
21 | ring_node ring_to_send_asm_f1 [ NB_RING_NODES_ASM_F1 ]; | |
22 | int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ]; |
|
22 | int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ]; | |
23 |
|
23 | |||
24 | float asm_f1_patched_norm [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f1_patched_norm [ TOTAL_SIZE_SM ]; | |
25 | float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ]; |
|
25 | float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ]; | |
26 | float asm_f1_reorganized [ TOTAL_SIZE_SM ]; |
|
26 | float asm_f1_reorganized [ TOTAL_SIZE_SM ]; | |
27 |
|
27 | |||
28 | char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; |
|
28 | char asm_f1_char [ TOTAL_SIZE_SM * 2 ]; | |
29 | float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; |
|
29 | float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; | |
30 | float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; |
|
30 | float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; | |
31 |
|
31 | |||
32 | float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416 |
|
32 | float k_coeff_intercalib_f1_norm[ NB_BINS_COMPRESSED_SM_F1 * NB_K_COEFF_PER_BIN ]; // 13 * 32 = 416 | |
33 | float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832 |
|
33 | float k_coeff_intercalib_f1_sbm[ NB_BINS_COMPRESSED_SM_SBM_F1 * NB_K_COEFF_PER_BIN ]; // 26 * 32 = 832 | |
34 |
|
34 | |||
35 | //************ |
|
35 | //************ | |
36 | // RTEMS TASKS |
|
36 | // RTEMS TASKS | |
37 |
|
37 | |||
38 | rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) |
|
38 | rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) | |
39 | { |
|
39 | { | |
40 | int i; |
|
40 | int i; | |
41 |
|
41 | |||
42 | rtems_event_set event_out; |
|
42 | rtems_event_set event_out; | |
43 | rtems_status_code status; |
|
43 | rtems_status_code status; | |
44 | rtems_id queue_id_prc1; |
|
44 | rtems_id queue_id_prc1; | |
45 | asm_msg msgForMATR; |
|
45 | asm_msg msgForMATR; | |
46 | ring_node *nodeForAveraging; |
|
46 | ring_node *nodeForAveraging; | |
47 | ring_node *ring_node_tab[NB_SM_BEFORE_AVF0]; |
|
47 | ring_node *ring_node_tab[NB_SM_BEFORE_AVF0]; | |
48 | ring_node_asm *current_ring_node_asm_burst_sbm_f1; |
|
48 | ring_node_asm *current_ring_node_asm_burst_sbm_f1; | |
49 | ring_node_asm *current_ring_node_asm_norm_f1; |
|
49 | ring_node_asm *current_ring_node_asm_norm_f1; | |
50 |
|
50 | |||
51 | unsigned int nb_norm_bp1; |
|
51 | unsigned int nb_norm_bp1; | |
52 | unsigned int nb_norm_bp2; |
|
52 | unsigned int nb_norm_bp2; | |
53 | unsigned int nb_norm_asm; |
|
53 | unsigned int nb_norm_asm; | |
54 | unsigned int nb_sbm_bp1; |
|
54 | unsigned int nb_sbm_bp1; | |
55 | unsigned int nb_sbm_bp2; |
|
55 | unsigned int nb_sbm_bp2; | |
56 |
|
56 | |||
57 | nb_norm_bp1 = 0; |
|
57 | nb_norm_bp1 = 0; | |
58 | nb_norm_bp2 = 0; |
|
58 | nb_norm_bp2 = 0; | |
59 | nb_norm_asm = 0; |
|
59 | nb_norm_asm = 0; | |
60 | nb_sbm_bp1 = 0; |
|
60 | nb_sbm_bp1 = 0; | |
61 | nb_sbm_bp2 = 0; |
|
61 | nb_sbm_bp2 = 0; | |
62 |
|
62 | |||
63 | reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
63 | reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
64 | ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 ); |
|
64 | ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 ); | |
65 | ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 ); |
|
65 | ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 ); | |
66 | current_ring_node_asm_norm_f1 = asm_ring_norm_f1; |
|
66 | current_ring_node_asm_norm_f1 = asm_ring_norm_f1; | |
67 | current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1; |
|
67 | current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1; | |
68 |
|
68 | |||
69 | BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
69 | BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
70 |
|
70 | |||
71 | status = get_message_queue_id_prc1( &queue_id_prc1 ); |
|
71 | status = get_message_queue_id_prc1( &queue_id_prc1 ); | |
72 | if (status != RTEMS_SUCCESSFUL) |
|
72 | if (status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status) |
|
74 | PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status) | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | while(1){ |
|
77 | while(1){ | |
78 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
78 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
79 |
|
79 | |||
80 | //**************************************** |
|
80 | //**************************************** | |
81 | // initialize the mesage for the MATR task |
|
81 | // initialize the mesage for the MATR task | |
82 | msgForMATR.norm = current_ring_node_asm_norm_f1; |
|
82 | msgForMATR.norm = current_ring_node_asm_norm_f1; | |
83 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; |
|
83 | msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; | |
84 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task |
|
84 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task | |
85 | // |
|
85 | // | |
86 | //**************************************** |
|
86 | //**************************************** | |
87 |
|
87 | |||
88 | nodeForAveraging = getRingNodeForAveraging( 1 ); |
|
88 | nodeForAveraging = getRingNodeForAveraging( 1 ); | |
89 |
|
89 | |||
90 | ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging; |
|
90 | ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging; | |
91 | for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) |
|
91 | for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) | |
92 | { |
|
92 | { | |
93 | nodeForAveraging = nodeForAveraging->previous; |
|
93 | nodeForAveraging = nodeForAveraging->previous; | |
94 | ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging; |
|
94 | ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | // compute the average and store it in the averaged_sm_f1 buffer |
|
97 | // compute the average and store it in the averaged_sm_f1 buffer | |
98 | SM_average( current_ring_node_asm_norm_f1->matrix, |
|
98 | SM_average( current_ring_node_asm_norm_f1->matrix, | |
99 | current_ring_node_asm_burst_sbm_f1->matrix, |
|
99 | current_ring_node_asm_burst_sbm_f1->matrix, | |
100 | ring_node_tab, |
|
100 | ring_node_tab, | |
101 | nb_norm_bp1, nb_sbm_bp1, |
|
101 | nb_norm_bp1, nb_sbm_bp1, | |
102 | &msgForMATR ); |
|
102 | &msgForMATR ); | |
103 |
|
103 | |||
104 | // update nb_average |
|
104 | // update nb_average | |
105 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; |
|
105 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; | |
106 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; |
|
106 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; | |
107 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; |
|
107 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; | |
108 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; |
|
108 | nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; | |
109 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; |
|
109 | nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; | |
110 |
|
110 | |||
111 | if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) |
|
111 | if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) | |
112 | { |
|
112 | { | |
113 | nb_sbm_bp1 = 0; |
|
113 | nb_sbm_bp1 = 0; | |
114 | // set another ring for the ASM storage |
|
114 | // set another ring for the ASM storage | |
115 | current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next; |
|
115 | current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next; | |
116 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
116 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
117 | { |
|
117 | { | |
118 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1; |
|
118 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1; | |
119 | } |
|
119 | } | |
120 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
120 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
121 | { |
|
121 | { | |
122 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1; |
|
122 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1; | |
123 | } |
|
123 | } | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) |
|
126 | if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) | |
127 | { |
|
127 | { | |
128 | nb_sbm_bp2 = 0; |
|
128 | nb_sbm_bp2 = 0; | |
129 | if ( lfrCurrentMode == LFR_MODE_BURST ) |
|
129 | if ( lfrCurrentMode == LFR_MODE_BURST ) | |
130 | { |
|
130 | { | |
131 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1; |
|
131 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1; | |
132 | } |
|
132 | } | |
133 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
133 | else if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
134 | { |
|
134 | { | |
135 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1; |
|
135 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1; | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) |
|
139 | if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) | |
140 | { |
|
140 | { | |
141 | nb_norm_bp1 = 0; |
|
141 | nb_norm_bp1 = 0; | |
142 | // set another ring for the ASM storage |
|
142 | // set another ring for the ASM storage | |
143 | current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next; |
|
143 | current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next; | |
144 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
144 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
145 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
145 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
146 | { |
|
146 | { | |
147 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; |
|
147 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) |
|
151 | if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) | |
152 | { |
|
152 | { | |
153 | nb_norm_bp2 = 0; |
|
153 | nb_norm_bp2 = 0; | |
154 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
154 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
155 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
155 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
156 | { |
|
156 | { | |
157 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; |
|
157 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; | |
158 | } |
|
158 | } | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | if (nb_norm_asm == nb_sm_before_f1.norm_asm) |
|
161 | if (nb_norm_asm == nb_sm_before_f1.norm_asm) | |
162 | { |
|
162 | { | |
163 | nb_norm_asm = 0; |
|
163 | nb_norm_asm = 0; | |
164 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
164 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
165 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
165 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
166 | { |
|
166 | { | |
167 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; |
|
167 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; | |
168 | } |
|
168 | } | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | //************************* |
|
171 | //************************* | |
172 | // send the message to MATR |
|
172 | // send the message to MATR | |
173 | if (msgForMATR.event != 0x00) |
|
173 | if (msgForMATR.event != 0x00) | |
174 | { |
|
174 | { | |
175 | status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1); |
|
175 | status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | if (status != RTEMS_SUCCESSFUL) { |
|
178 | if (status != RTEMS_SUCCESSFUL) { | |
179 |
|
|
179 | PRINTF1("in AVF1 *** Error sending message to PRC1, code %d\n", status) | |
180 | } |
|
180 | } | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) |
|
184 | rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) | |
185 | { |
|
185 | { | |
186 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
186 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
187 | size_t size; // size of the incoming TC packet |
|
187 | size_t size; // size of the incoming TC packet | |
188 | asm_msg *incomingMsg; |
|
188 | asm_msg *incomingMsg; | |
189 | // |
|
189 | // | |
190 | unsigned char sid; |
|
190 | unsigned char sid; | |
191 | rtems_status_code status; |
|
191 | rtems_status_code status; | |
192 | rtems_id queue_id_send; |
|
192 | rtems_id queue_id_send; | |
193 | rtems_id queue_id_q_p1; |
|
193 | rtems_id queue_id_q_p1; | |
194 | bp_packet_with_spare packet_norm_bp1; |
|
194 | bp_packet_with_spare packet_norm_bp1; | |
195 | bp_packet packet_norm_bp2; |
|
195 | bp_packet packet_norm_bp2; | |
196 | bp_packet packet_sbm_bp1; |
|
196 | bp_packet packet_sbm_bp1; | |
197 | bp_packet packet_sbm_bp2; |
|
197 | bp_packet packet_sbm_bp2; | |
198 | ring_node *current_ring_node_to_send_asm_f1; |
|
198 | ring_node *current_ring_node_to_send_asm_f1; | |
199 |
|
199 | |||
200 | unsigned long long int localTime; |
|
200 | unsigned long long int localTime; | |
201 |
|
201 | |||
202 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
202 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
203 | init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM ); |
|
203 | init_ring( ring_to_send_asm_f1, NB_RING_NODES_ASM_F1, (volatile int*) buffer_asm_f1, TOTAL_SIZE_SM ); | |
204 | current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1; |
|
204 | current_ring_node_to_send_asm_f1 = ring_to_send_asm_f1; | |
205 |
|
205 | |||
206 | //************* |
|
206 | //************* | |
207 | // NORM headers |
|
207 | // NORM headers | |
208 | BP_init_header_with_spare( &packet_norm_bp1, |
|
208 | BP_init_header_with_spare( &packet_norm_bp1, | |
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, |
|
209 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, | |
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 ); |
|
210 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 ); | |
211 | BP_init_header( &packet_norm_bp2, |
|
211 | BP_init_header( &packet_norm_bp2, | |
212 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, |
|
212 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, | |
213 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1); |
|
213 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1); | |
214 |
|
214 | |||
215 | //*********************** |
|
215 | //*********************** | |
216 | // BURST and SBM2 headers |
|
216 | // BURST and SBM2 headers | |
217 | if ( lfrRequestedMode == LFR_MODE_BURST ) |
|
217 | if ( lfrRequestedMode == LFR_MODE_BURST ) | |
218 | { |
|
218 | { | |
219 | BP_init_header( &packet_sbm_bp1, |
|
219 | BP_init_header( &packet_sbm_bp1, | |
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, |
|
220 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, | |
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
221 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
222 | BP_init_header( &packet_sbm_bp2, |
|
222 | BP_init_header( &packet_sbm_bp2, | |
223 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, |
|
223 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, | |
224 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
224 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
225 | } |
|
225 | } | |
226 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
226 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) | |
227 | { |
|
227 | { | |
228 | BP_init_header( &packet_sbm_bp1, |
|
228 | BP_init_header( &packet_sbm_bp1, | |
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, |
|
229 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, | |
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
230 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
231 | BP_init_header( &packet_sbm_bp2, |
|
231 | BP_init_header( &packet_sbm_bp2, | |
232 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, |
|
232 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, | |
233 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); |
|
233 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); | |
234 | } |
|
234 | } | |
235 | else |
|
235 | else | |
236 | { |
|
236 | { | |
237 | PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) |
|
237 | PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) | |
238 | } |
|
238 | } | |
239 |
|
239 | |||
240 | status = get_message_queue_id_send( &queue_id_send ); |
|
240 | status = get_message_queue_id_send( &queue_id_send ); | |
241 | if (status != RTEMS_SUCCESSFUL) |
|
241 | if (status != RTEMS_SUCCESSFUL) | |
242 | { |
|
242 | { | |
243 | PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status) |
|
243 | PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status) | |
244 | } |
|
244 | } | |
245 | status = get_message_queue_id_prc1( &queue_id_q_p1); |
|
245 | status = get_message_queue_id_prc1( &queue_id_q_p1); | |
246 | if (status != RTEMS_SUCCESSFUL) |
|
246 | if (status != RTEMS_SUCCESSFUL) | |
247 | { |
|
247 | { | |
248 | PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status) |
|
248 | PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status) | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) |
|
251 | BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) | |
252 |
|
252 | |||
253 | while(1){ |
|
253 | while(1){ | |
254 | status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ |
|
254 | status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ | |
255 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
|
255 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 | |
256 |
|
256 | |||
257 | incomingMsg = (asm_msg*) incomingData; |
|
257 | incomingMsg = (asm_msg*) incomingData; | |
258 |
|
258 | |||
259 | ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm ); |
|
259 | ASM_patch( incomingMsg->norm->matrix, asm_f1_patched_norm ); | |
260 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm ); |
|
260 | ASM_patch( incomingMsg->burst_sbm->matrix, asm_f1_patched_burst_sbm ); | |
261 |
|
261 | |||
262 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
262 | localTime = getTimeAsUnsignedLongLongInt( ); | |
263 | //*********** |
|
263 | //*********** | |
264 | //*********** |
|
264 | //*********** | |
265 | // BURST SBM2 |
|
265 | // BURST SBM2 | |
266 | //*********** |
|
266 | //*********** | |
267 | //*********** |
|
267 | //*********** | |
268 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) ) |
|
268 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) ) | |
269 | { |
|
269 | { | |
270 | sid = getSID( incomingMsg->event ); |
|
270 | sid = getSID( incomingMsg->event ); | |
271 | // 1) compress the matrix for Basic Parameters calculation |
|
271 | // 1) compress the matrix for Basic Parameters calculation | |
272 | ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1, |
|
272 | ASM_compress_reorganize_and_divide( asm_f1_patched_burst_sbm, compressed_sm_sbm_f1, | |
273 | nb_sm_before_f1.burst_sbm_bp1, |
|
273 | nb_sm_before_f1.burst_sbm_bp1, | |
274 | NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1, |
|
274 | NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1, | |
275 | ASM_F1_INDICE_START); |
|
275 | ASM_F1_INDICE_START); | |
276 | // 2) compute the BP1 set |
|
276 | // 2) compute the BP1 set | |
277 | BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data ); |
|
277 | BP1_set( compressed_sm_sbm_f1, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp1.data ); | |
278 | // 3) send the BP1 set |
|
278 | // 3) send the BP1 set | |
279 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
279 | set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
280 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
280 | set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
281 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
281 | packet_sbm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
282 | BP_send( (char *) &packet_sbm_bp1, queue_id_send, |
|
282 | BP_send( (char *) &packet_sbm_bp1, queue_id_send, | |
283 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, |
|
283 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA, | |
284 | sid ); |
|
284 | sid ); | |
285 | // 4) compute the BP2 set if needed |
|
285 | // 4) compute the BP2 set if needed | |
286 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) ) |
|
286 | if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) ) | |
287 | { |
|
287 | { | |
288 | // 1) compute the BP2 set |
|
288 | // 1) compute the BP2 set | |
289 | BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data ); |
|
289 | BP2_set( compressed_sm_sbm_f1, NB_BINS_COMPRESSED_SM_SBM_F1, packet_sbm_bp2.data ); | |
290 | // 2) send the BP2 set |
|
290 | // 2) send the BP2 set | |
291 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
291 | set_time( packet_sbm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
292 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); |
|
292 | set_time( packet_sbm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM ); | |
293 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
293 | packet_sbm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
294 | BP_send( (char *) &packet_sbm_bp2, queue_id_send, |
|
294 | BP_send( (char *) &packet_sbm_bp2, queue_id_send, | |
295 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, |
|
295 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA, | |
296 | sid ); |
|
296 | sid ); | |
297 | } |
|
297 | } | |
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | //***** |
|
300 | //***** | |
301 | //***** |
|
301 | //***** | |
302 | // NORM |
|
302 | // NORM | |
303 | //***** |
|
303 | //***** | |
304 | //***** |
|
304 | //***** | |
305 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) |
|
305 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) | |
306 | { |
|
306 | { | |
307 | // 1) compress the matrix for Basic Parameters calculation |
|
307 | // 1) compress the matrix for Basic Parameters calculation | |
308 | ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1, |
|
308 | ASM_compress_reorganize_and_divide( asm_f1_patched_norm, compressed_sm_norm_f1, | |
309 | nb_sm_before_f1.norm_bp1, |
|
309 | nb_sm_before_f1.norm_bp1, | |
310 | NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, |
|
310 | NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1, | |
311 | ASM_F1_INDICE_START ); |
|
311 | ASM_F1_INDICE_START ); | |
312 | // 2) compute the BP1 set |
|
312 | // 2) compute the BP1 set | |
313 | BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); |
|
313 | BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data ); | |
314 | // 3) send the BP1 set |
|
314 | // 3) send the BP1 set | |
315 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
315 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
316 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
316 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
317 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
317 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
318 | BP_send( (char *) &packet_norm_bp1, queue_id_send, |
|
318 | BP_send( (char *) &packet_norm_bp1, queue_id_send, | |
319 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA, |
|
319 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA, | |
320 | SID_NORM_BP1_F1 ); |
|
320 | SID_NORM_BP1_F1 ); | |
321 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) |
|
321 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) | |
322 | { |
|
322 | { | |
323 | // 1) compute the BP2 set |
|
323 | // 1) compute the BP2 set | |
324 | BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data ); |
|
324 | BP2_set( compressed_sm_norm_f1, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp2.data ); | |
325 | // 2) send the BP2 set |
|
325 | // 2) send the BP2 set | |
326 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
326 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
327 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
327 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
328 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
328 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
329 | BP_send( (char *) &packet_norm_bp2, queue_id_send, |
|
329 | BP_send( (char *) &packet_norm_bp2, queue_id_send, | |
330 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA, |
|
330 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA, | |
331 | SID_NORM_BP2_F1 ); |
|
331 | SID_NORM_BP2_F1 ); | |
332 | } |
|
332 | } | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) |
|
335 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) | |
336 | { |
|
336 | { | |
337 | // 1) reorganize the ASM and divide |
|
337 | // 1) reorganize the ASM and divide | |
338 | ASM_reorganize_and_divide( asm_f1_patched_norm, |
|
338 | ASM_reorganize_and_divide( asm_f1_patched_norm, | |
339 | (float*) current_ring_node_to_send_asm_f1->buffer_address, |
|
339 | (float*) current_ring_node_to_send_asm_f1->buffer_address, | |
340 | nb_sm_before_f1.norm_bp1 ); |
|
340 | nb_sm_before_f1.norm_bp1 ); | |
341 | current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM; |
|
341 | current_ring_node_to_send_asm_f1->coarseTime = incomingMsg->coarseTimeNORM; | |
342 | current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM; |
|
342 | current_ring_node_to_send_asm_f1->fineTime = incomingMsg->fineTimeNORM; | |
343 | current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1; |
|
343 | current_ring_node_to_send_asm_f1->sid = SID_NORM_ASM_F1; | |
344 | // 3) send the spectral matrix packets |
|
344 | // 3) send the spectral matrix packets | |
345 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f1, sizeof( ring_node* ) ); |
|
345 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f1, sizeof( ring_node* ) ); | |
346 | // change asm ring node |
|
346 | // change asm ring node | |
347 | current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next; |
|
347 | current_ring_node_to_send_asm_f1 = current_ring_node_to_send_asm_f1->next; | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max ); |
|
350 | update_queue_max_count( queue_id_q_p1, &hk_lfr_q_p1_fifo_size_max ); | |
351 |
|
351 | |||
352 | } |
|
352 | } | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | //********** |
|
355 | //********** | |
356 | // FUNCTIONS |
|
356 | // FUNCTIONS | |
357 |
|
357 | |||
358 | void reset_nb_sm_f1( unsigned char lfrMode ) |
|
358 | void reset_nb_sm_f1( unsigned char lfrMode ) | |
359 | { |
|
359 | { | |
360 | nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; |
|
360 | nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; | |
361 | nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; |
|
361 | nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; | |
362 | nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16; |
|
362 | nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16; | |
363 | nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; |
|
363 | nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; | |
364 | nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; |
|
364 | nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; | |
365 | nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; |
|
365 | nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; | |
366 | nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; |
|
366 | nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; | |
367 |
|
367 | |||
368 | if (lfrMode == LFR_MODE_SBM2) |
|
368 | if (lfrMode == LFR_MODE_SBM2) | |
369 | { |
|
369 | { | |
370 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; |
|
370 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; | |
371 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; |
|
371 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; | |
372 | } |
|
372 | } | |
373 | else if (lfrMode == LFR_MODE_BURST) |
|
373 | else if (lfrMode == LFR_MODE_BURST) | |
374 | { |
|
374 | { | |
375 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; |
|
375 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; | |
376 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; |
|
376 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; | |
377 | } |
|
377 | } | |
378 | else |
|
378 | else | |
379 | { |
|
379 | { | |
380 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; |
|
380 | nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; | |
381 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; |
|
381 | nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; | |
382 | } |
|
382 | } | |
383 | } |
|
383 | } | |
384 |
|
384 | |||
385 | void init_k_coefficients_prc1( void ) |
|
385 | void init_k_coefficients_prc1( void ) | |
386 | { |
|
386 | { | |
387 | init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 ); |
|
387 | init_k_coefficients( k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1 ); | |
388 |
|
388 | |||
389 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1); |
|
389 | init_kcoeff_sbm_from_kcoeff_norm( k_coeff_intercalib_f1_norm, k_coeff_intercalib_f1_sbm, NB_BINS_COMPRESSED_SM_F1); | |
390 | } |
|
390 | } |
@@ -1,291 +1,279 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "avf2_prc2.h" |
|
10 | #include "avf2_prc2.h" | |
11 |
|
11 | |||
12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; |
|
12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; | |
13 |
|
13 | |||
14 | extern ring_node sm_ring_f2[ ]; |
|
14 | extern ring_node sm_ring_f2[ ]; | |
15 |
|
15 | |||
16 | //*** |
|
16 | //*** | |
17 | // F2 |
|
17 | // F2 | |
18 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; |
|
18 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; | |
19 |
|
19 | |||
20 | ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ]; |
|
20 | ring_node ring_to_send_asm_f2 [ NB_RING_NODES_ASM_F2 ]; | |
21 | int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ]; |
|
21 | int buffer_asm_f2 [ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ]; | |
22 |
|
22 | |||
23 | float asm_f2_patched_norm [ TOTAL_SIZE_SM ]; |
|
23 | float asm_f2_patched_norm [ TOTAL_SIZE_SM ]; | |
24 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; |
|
24 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; | |
25 |
|
25 | |||
26 | char asm_f2_char [ TOTAL_SIZE_SM * 2 ]; |
|
26 | char asm_f2_char [ TOTAL_SIZE_SM * 2 ]; | |
27 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; |
|
27 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; | |
28 |
|
28 | |||
29 | float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384 |
|
29 | float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384 | |
30 |
|
30 | |||
31 | //************ |
|
31 | //************ | |
32 | // RTEMS TASKS |
|
32 | // RTEMS TASKS | |
33 |
|
33 | |||
34 | //*** |
|
34 | //*** | |
35 | // F2 |
|
35 | // F2 | |
36 | rtems_task avf2_task( rtems_task_argument argument ) |
|
36 | rtems_task avf2_task( rtems_task_argument argument ) | |
37 | { |
|
37 | { | |
38 | rtems_event_set event_out; |
|
38 | rtems_event_set event_out; | |
39 | rtems_status_code status; |
|
39 | rtems_status_code status; | |
40 | rtems_id queue_id_prc2; |
|
40 | rtems_id queue_id_prc2; | |
41 | asm_msg msgForMATR; |
|
41 | asm_msg msgForMATR; | |
42 | ring_node *nodeForAveraging; |
|
42 | ring_node *nodeForAveraging; | |
43 | ring_node_asm *current_ring_node_asm_norm_f2; |
|
43 | ring_node_asm *current_ring_node_asm_norm_f2; | |
44 |
|
44 | |||
45 | unsigned int nb_norm_bp1; |
|
45 | unsigned int nb_norm_bp1; | |
46 | unsigned int nb_norm_bp2; |
|
46 | unsigned int nb_norm_bp2; | |
47 | unsigned int nb_norm_asm; |
|
47 | unsigned int nb_norm_asm; | |
48 |
|
48 | |||
49 | nb_norm_bp1 = 0; |
|
49 | nb_norm_bp1 = 0; | |
50 | nb_norm_bp2 = 0; |
|
50 | nb_norm_bp2 = 0; | |
51 | nb_norm_asm = 0; |
|
51 | nb_norm_asm = 0; | |
52 |
|
52 | |||
53 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
53 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions | |
54 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); |
|
54 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); | |
55 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; |
|
55 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; | |
56 |
|
56 | |||
57 | BOOT_PRINTF("in AVF2 ***\n") |
|
57 | BOOT_PRINTF("in AVF2 ***\n") | |
58 |
|
58 | |||
59 | status = get_message_queue_id_prc2( &queue_id_prc2 ); |
|
59 | status = get_message_queue_id_prc2( &queue_id_prc2 ); | |
60 | if (status != RTEMS_SUCCESSFUL) |
|
60 | if (status != RTEMS_SUCCESSFUL) | |
61 | { |
|
61 | { | |
62 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
62 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | while(1){ |
|
65 | while(1){ | |
66 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
66 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
67 |
|
67 | |||
68 | //**************************************** |
|
68 | //**************************************** | |
69 | // initialize the mesage for the MATR task |
|
69 | // initialize the mesage for the MATR task | |
70 | msgForMATR.norm = current_ring_node_asm_norm_f2; |
|
70 | msgForMATR.norm = current_ring_node_asm_norm_f2; | |
71 | msgForMATR.burst_sbm = NULL; |
|
71 | msgForMATR.burst_sbm = NULL; | |
72 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task |
|
72 | msgForMATR.event = 0x00; // this composite event will be sent to the PRC2 task | |
73 | // |
|
73 | // | |
74 | //**************************************** |
|
74 | //**************************************** | |
75 |
|
75 | |||
76 | nodeForAveraging = getRingNodeForAveraging( 2 ); |
|
76 | nodeForAveraging = getRingNodeForAveraging( 2 ); | |
77 |
|
77 | |||
78 | // 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 |
|
||||
90 | // compute the average and store it in the averaged_sm_f2 buffer |
|
78 | // compute the average and store it in the averaged_sm_f2 buffer | |
91 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, |
|
79 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, | |
92 | nodeForAveraging, |
|
80 | nodeForAveraging, | |
93 | nb_norm_bp1, |
|
81 | nb_norm_bp1, | |
94 | &msgForMATR ); |
|
82 | &msgForMATR ); | |
95 |
|
83 | |||
96 | // update nb_average |
|
84 | // update nb_average | |
97 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; |
|
85 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; | |
98 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; |
|
86 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; | |
99 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; |
|
87 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; | |
100 |
|
88 | |||
101 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) |
|
89 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) | |
102 | { |
|
90 | { | |
103 | nb_norm_bp1 = 0; |
|
91 | nb_norm_bp1 = 0; | |
104 | // set another ring for the ASM storage |
|
92 | // set another ring for the ASM storage | |
105 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; |
|
93 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; | |
106 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
94 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
107 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
95 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
108 | { |
|
96 | { | |
109 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; |
|
97 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; | |
110 | } |
|
98 | } | |
111 | } |
|
99 | } | |
112 |
|
100 | |||
113 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) |
|
101 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) | |
114 | { |
|
102 | { | |
115 | nb_norm_bp2 = 0; |
|
103 | nb_norm_bp2 = 0; | |
116 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
104 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
117 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
105 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
118 | { |
|
106 | { | |
119 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; |
|
107 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; | |
120 | } |
|
108 | } | |
121 | } |
|
109 | } | |
122 |
|
110 | |||
123 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) |
|
111 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) | |
124 | { |
|
112 | { | |
125 | nb_norm_asm = 0; |
|
113 | nb_norm_asm = 0; | |
126 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
114 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) | |
127 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
115 | || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
128 | { |
|
116 | { | |
129 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; |
|
117 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; | |
130 | } |
|
118 | } | |
131 | } |
|
119 | } | |
132 |
|
120 | |||
133 | //************************* |
|
121 | //************************* | |
134 | // send the message to MATR |
|
122 | // send the message to MATR | |
135 | if (msgForMATR.event != 0x00) |
|
123 | if (msgForMATR.event != 0x00) | |
136 | { |
|
124 | { | |
137 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2); |
|
125 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC2); | |
138 | } |
|
126 | } | |
139 |
|
127 | |||
140 | if (status != RTEMS_SUCCESSFUL) { |
|
128 | if (status != RTEMS_SUCCESSFUL) { | |
141 |
|
|
129 | PRINTF1("in AVF2 *** Error sending message to MATR, code %d\n", status) | |
142 | } |
|
130 | } | |
143 | } |
|
131 | } | |
144 | } |
|
132 | } | |
145 |
|
133 | |||
146 | rtems_task prc2_task( rtems_task_argument argument ) |
|
134 | rtems_task prc2_task( rtems_task_argument argument ) | |
147 | { |
|
135 | { | |
148 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
136 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
149 | size_t size; // size of the incoming TC packet |
|
137 | size_t size; // size of the incoming TC packet | |
150 | asm_msg *incomingMsg; |
|
138 | asm_msg *incomingMsg; | |
151 | // |
|
139 | // | |
152 | rtems_status_code status; |
|
140 | rtems_status_code status; | |
153 | rtems_id queue_id_send; |
|
141 | rtems_id queue_id_send; | |
154 | rtems_id queue_id_q_p2; |
|
142 | rtems_id queue_id_q_p2; | |
155 | bp_packet packet_norm_bp1; |
|
143 | bp_packet packet_norm_bp1; | |
156 | bp_packet packet_norm_bp2; |
|
144 | bp_packet packet_norm_bp2; | |
157 | ring_node *current_ring_node_to_send_asm_f2; |
|
145 | ring_node *current_ring_node_to_send_asm_f2; | |
158 |
|
146 | |||
159 | unsigned long long int localTime; |
|
147 | unsigned long long int localTime; | |
160 |
|
148 | |||
161 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU |
|
149 | // init the ring of the averaged spectral matrices which will be transmitted to the DPU | |
162 | init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM ); |
|
150 | init_ring( ring_to_send_asm_f2, NB_RING_NODES_ASM_F2, (volatile int*) buffer_asm_f2, TOTAL_SIZE_SM ); | |
163 | current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2; |
|
151 | current_ring_node_to_send_asm_f2 = ring_to_send_asm_f2; | |
164 |
|
152 | |||
165 | //************* |
|
153 | //************* | |
166 | // NORM headers |
|
154 | // NORM headers | |
167 | BP_init_header( &packet_norm_bp1, |
|
155 | BP_init_header( &packet_norm_bp1, | |
168 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, |
|
156 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, | |
169 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
157 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); | |
170 | BP_init_header( &packet_norm_bp2, |
|
158 | BP_init_header( &packet_norm_bp2, | |
171 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, |
|
159 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, | |
172 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
160 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); | |
173 |
|
161 | |||
174 | status = get_message_queue_id_send( &queue_id_send ); |
|
162 | status = get_message_queue_id_send( &queue_id_send ); | |
175 | if (status != RTEMS_SUCCESSFUL) |
|
163 | if (status != RTEMS_SUCCESSFUL) | |
176 | { |
|
164 | { | |
177 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) |
|
165 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) | |
178 | } |
|
166 | } | |
179 | status = get_message_queue_id_prc2( &queue_id_q_p2); |
|
167 | status = get_message_queue_id_prc2( &queue_id_q_p2); | |
180 | if (status != RTEMS_SUCCESSFUL) |
|
168 | if (status != RTEMS_SUCCESSFUL) | |
181 | { |
|
169 | { | |
182 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
170 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) | |
183 | } |
|
171 | } | |
184 |
|
172 | |||
185 | BOOT_PRINTF("in PRC2 ***\n") |
|
173 | BOOT_PRINTF("in PRC2 ***\n") | |
186 |
|
174 | |||
187 | while(1){ |
|
175 | while(1){ | |
188 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ |
|
176 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ | |
189 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 |
|
177 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2 | |
190 |
|
178 | |||
191 | incomingMsg = (asm_msg*) incomingData; |
|
179 | incomingMsg = (asm_msg*) incomingData; | |
192 |
|
180 | |||
193 | ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm ); |
|
181 | ASM_patch( incomingMsg->norm->matrix, asm_f2_patched_norm ); | |
194 |
|
182 | |||
195 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
183 | localTime = getTimeAsUnsignedLongLongInt( ); | |
196 |
|
184 | |||
197 | //***** |
|
185 | //***** | |
198 | //***** |
|
186 | //***** | |
199 | // NORM |
|
187 | // NORM | |
200 | //***** |
|
188 | //***** | |
201 | //***** |
|
189 | //***** | |
202 | // 1) compress the matrix for Basic Parameters calculation |
|
190 | // 1) compress the matrix for Basic Parameters calculation | |
203 | ASM_compress_reorganize_and_divide( asm_f2_patched_norm, compressed_sm_norm_f2, |
|
191 | ASM_compress_reorganize_and_divide( asm_f2_patched_norm, compressed_sm_norm_f2, | |
204 | nb_sm_before_f2.norm_bp1, |
|
192 | nb_sm_before_f2.norm_bp1, | |
205 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, |
|
193 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, | |
206 | ASM_F2_INDICE_START ); |
|
194 | ASM_F2_INDICE_START ); | |
207 | // BP1_F2 |
|
195 | // BP1_F2 | |
208 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) |
|
196 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) | |
209 | { |
|
197 | { | |
210 | // 1) compute the BP1 set |
|
198 | // 1) compute the BP1 set | |
211 | BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); |
|
199 | BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data ); | |
212 | // 2) send the BP1 set |
|
200 | // 2) send the BP1 set | |
213 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
201 | set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
214 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
202 | set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
215 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
203 | packet_norm_bp1.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
216 | BP_send( (char *) &packet_norm_bp1, queue_id_send, |
|
204 | BP_send( (char *) &packet_norm_bp1, queue_id_send, | |
217 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, |
|
205 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, | |
218 | SID_NORM_BP1_F2 ); |
|
206 | SID_NORM_BP1_F2 ); | |
219 | } |
|
207 | } | |
220 | // BP2_F2 |
|
208 | // BP2_F2 | |
221 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) |
|
209 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) | |
222 | { |
|
210 | { | |
223 | // 1) compute the BP2 set |
|
211 | // 1) compute the BP2 set | |
224 | BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); |
|
212 | BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data ); | |
225 | // 2) send the BP2 set |
|
213 | // 2) send the BP2 set | |
226 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
214 | set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
227 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); |
|
215 | set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM ); | |
228 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
216 | packet_norm_bp2.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
229 | BP_send( (char *) &packet_norm_bp2, queue_id_send, |
|
217 | BP_send( (char *) &packet_norm_bp2, queue_id_send, | |
230 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, |
|
218 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, | |
231 | SID_NORM_BP2_F2 ); |
|
219 | SID_NORM_BP2_F2 ); | |
232 | } |
|
220 | } | |
233 |
|
221 | |||
234 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) |
|
222 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) | |
235 | { |
|
223 | { | |
236 | // 1) reorganize the ASM and divide |
|
224 | // 1) reorganize the ASM and divide | |
237 | ASM_reorganize_and_divide( asm_f2_patched_norm, |
|
225 | ASM_reorganize_and_divide( asm_f2_patched_norm, | |
238 | (float*) current_ring_node_to_send_asm_f2->buffer_address, |
|
226 | (float*) current_ring_node_to_send_asm_f2->buffer_address, | |
239 | nb_sm_before_f2.norm_bp1 ); |
|
227 | nb_sm_before_f2.norm_bp1 ); | |
240 | current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM; |
|
228 | current_ring_node_to_send_asm_f2->coarseTime = incomingMsg->coarseTimeNORM; | |
241 | current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM; |
|
229 | current_ring_node_to_send_asm_f2->fineTime = incomingMsg->fineTimeNORM; | |
242 | current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2; |
|
230 | current_ring_node_to_send_asm_f2->sid = SID_NORM_ASM_F2; | |
243 | // 3) send the spectral matrix packets |
|
231 | // 3) send the spectral matrix packets | |
244 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f2, sizeof( ring_node* ) ); |
|
232 | status = rtems_message_queue_send( queue_id_send, ¤t_ring_node_to_send_asm_f2, sizeof( ring_node* ) ); | |
245 | // change asm ring node |
|
233 | // change asm ring node | |
246 | current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next; |
|
234 | current_ring_node_to_send_asm_f2 = current_ring_node_to_send_asm_f2->next; | |
247 | } |
|
235 | } | |
248 |
|
236 | |||
249 | update_queue_max_count( queue_id_q_p2, &hk_lfr_q_p2_fifo_size_max ); |
|
237 | update_queue_max_count( queue_id_q_p2, &hk_lfr_q_p2_fifo_size_max ); | |
250 |
|
238 | |||
251 | } |
|
239 | } | |
252 | } |
|
240 | } | |
253 |
|
241 | |||
254 | //********** |
|
242 | //********** | |
255 | // FUNCTIONS |
|
243 | // FUNCTIONS | |
256 |
|
244 | |||
257 | void reset_nb_sm_f2( void ) |
|
245 | void reset_nb_sm_f2( void ) | |
258 | { |
|
246 | { | |
259 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; |
|
247 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; | |
260 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; |
|
248 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; | |
261 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; |
|
249 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; | |
262 | } |
|
250 | } | |
263 |
|
251 | |||
264 | void SM_average_f2( float *averaged_spec_mat_f2, |
|
252 | void SM_average_f2( float *averaged_spec_mat_f2, | |
265 | ring_node *ring_node, |
|
253 | ring_node *ring_node, | |
266 | unsigned int nbAverageNormF2, |
|
254 | unsigned int nbAverageNormF2, | |
267 | asm_msg *msgForMATR ) |
|
255 | asm_msg *msgForMATR ) | |
268 | { |
|
256 | { | |
269 | float sum; |
|
257 | float sum; | |
270 | unsigned int i; |
|
258 | unsigned int i; | |
271 |
|
259 | |||
272 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
260 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
273 | { |
|
261 | { | |
274 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; |
|
262 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; | |
275 | if ( (nbAverageNormF2 == 0) ) |
|
263 | if ( (nbAverageNormF2 == 0) ) | |
276 | { |
|
264 | { | |
277 | averaged_spec_mat_f2[ i ] = sum; |
|
265 | averaged_spec_mat_f2[ i ] = sum; | |
278 | msgForMATR->coarseTimeNORM = ring_node->coarseTime; |
|
266 | msgForMATR->coarseTimeNORM = ring_node->coarseTime; | |
279 | msgForMATR->fineTimeNORM = ring_node->fineTime; |
|
267 | msgForMATR->fineTimeNORM = ring_node->fineTime; | |
280 | } |
|
268 | } | |
281 | else |
|
269 | else | |
282 | { |
|
270 | { | |
283 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); |
|
271 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); | |
284 | } |
|
272 | } | |
285 | } |
|
273 | } | |
286 | } |
|
274 | } | |
287 |
|
275 | |||
288 | void init_k_coefficients_prc2( void ) |
|
276 | void init_k_coefficients_prc2( void ) | |
289 | { |
|
277 | { | |
290 | init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2); |
|
278 | init_k_coefficients( k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2); | |
291 | } |
|
279 | } |
@@ -1,671 +1,671 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "fsw_processing.h" |
|
10 | #include "fsw_processing.h" | |
11 | #include "fsw_processing_globals.c" |
|
11 | #include "fsw_processing_globals.c" | |
12 | #include "fsw_init.h" |
|
12 | #include "fsw_init.h" | |
13 |
|
13 | |||
14 | unsigned int nb_sm_f0; |
|
14 | unsigned int nb_sm_f0; | |
15 | unsigned int nb_sm_f0_aux_f1; |
|
15 | unsigned int nb_sm_f0_aux_f1; | |
16 | unsigned int nb_sm_f1; |
|
16 | unsigned int nb_sm_f1; | |
17 | unsigned int nb_sm_f0_aux_f2; |
|
17 | unsigned int nb_sm_f0_aux_f2; | |
18 |
|
18 | |||
19 | //************************ |
|
19 | //************************ | |
20 | // spectral matrices rings |
|
20 | // spectral matrices rings | |
21 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ]; |
|
21 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ]; | |
22 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ]; |
|
22 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ]; | |
23 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ]; |
|
23 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ]; | |
24 | ring_node *current_ring_node_sm_f0; |
|
24 | ring_node *current_ring_node_sm_f0; | |
25 | ring_node *current_ring_node_sm_f1; |
|
25 | ring_node *current_ring_node_sm_f1; | |
26 | ring_node *current_ring_node_sm_f2; |
|
26 | ring_node *current_ring_node_sm_f2; | |
27 | ring_node *ring_node_for_averaging_sm_f0; |
|
27 | ring_node *ring_node_for_averaging_sm_f0; | |
28 | ring_node *ring_node_for_averaging_sm_f1; |
|
28 | ring_node *ring_node_for_averaging_sm_f1; | |
29 | ring_node *ring_node_for_averaging_sm_f2; |
|
29 | ring_node *ring_node_for_averaging_sm_f2; | |
30 |
|
30 | |||
31 | // |
|
31 | // | |
32 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel) |
|
32 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel) | |
33 | { |
|
33 | { | |
34 | ring_node *node; |
|
34 | ring_node *node; | |
35 |
|
35 | |||
36 | node = NULL; |
|
36 | node = NULL; | |
37 | switch ( frequencyChannel ) { |
|
37 | switch ( frequencyChannel ) { | |
38 | case 0: |
|
38 | case 0: | |
39 | node = ring_node_for_averaging_sm_f0; |
|
39 | node = ring_node_for_averaging_sm_f0; | |
40 | break; |
|
40 | break; | |
41 | case 1: |
|
41 | case 1: | |
42 | node = ring_node_for_averaging_sm_f1; |
|
42 | node = ring_node_for_averaging_sm_f1; | |
43 | break; |
|
43 | break; | |
44 | case 2: |
|
44 | case 2: | |
45 | node = ring_node_for_averaging_sm_f2; |
|
45 | node = ring_node_for_averaging_sm_f2; | |
46 | break; |
|
46 | break; | |
47 | default: |
|
47 | default: | |
48 | break; |
|
48 | break; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | return node; |
|
51 | return node; | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | //*********************************************************** |
|
54 | //*********************************************************** | |
55 | // Interrupt Service Routine for spectral matrices processing |
|
55 | // Interrupt Service Routine for spectral matrices processing | |
56 |
|
56 | |||
57 | void spectral_matrices_isr_f0( unsigned char statusReg ) |
|
57 | void spectral_matrices_isr_f0( unsigned char statusReg ) | |
58 | { |
|
58 | { | |
59 | unsigned char status; |
|
59 | unsigned char status; | |
60 | rtems_status_code status_code; |
|
60 | rtems_status_code status_code; | |
61 | ring_node *full_ring_node; |
|
61 | ring_node *full_ring_node; | |
62 |
|
62 | |||
63 | status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits |
|
63 | status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits | |
64 |
|
64 | |||
65 | switch(status) |
|
65 | switch(status) | |
66 | { |
|
66 | { | |
67 | case 0: |
|
67 | case 0: | |
68 | break; |
|
68 | break; | |
69 | case 3: |
|
69 | case 3: | |
70 | // UNEXPECTED VALUE |
|
70 | // UNEXPECTED VALUE | |
71 | spectral_matrix_regs->status = 0x03; // [0011] |
|
71 | spectral_matrix_regs->status = 0x03; // [0011] | |
72 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
72 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
73 | break; |
|
73 | break; | |
74 | case 1: |
|
74 | case 1: | |
75 | full_ring_node = current_ring_node_sm_f0->previous; |
|
75 | full_ring_node = current_ring_node_sm_f0->previous; | |
76 | full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time; |
|
76 | full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time; | |
77 | full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time; |
|
77 | full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time; | |
78 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
78 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
79 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
79 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; | |
80 | // if there are enough ring nodes ready, wake up an AVFx task |
|
80 | // if there are enough ring nodes ready, wake up an AVFx task | |
81 | nb_sm_f0 = nb_sm_f0 + 1; |
|
81 | nb_sm_f0 = nb_sm_f0 + 1; | |
82 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) |
|
82 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) | |
83 | { |
|
83 | { | |
84 | ring_node_for_averaging_sm_f0 = full_ring_node; |
|
84 | ring_node_for_averaging_sm_f0 = full_ring_node; | |
85 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
85 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
86 | { |
|
86 | { | |
87 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
87 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
88 | } |
|
88 | } | |
89 | nb_sm_f0 = 0; |
|
89 | nb_sm_f0 = 0; | |
90 | } |
|
90 | } | |
91 | spectral_matrix_regs->status = 0x01; // [0000 0001] |
|
91 | spectral_matrix_regs->status = 0x01; // [0000 0001] | |
92 | break; |
|
92 | break; | |
93 | case 2: |
|
93 | case 2: | |
94 | full_ring_node = current_ring_node_sm_f0->previous; |
|
94 | full_ring_node = current_ring_node_sm_f0->previous; | |
95 | full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time; |
|
95 | full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time; | |
96 | full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time; |
|
96 | full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time; | |
97 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
97 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
98 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
98 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
99 | // if there are enough ring nodes ready, wake up an AVFx task |
|
99 | // if there are enough ring nodes ready, wake up an AVFx task | |
100 | nb_sm_f0 = nb_sm_f0 + 1; |
|
100 | nb_sm_f0 = nb_sm_f0 + 1; | |
101 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) |
|
101 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) | |
102 | { |
|
102 | { | |
103 | ring_node_for_averaging_sm_f0 = full_ring_node; |
|
103 | ring_node_for_averaging_sm_f0 = full_ring_node; | |
104 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
104 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
106 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
107 | } |
|
107 | } | |
108 | nb_sm_f0 = 0; |
|
108 | nb_sm_f0 = 0; | |
109 | } |
|
109 | } | |
110 | spectral_matrix_regs->status = 0x02; // [0000 0010] |
|
110 | spectral_matrix_regs->status = 0x02; // [0000 0010] | |
111 | break; |
|
111 | break; | |
112 | } |
|
112 | } | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void spectral_matrices_isr_f1( unsigned char statusReg ) |
|
115 | void spectral_matrices_isr_f1( unsigned char statusReg ) | |
116 | { |
|
116 | { | |
117 | rtems_status_code status_code; |
|
117 | rtems_status_code status_code; | |
118 | unsigned char status; |
|
118 | unsigned char status; | |
119 | ring_node *full_ring_node; |
|
119 | ring_node *full_ring_node; | |
120 |
|
120 | |||
121 | status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits |
|
121 | status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits | |
122 |
|
122 | |||
123 | switch(status) |
|
123 | switch(status) | |
124 | { |
|
124 | { | |
125 | case 0: |
|
125 | case 0: | |
126 | break; |
|
126 | break; | |
127 | case 3: |
|
127 | case 3: | |
128 | // UNEXPECTED VALUE |
|
128 | // UNEXPECTED VALUE | |
129 | spectral_matrix_regs->status = 0xc0; // [1100] |
|
129 | spectral_matrix_regs->status = 0xc0; // [1100] | |
130 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
130 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
131 | break; |
|
131 | break; | |
132 | case 1: |
|
132 | case 1: | |
133 | full_ring_node = current_ring_node_sm_f1->previous; |
|
133 | full_ring_node = current_ring_node_sm_f1->previous; | |
134 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; |
|
134 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; | |
135 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; |
|
135 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; | |
136 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
136 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
137 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; |
|
137 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; | |
138 | // if there are enough ring nodes ready, wake up an AVFx task |
|
138 | // if there are enough ring nodes ready, wake up an AVFx task | |
139 | nb_sm_f1 = nb_sm_f1 + 1; |
|
139 | nb_sm_f1 = nb_sm_f1 + 1; | |
140 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) |
|
140 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) | |
141 | { |
|
141 | { | |
142 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
142 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
143 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
143 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
144 | { |
|
144 | { | |
145 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
145 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
146 | } |
|
146 | } | |
147 | nb_sm_f1 = 0; |
|
147 | nb_sm_f1 = 0; | |
148 | } |
|
148 | } | |
149 | spectral_matrix_regs->status = 0x04; // [0000 0100] |
|
149 | spectral_matrix_regs->status = 0x04; // [0000 0100] | |
150 | break; |
|
150 | break; | |
151 | case 2: |
|
151 | case 2: | |
152 | full_ring_node = current_ring_node_sm_f1->previous; |
|
152 | full_ring_node = current_ring_node_sm_f1->previous; | |
153 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; |
|
153 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; | |
154 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; |
|
154 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; | |
155 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
155 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
156 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
156 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
157 | // if there are enough ring nodes ready, wake up an AVFx task |
|
157 | // if there are enough ring nodes ready, wake up an AVFx task | |
158 | nb_sm_f1 = nb_sm_f1 + 1; |
|
158 | nb_sm_f1 = nb_sm_f1 + 1; | |
159 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) |
|
159 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) | |
160 | { |
|
160 | { | |
161 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
161 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
162 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
162 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
163 | { |
|
163 | { | |
164 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
164 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
165 | } |
|
165 | } | |
166 | nb_sm_f1 = 0; |
|
166 | nb_sm_f1 = 0; | |
167 | } |
|
167 | } | |
168 | spectral_matrix_regs->status = 0x08; // [1000 0000] |
|
168 | spectral_matrix_regs->status = 0x08; // [1000 0000] | |
169 | break; |
|
169 | break; | |
170 | } |
|
170 | } | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | void spectral_matrices_isr_f2( unsigned char statusReg ) |
|
173 | void spectral_matrices_isr_f2( unsigned char statusReg ) | |
174 | { |
|
174 | { | |
175 | unsigned char status; |
|
175 | unsigned char status; | |
176 | rtems_status_code status_code; |
|
176 | rtems_status_code status_code; | |
177 |
|
177 | |||
178 | status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits |
|
178 | status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits | |
179 |
|
179 | |||
180 | switch(status) |
|
180 | switch(status) | |
181 | { |
|
181 | { | |
182 | case 0: |
|
182 | case 0: | |
183 | break; |
|
183 | break; | |
184 | case 3: |
|
184 | case 3: | |
185 | // UNEXPECTED VALUE |
|
185 | // UNEXPECTED VALUE | |
186 | spectral_matrix_regs->status = 0x30; // [0011 0000] |
|
186 | spectral_matrix_regs->status = 0x30; // [0011 0000] | |
187 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
187 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
188 | break; |
|
188 | break; | |
189 | case 1: |
|
189 | case 1: | |
190 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
190 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
191 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
191 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
192 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; |
|
192 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; | |
193 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; |
|
193 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; | |
194 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; |
|
194 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; | |
195 | spectral_matrix_regs->status = 0x10; // [0001 0000] |
|
195 | spectral_matrix_regs->status = 0x10; // [0001 0000] | |
196 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
196 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
197 | { |
|
197 | { | |
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
199 | } |
|
199 | } | |
200 | break; |
|
200 | break; | |
201 | case 2: |
|
201 | case 2: | |
202 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
202 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
203 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
203 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
204 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; |
|
204 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; | |
205 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; |
|
205 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; | |
206 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
206 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
207 | spectral_matrix_regs->status = 0x20; // [0010 0000] |
|
207 | spectral_matrix_regs->status = 0x20; // [0010 0000] | |
208 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
208 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
209 | { |
|
209 | { | |
210 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
210 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
211 | } |
|
211 | } | |
212 | break; |
|
212 | break; | |
213 | } |
|
213 | } | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void spectral_matrix_isr_error_handler( unsigned char statusReg ) |
|
216 | void spectral_matrix_isr_error_handler( unsigned char statusReg ) | |
217 | { |
|
217 | { | |
218 | rtems_status_code status_code; |
|
218 | rtems_status_code status_code; | |
219 |
|
219 | |||
220 | if (statusReg & 0x7c0) // [0111 1100 0000] |
|
220 | if (statusReg & 0x7c0) // [0111 1100 0000] | |
221 | { |
|
221 | { | |
222 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); |
|
222 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0; |
|
225 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0; | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
228 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |
229 | { |
|
229 | { | |
230 | // STATUS REGISTER |
|
230 | // STATUS REGISTER | |
231 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
231 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) | |
232 | // 10 9 8 |
|
232 | // 10 9 8 | |
233 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
233 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 | |
234 | // 7 6 5 4 3 2 1 0 |
|
234 | // 7 6 5 4 3 2 1 0 | |
235 |
|
235 | |||
236 | unsigned char statusReg; |
|
236 | unsigned char statusReg; | |
237 |
|
237 | |||
238 | statusReg = spectral_matrix_regs->status; |
|
238 | statusReg = spectral_matrix_regs->status; | |
239 |
|
239 | |||
240 | spectral_matrices_isr_f0( statusReg ); |
|
240 | spectral_matrices_isr_f0( statusReg ); | |
241 |
|
241 | |||
242 | spectral_matrices_isr_f1( statusReg ); |
|
242 | spectral_matrices_isr_f1( statusReg ); | |
243 |
|
243 | |||
244 | spectral_matrices_isr_f2( statusReg ); |
|
244 | spectral_matrices_isr_f2( statusReg ); | |
245 |
|
245 | |||
246 | spectral_matrix_isr_error_handler( statusReg ); |
|
246 | spectral_matrix_isr_error_handler( statusReg ); | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
249 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) | |
250 | { |
|
250 | { | |
251 | rtems_status_code status_code; |
|
251 | rtems_status_code status_code; | |
252 |
|
252 | |||
253 | //*** |
|
253 | //*** | |
254 | // F0 |
|
254 | // F0 | |
255 | nb_sm_f0 = nb_sm_f0 + 1; |
|
255 | nb_sm_f0 = nb_sm_f0 + 1; | |
256 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) |
|
256 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) | |
257 | { |
|
257 | { | |
258 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; |
|
258 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; | |
259 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
259 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
260 | { |
|
260 | { | |
261 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
261 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
262 | } |
|
262 | } | |
263 | nb_sm_f0 = 0; |
|
263 | nb_sm_f0 = 0; | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | //*** |
|
266 | //*** | |
267 | // F1 |
|
267 | // F1 | |
268 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; |
|
268 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; | |
269 | if (nb_sm_f0_aux_f1 == 6) |
|
269 | if (nb_sm_f0_aux_f1 == 6) | |
270 | { |
|
270 | { | |
271 | nb_sm_f0_aux_f1 = 0; |
|
271 | nb_sm_f0_aux_f1 = 0; | |
272 | nb_sm_f1 = nb_sm_f1 + 1; |
|
272 | nb_sm_f1 = nb_sm_f1 + 1; | |
273 | } |
|
273 | } | |
274 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) |
|
274 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) | |
275 | { |
|
275 | { | |
276 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; |
|
276 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; | |
277 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
277 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
278 | { |
|
278 | { | |
279 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
279 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
280 | } |
|
280 | } | |
281 | nb_sm_f1 = 0; |
|
281 | nb_sm_f1 = 0; | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | //*** |
|
284 | //*** | |
285 | // F2 |
|
285 | // F2 | |
286 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; |
|
286 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; | |
287 | if (nb_sm_f0_aux_f2 == 96) |
|
287 | if (nb_sm_f0_aux_f2 == 96) | |
288 | { |
|
288 | { | |
289 | nb_sm_f0_aux_f2 = 0; |
|
289 | nb_sm_f0_aux_f2 = 0; | |
290 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
290 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; | |
291 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
291 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
292 | { |
|
292 | { | |
293 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
293 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
294 | } |
|
294 | } | |
295 | } |
|
295 | } | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 | //****************** |
|
298 | //****************** | |
299 | // Spectral Matrices |
|
299 | // Spectral Matrices | |
300 |
|
300 | |||
301 | void reset_nb_sm( void ) |
|
301 | void reset_nb_sm( void ) | |
302 | { |
|
302 | { | |
303 | nb_sm_f0 = 0; |
|
303 | nb_sm_f0 = 0; | |
304 | nb_sm_f0_aux_f1 = 0; |
|
304 | nb_sm_f0_aux_f1 = 0; | |
305 | nb_sm_f0_aux_f2 = 0; |
|
305 | nb_sm_f0_aux_f2 = 0; | |
306 |
|
306 | |||
307 | nb_sm_f1 = 0; |
|
307 | nb_sm_f1 = 0; | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void SM_init_rings( void ) |
|
310 | void SM_init_rings( void ) | |
311 | { |
|
311 | { | |
312 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); |
|
312 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); | |
313 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); |
|
313 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); | |
314 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); |
|
314 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); | |
315 |
|
315 | |||
316 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
316 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) | |
317 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
317 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) | |
318 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
318 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) | |
319 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) |
|
319 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) | |
320 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) |
|
320 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) | |
321 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) |
|
321 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) |
|
324 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) | |
325 | { |
|
325 | { | |
326 | unsigned char i; |
|
326 | unsigned char i; | |
327 |
|
327 | |||
328 | ring[ nbNodes - 1 ].next |
|
328 | ring[ nbNodes - 1 ].next | |
329 | = (ring_node_asm*) &ring[ 0 ]; |
|
329 | = (ring_node_asm*) &ring[ 0 ]; | |
330 |
|
330 | |||
331 | for(i=0; i<nbNodes-1; i++) |
|
331 | for(i=0; i<nbNodes-1; i++) | |
332 | { |
|
332 | { | |
333 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; |
|
333 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; | |
334 | } |
|
334 | } | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | void SM_reset_current_ring_nodes( void ) |
|
337 | void SM_reset_current_ring_nodes( void ) | |
338 | { |
|
338 | { | |
339 | current_ring_node_sm_f0 = sm_ring_f0[0].next; |
|
339 | current_ring_node_sm_f0 = sm_ring_f0[0].next; | |
340 | current_ring_node_sm_f1 = sm_ring_f1[0].next; |
|
340 | current_ring_node_sm_f1 = sm_ring_f1[0].next; | |
341 | current_ring_node_sm_f2 = sm_ring_f2[0].next; |
|
341 | current_ring_node_sm_f2 = sm_ring_f2[0].next; | |
342 |
|
342 | |||
343 | ring_node_for_averaging_sm_f0 = NULL; |
|
343 | ring_node_for_averaging_sm_f0 = NULL; | |
344 | ring_node_for_averaging_sm_f1 = NULL; |
|
344 | ring_node_for_averaging_sm_f1 = NULL; | |
345 | ring_node_for_averaging_sm_f2 = NULL; |
|
345 | ring_node_for_averaging_sm_f2 = NULL; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | //***************** |
|
348 | //***************** | |
349 | // Basic Parameters |
|
349 | // Basic Parameters | |
350 |
|
350 | |||
351 | void BP_init_header( bp_packet *packet, |
|
351 | void BP_init_header( bp_packet *packet, | |
352 | unsigned int apid, unsigned char sid, |
|
352 | unsigned int apid, unsigned char sid, | |
353 | unsigned int packetLength, unsigned char blkNr ) |
|
353 | unsigned int packetLength, unsigned char blkNr ) | |
354 | { |
|
354 | { | |
355 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
355 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
356 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
356 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
357 | packet->reserved = 0x00; |
|
357 | packet->reserved = 0x00; | |
358 | packet->userApplication = CCSDS_USER_APP; |
|
358 | packet->userApplication = CCSDS_USER_APP; | |
359 | packet->packetID[0] = (unsigned char) (apid >> 8); |
|
359 | packet->packetID[0] = (unsigned char) (apid >> 8); | |
360 | packet->packetID[1] = (unsigned char) (apid); |
|
360 | packet->packetID[1] = (unsigned char) (apid); | |
361 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
361 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
362 | packet->packetSequenceControl[1] = 0x00; |
|
362 | packet->packetSequenceControl[1] = 0x00; | |
363 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
363 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); | |
364 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
364 | packet->packetLength[1] = (unsigned char) (packetLength); | |
365 | // DATA FIELD HEADER |
|
365 | // DATA FIELD HEADER | |
366 | packet->spare1_pusVersion_spare2 = 0x10; |
|
366 | packet->spare1_pusVersion_spare2 = 0x10; | |
367 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
367 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
368 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
368 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
369 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
369 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
370 | packet->time[0] = 0x00; |
|
370 | packet->time[0] = 0x00; | |
371 | packet->time[1] = 0x00; |
|
371 | packet->time[1] = 0x00; | |
372 | packet->time[2] = 0x00; |
|
372 | packet->time[2] = 0x00; | |
373 | packet->time[3] = 0x00; |
|
373 | packet->time[3] = 0x00; | |
374 | packet->time[4] = 0x00; |
|
374 | packet->time[4] = 0x00; | |
375 | packet->time[5] = 0x00; |
|
375 | packet->time[5] = 0x00; | |
376 | // AUXILIARY DATA HEADER |
|
376 | // AUXILIARY DATA HEADER | |
377 | packet->sid = sid; |
|
377 | packet->sid = sid; | |
378 | packet->biaStatusInfo = 0x00; |
|
378 | packet->biaStatusInfo = 0x00; | |
379 | packet->sy_lfr_common_parameters_spare = 0x00; |
|
379 | packet->sy_lfr_common_parameters_spare = 0x00; | |
380 | packet->sy_lfr_common_parameters = 0x00; |
|
380 | packet->sy_lfr_common_parameters = 0x00; | |
381 | packet->acquisitionTime[0] = 0x00; |
|
381 | packet->acquisitionTime[0] = 0x00; | |
382 | packet->acquisitionTime[1] = 0x00; |
|
382 | packet->acquisitionTime[1] = 0x00; | |
383 | packet->acquisitionTime[2] = 0x00; |
|
383 | packet->acquisitionTime[2] = 0x00; | |
384 | packet->acquisitionTime[3] = 0x00; |
|
384 | packet->acquisitionTime[3] = 0x00; | |
385 | packet->acquisitionTime[4] = 0x00; |
|
385 | packet->acquisitionTime[4] = 0x00; | |
386 | packet->acquisitionTime[5] = 0x00; |
|
386 | packet->acquisitionTime[5] = 0x00; | |
387 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
387 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB | |
388 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
388 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | void BP_init_header_with_spare( bp_packet_with_spare *packet, |
|
391 | void BP_init_header_with_spare( bp_packet_with_spare *packet, | |
392 | unsigned int apid, unsigned char sid, |
|
392 | unsigned int apid, unsigned char sid, | |
393 | unsigned int packetLength , unsigned char blkNr) |
|
393 | unsigned int packetLength , unsigned char blkNr) | |
394 | { |
|
394 | { | |
395 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
395 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
396 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
396 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
397 | packet->reserved = 0x00; |
|
397 | packet->reserved = 0x00; | |
398 | packet->userApplication = CCSDS_USER_APP; |
|
398 | packet->userApplication = CCSDS_USER_APP; | |
399 | packet->packetID[0] = (unsigned char) (apid >> 8); |
|
399 | packet->packetID[0] = (unsigned char) (apid >> 8); | |
400 | packet->packetID[1] = (unsigned char) (apid); |
|
400 | packet->packetID[1] = (unsigned char) (apid); | |
401 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
401 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
402 | packet->packetSequenceControl[1] = 0x00; |
|
402 | packet->packetSequenceControl[1] = 0x00; | |
403 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
403 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); | |
404 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
404 | packet->packetLength[1] = (unsigned char) (packetLength); | |
405 | // DATA FIELD HEADER |
|
405 | // DATA FIELD HEADER | |
406 | packet->spare1_pusVersion_spare2 = 0x10; |
|
406 | packet->spare1_pusVersion_spare2 = 0x10; | |
407 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
407 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
408 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
408 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
409 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
409 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
410 | // AUXILIARY DATA HEADER |
|
410 | // AUXILIARY DATA HEADER | |
411 | packet->sid = sid; |
|
411 | packet->sid = sid; | |
412 | packet->biaStatusInfo = 0x00; |
|
412 | packet->biaStatusInfo = 0x00; | |
413 | packet->sy_lfr_common_parameters_spare = 0x00; |
|
413 | packet->sy_lfr_common_parameters_spare = 0x00; | |
414 | packet->sy_lfr_common_parameters = 0x00; |
|
414 | packet->sy_lfr_common_parameters = 0x00; | |
415 | packet->time[0] = 0x00; |
|
415 | packet->time[0] = 0x00; | |
416 | packet->time[0] = 0x00; |
|
416 | packet->time[0] = 0x00; | |
417 | packet->time[0] = 0x00; |
|
417 | packet->time[0] = 0x00; | |
418 | packet->time[0] = 0x00; |
|
418 | packet->time[0] = 0x00; | |
419 | packet->time[0] = 0x00; |
|
419 | packet->time[0] = 0x00; | |
420 | packet->time[0] = 0x00; |
|
420 | packet->time[0] = 0x00; | |
421 | packet->source_data_spare = 0x00; |
|
421 | packet->source_data_spare = 0x00; | |
422 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
422 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB | |
423 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
423 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
424 | } |
|
424 | } | |
425 |
|
425 | |||
426 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
426 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) | |
427 | { |
|
427 | { | |
428 | rtems_status_code status; |
|
428 | rtems_status_code status; | |
429 |
|
429 | |||
430 | // SET THE SEQUENCE_CNT PARAMETER |
|
430 | // SET THE SEQUENCE_CNT PARAMETER | |
431 | increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid ); |
|
431 | increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid ); | |
432 | // SEND PACKET |
|
432 | // SEND PACKET | |
433 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
433 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); | |
434 | if (status != RTEMS_SUCCESSFUL) |
|
434 | if (status != RTEMS_SUCCESSFUL) | |
435 | { |
|
435 | { | |
436 |
|
|
436 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) | |
437 | } |
|
437 | } | |
438 | } |
|
438 | } | |
439 |
|
439 | |||
440 | //****************** |
|
440 | //****************** | |
441 | // general functions |
|
441 | // general functions | |
442 |
|
442 | |||
443 | void reset_sm_status( void ) |
|
443 | void reset_sm_status( void ) | |
444 | { |
|
444 | { | |
445 | // error |
|
445 | // error | |
446 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- |
|
446 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- | |
447 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full |
|
447 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full | |
448 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- |
|
448 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- | |
449 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 |
|
449 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 | |
450 |
|
450 | |||
451 | spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111] |
|
451 | spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111] | |
452 | } |
|
452 | } | |
453 |
|
453 | |||
454 | void reset_spectral_matrix_regs( void ) |
|
454 | void reset_spectral_matrix_regs( void ) | |
455 | { |
|
455 | { | |
456 | /** This function resets the spectral matrices module registers. |
|
456 | /** This function resets the spectral matrices module registers. | |
457 | * |
|
457 | * | |
458 | * The registers affected by this function are located at the following offset addresses: |
|
458 | * The registers affected by this function are located at the following offset addresses: | |
459 | * |
|
459 | * | |
460 | * - 0x00 config |
|
460 | * - 0x00 config | |
461 | * - 0x04 status |
|
461 | * - 0x04 status | |
462 | * - 0x08 matrixF0_Address0 |
|
462 | * - 0x08 matrixF0_Address0 | |
463 | * - 0x10 matrixFO_Address1 |
|
463 | * - 0x10 matrixFO_Address1 | |
464 | * - 0x14 matrixF1_Address |
|
464 | * - 0x14 matrixF1_Address | |
465 | * - 0x18 matrixF2_Address |
|
465 | * - 0x18 matrixF2_Address | |
466 | * |
|
466 | * | |
467 | */ |
|
467 | */ | |
468 |
|
468 | |||
469 | set_sm_irq_onError( 0 ); |
|
469 | set_sm_irq_onError( 0 ); | |
470 |
|
470 | |||
471 | set_sm_irq_onNewMatrix( 0 ); |
|
471 | set_sm_irq_onNewMatrix( 0 ); | |
472 |
|
472 | |||
473 | reset_sm_status(); |
|
473 | reset_sm_status(); | |
474 |
|
474 | |||
475 | // F1 |
|
475 | // F1 | |
476 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; |
|
476 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; | |
477 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
477 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
478 | // F2 |
|
478 | // F2 | |
479 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; |
|
479 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; | |
480 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
480 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
481 | // F3 |
|
481 | // F3 | |
482 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; |
|
482 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; | |
483 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
483 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
484 |
|
484 | |||
485 | spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8 |
|
485 | spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8 | |
486 | } |
|
486 | } | |
487 |
|
487 | |||
488 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
488 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) | |
489 | { |
|
489 | { | |
490 | time[0] = timeInBuffer[0]; |
|
490 | time[0] = timeInBuffer[0]; | |
491 | time[1] = timeInBuffer[1]; |
|
491 | time[1] = timeInBuffer[1]; | |
492 | time[2] = timeInBuffer[2]; |
|
492 | time[2] = timeInBuffer[2]; | |
493 | time[3] = timeInBuffer[3]; |
|
493 | time[3] = timeInBuffer[3]; | |
494 | time[4] = timeInBuffer[6]; |
|
494 | time[4] = timeInBuffer[6]; | |
495 | time[5] = timeInBuffer[7]; |
|
495 | time[5] = timeInBuffer[7]; | |
496 | } |
|
496 | } | |
497 |
|
497 | |||
498 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) |
|
498 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) | |
499 | { |
|
499 | { | |
500 | unsigned long long int acquisitionTimeAslong; |
|
500 | unsigned long long int acquisitionTimeAslong; | |
501 | acquisitionTimeAslong = 0x00; |
|
501 | acquisitionTimeAslong = 0x00; | |
502 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
502 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit | |
503 | + ( (unsigned long long int) timePtr[1] << 32 ) |
|
503 | + ( (unsigned long long int) timePtr[1] << 32 ) | |
504 | + ( (unsigned long long int) timePtr[2] << 24 ) |
|
504 | + ( (unsigned long long int) timePtr[2] << 24 ) | |
505 | + ( (unsigned long long int) timePtr[3] << 16 ) |
|
505 | + ( (unsigned long long int) timePtr[3] << 16 ) | |
506 | + ( (unsigned long long int) timePtr[6] << 8 ) |
|
506 | + ( (unsigned long long int) timePtr[6] << 8 ) | |
507 | + ( (unsigned long long int) timePtr[7] ); |
|
507 | + ( (unsigned long long int) timePtr[7] ); | |
508 | return acquisitionTimeAslong; |
|
508 | return acquisitionTimeAslong; | |
509 | } |
|
509 | } | |
510 |
|
510 | |||
511 | unsigned char getSID( rtems_event_set event ) |
|
511 | unsigned char getSID( rtems_event_set event ) | |
512 | { |
|
512 | { | |
513 | unsigned char sid; |
|
513 | unsigned char sid; | |
514 |
|
514 | |||
515 | rtems_event_set eventSetBURST; |
|
515 | rtems_event_set eventSetBURST; | |
516 | rtems_event_set eventSetSBM; |
|
516 | rtems_event_set eventSetSBM; | |
517 |
|
517 | |||
518 | //****** |
|
518 | //****** | |
519 | // BURST |
|
519 | // BURST | |
520 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 |
|
520 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 | |
521 | | RTEMS_EVENT_BURST_BP1_F1 |
|
521 | | RTEMS_EVENT_BURST_BP1_F1 | |
522 | | RTEMS_EVENT_BURST_BP2_F0 |
|
522 | | RTEMS_EVENT_BURST_BP2_F0 | |
523 | | RTEMS_EVENT_BURST_BP2_F1; |
|
523 | | RTEMS_EVENT_BURST_BP2_F1; | |
524 |
|
524 | |||
525 | //**** |
|
525 | //**** | |
526 | // SBM |
|
526 | // SBM | |
527 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 |
|
527 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 | |
528 | | RTEMS_EVENT_SBM_BP1_F1 |
|
528 | | RTEMS_EVENT_SBM_BP1_F1 | |
529 | | RTEMS_EVENT_SBM_BP2_F0 |
|
529 | | RTEMS_EVENT_SBM_BP2_F0 | |
530 | | RTEMS_EVENT_SBM_BP2_F1; |
|
530 | | RTEMS_EVENT_SBM_BP2_F1; | |
531 |
|
531 | |||
532 | if (event & eventSetBURST) |
|
532 | if (event & eventSetBURST) | |
533 | { |
|
533 | { | |
534 | sid = SID_BURST_BP1_F0; |
|
534 | sid = SID_BURST_BP1_F0; | |
535 | } |
|
535 | } | |
536 | else if (event & eventSetSBM) |
|
536 | else if (event & eventSetSBM) | |
537 | { |
|
537 | { | |
538 | sid = SID_SBM1_BP1_F0; |
|
538 | sid = SID_SBM1_BP1_F0; | |
539 | } |
|
539 | } | |
540 | else |
|
540 | else | |
541 | { |
|
541 | { | |
542 | sid = 0; |
|
542 | sid = 0; | |
543 | } |
|
543 | } | |
544 |
|
544 | |||
545 | return sid; |
|
545 | return sid; | |
546 | } |
|
546 | } | |
547 |
|
547 | |||
548 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
548 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
549 | { |
|
549 | { | |
550 | unsigned int i; |
|
550 | unsigned int i; | |
551 | float re; |
|
551 | float re; | |
552 | float im; |
|
552 | float im; | |
553 |
|
553 | |||
554 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
554 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
555 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; |
|
555 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; | |
556 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; |
|
556 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; | |
557 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; |
|
557 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; | |
558 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; |
|
558 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; | |
559 | } |
|
559 | } | |
560 | } |
|
560 | } | |
561 |
|
561 | |||
562 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
562 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
563 | { |
|
563 | { | |
564 | unsigned int i; |
|
564 | unsigned int i; | |
565 | float re; |
|
565 | float re; | |
566 |
|
566 | |||
567 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
567 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
568 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; |
|
568 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; | |
569 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; |
|
569 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; | |
570 | } |
|
570 | } | |
571 | } |
|
571 | } | |
572 |
|
572 | |||
573 | void ASM_patch( float *inputASM, float *outputASM ) |
|
573 | void ASM_patch( float *inputASM, float *outputASM ) | |
574 | { |
|
574 | { | |
575 | extractReImVectors( inputASM, outputASM, 1); // b1b2 |
|
575 | extractReImVectors( inputASM, outputASM, 1); // b1b2 | |
576 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 |
|
576 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 | |
577 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 |
|
577 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 | |
578 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 |
|
578 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 | |
579 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 |
|
579 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 | |
580 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 |
|
580 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 | |
581 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 |
|
581 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 | |
582 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 |
|
582 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 | |
583 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 |
|
583 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 | |
584 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 |
|
584 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 | |
585 |
|
585 | |||
586 | copyReVectors(inputASM, outputASM, 0 ); // b1b1 |
|
586 | copyReVectors(inputASM, outputASM, 0 ); // b1b1 | |
587 | copyReVectors(inputASM, outputASM, 9 ); // b2b2 |
|
587 | copyReVectors(inputASM, outputASM, 9 ); // b2b2 | |
588 | copyReVectors(inputASM, outputASM, 16); // b3b3 |
|
588 | copyReVectors(inputASM, outputASM, 16); // b3b3 | |
589 | copyReVectors(inputASM, outputASM, 21); // e1e1 |
|
589 | copyReVectors(inputASM, outputASM, 21); // e1e1 | |
590 | copyReVectors(inputASM, outputASM, 24); // e2e2 |
|
590 | copyReVectors(inputASM, outputASM, 24); // e2e2 | |
591 | } |
|
591 | } | |
592 |
|
592 | |||
593 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
593 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
594 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
594 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) | |
595 | { |
|
595 | { | |
596 | //************* |
|
596 | //************* | |
597 | // input format |
|
597 | // input format | |
598 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] |
|
598 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] | |
599 | //************** |
|
599 | //************** | |
600 | // output format |
|
600 | // output format | |
601 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] |
|
601 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] | |
602 | //************ |
|
602 | //************ | |
603 | // compression |
|
603 | // compression | |
604 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM |
|
604 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM | |
605 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM |
|
605 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM | |
606 |
|
606 | |||
607 | int frequencyBin; |
|
607 | int frequencyBin; | |
608 | int asmComponent; |
|
608 | int asmComponent; | |
609 | int offsetASM; |
|
609 | int offsetASM; | |
610 | int offsetCompressed; |
|
610 | int offsetCompressed; | |
611 | int offsetFBin; |
|
611 | int offsetFBin; | |
612 | int fBinMask; |
|
612 | int fBinMask; | |
613 | int k; |
|
613 | int k; | |
614 |
|
614 | |||
615 | // BUILD DATA |
|
615 | // BUILD DATA | |
616 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
616 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
617 | { |
|
617 | { | |
618 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
618 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
619 | { |
|
619 | { | |
620 | offsetCompressed = // NO TIME OFFSET |
|
620 | offsetCompressed = // NO TIME OFFSET | |
621 | frequencyBin * NB_VALUES_PER_SM |
|
621 | frequencyBin * NB_VALUES_PER_SM | |
622 | + asmComponent; |
|
622 | + asmComponent; | |
623 | offsetASM = // NO TIME OFFSET |
|
623 | offsetASM = // NO TIME OFFSET | |
624 | asmComponent * NB_BINS_PER_SM |
|
624 | asmComponent * NB_BINS_PER_SM | |
625 | + ASMIndexStart |
|
625 | + ASMIndexStart | |
626 | + frequencyBin * nbBinsToAverage; |
|
626 | + frequencyBin * nbBinsToAverage; | |
627 | offsetFBin = ASMIndexStart |
|
627 | offsetFBin = ASMIndexStart | |
628 | + frequencyBin * nbBinsToAverage; |
|
628 | + frequencyBin * nbBinsToAverage; | |
629 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
629 | compressed_spec_mat[ offsetCompressed ] = 0; | |
630 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
630 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
631 | { |
|
631 | { | |
632 | fBinMask = getFBinMask( offsetFBin + k ); |
|
632 | fBinMask = getFBinMask( offsetFBin + k ); | |
633 | compressed_spec_mat[offsetCompressed ] = |
|
633 | compressed_spec_mat[offsetCompressed ] = | |
634 | ( compressed_spec_mat[ offsetCompressed ] |
|
634 | ( compressed_spec_mat[ offsetCompressed ] | |
635 | + averaged_spec_mat[ offsetASM + k ] * fBinMask ); |
|
635 | + averaged_spec_mat[ offsetASM + k ] * fBinMask ); | |
636 | } |
|
636 | } | |
637 | compressed_spec_mat[ offsetCompressed ] = |
|
637 | compressed_spec_mat[ offsetCompressed ] = | |
638 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
638 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
639 | } |
|
639 | } | |
640 | } |
|
640 | } | |
641 |
|
641 | |||
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 | int getFBinMask( int index ) |
|
644 | int getFBinMask( int index ) | |
645 | { |
|
645 | { | |
646 | unsigned int indexInChar; |
|
646 | unsigned int indexInChar; | |
647 | unsigned int indexInTheChar; |
|
647 | unsigned int indexInTheChar; | |
648 | int fbin; |
|
648 | int fbin; | |
649 |
|
649 | |||
650 | indexInChar = index >> 3; |
|
650 | indexInChar = index >> 3; | |
651 | indexInTheChar = index - indexInChar * 8; |
|
651 | indexInTheChar = index - indexInChar * 8; | |
652 |
|
652 | |||
653 | fbin = (int) ((parameter_dump_packet.sy_lfr_fbins_f0_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1); |
|
653 | fbin = (int) ((parameter_dump_packet.sy_lfr_fbins_f0_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1); | |
654 |
|
654 | |||
655 | return fbin; |
|
655 | return fbin; | |
656 | } |
|
656 | } | |
657 |
|
657 | |||
658 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) |
|
658 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) | |
659 | { |
|
659 | { | |
660 | unsigned char bin; |
|
660 | unsigned char bin; | |
661 | unsigned char kcoeff; |
|
661 | unsigned char kcoeff; | |
662 |
|
662 | |||
663 | for (bin=0; bin<nb_bins_norm; bin++) |
|
663 | for (bin=0; bin<nb_bins_norm; bin++) | |
664 | { |
|
664 | { | |
665 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
665 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
666 | { |
|
666 | { | |
667 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; |
|
667 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; | |
668 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; |
|
668 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; | |
669 | } |
|
669 | } | |
670 | } |
|
670 | } | |
671 | } |
|
671 | } |
@@ -1,1180 +1,1180 | |||||
1 | /** Functions and tasks related to TeleCommand handling. |
|
1 | /** Functions and tasks related to TeleCommand handling. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TeleCommands:\n |
|
6 | * A group of functions to handle TeleCommands:\n | |
7 | * action launching\n |
|
7 | * action launching\n | |
8 | * TC parsing\n |
|
8 | * TC parsing\n | |
9 | * ... |
|
9 | * ... | |
10 | * |
|
10 | * | |
11 | */ |
|
11 | */ | |
12 |
|
12 | |||
13 | #include "tc_handler.h" |
|
13 | #include "tc_handler.h" | |
14 | #include "math.h" |
|
14 | #include "math.h" | |
15 |
|
15 | |||
16 | //*********** |
|
16 | //*********** | |
17 | // RTEMS TASK |
|
17 | // RTEMS TASK | |
18 |
|
18 | |||
19 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | rtems_task actn_task( rtems_task_argument unused ) | |
20 | { |
|
20 | { | |
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
22 | * |
|
22 | * | |
23 | * @param unused is the starting argument of the RTEMS task |
|
23 | * @param unused is the starting argument of the RTEMS task | |
24 | * |
|
24 | * | |
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
26 | * on the incoming TeleCommand. |
|
26 | * on the incoming TeleCommand. | |
27 | * |
|
27 | * | |
28 | */ |
|
28 | */ | |
29 |
|
29 | |||
30 | int result; |
|
30 | int result; | |
31 | rtems_status_code status; // RTEMS status code |
|
31 | rtems_status_code status; // RTEMS status code | |
32 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | |
33 | size_t size; // size of the incoming TC packet |
|
33 | size_t size; // size of the incoming TC packet | |
34 | unsigned char subtype; // subtype of the current TC packet |
|
34 | unsigned char subtype; // subtype of the current TC packet | |
35 | unsigned char time[6]; |
|
35 | unsigned char time[6]; | |
36 | rtems_id queue_rcv_id; |
|
36 | rtems_id queue_rcv_id; | |
37 | rtems_id queue_snd_id; |
|
37 | rtems_id queue_snd_id; | |
38 |
|
38 | |||
39 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
40 | if (status != RTEMS_SUCCESSFUL) |
|
40 | if (status != RTEMS_SUCCESSFUL) | |
41 | { |
|
41 | { | |
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | status = get_message_queue_id_send( &queue_snd_id ); | |
46 | if (status != RTEMS_SUCCESSFUL) |
|
46 | if (status != RTEMS_SUCCESSFUL) | |
47 | { |
|
47 | { | |
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | result = LFR_SUCCESSFUL; |
|
51 | result = LFR_SUCCESSFUL; | |
52 | subtype = 0; // subtype of the current TC packet |
|
52 | subtype = 0; // subtype of the current TC packet | |
53 |
|
53 | |||
54 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | BOOT_PRINTF("in ACTN *** \n") | |
55 |
|
55 | |||
56 | while(1) |
|
56 | while(1) | |
57 | { |
|
57 | { | |
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
60 | getTime( time ); // set time to the current time |
|
60 | getTime( time ); // set time to the current time | |
61 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | if (status!=RTEMS_SUCCESSFUL) | |
62 | { |
|
62 | { | |
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
64 | } |
|
64 | } | |
65 | else |
|
65 | else | |
66 | { |
|
66 | { | |
67 | subtype = TC.serviceSubType; |
|
67 | subtype = TC.serviceSubType; | |
68 | switch(subtype) |
|
68 | switch(subtype) | |
69 | { |
|
69 | { | |
70 | case TC_SUBTYPE_RESET: |
|
70 | case TC_SUBTYPE_RESET: | |
71 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | result = action_reset( &TC, queue_snd_id, time ); | |
72 | close_action( &TC, result, queue_snd_id ); |
|
72 | close_action( &TC, result, queue_snd_id ); | |
73 | break; |
|
73 | break; | |
74 | case TC_SUBTYPE_LOAD_COMM: |
|
74 | case TC_SUBTYPE_LOAD_COMM: | |
75 | result = action_load_common_par( &TC ); |
|
75 | result = action_load_common_par( &TC ); | |
76 | close_action( &TC, result, queue_snd_id ); |
|
76 | close_action( &TC, result, queue_snd_id ); | |
77 | break; |
|
77 | break; | |
78 | case TC_SUBTYPE_LOAD_NORM: |
|
78 | case TC_SUBTYPE_LOAD_NORM: | |
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
80 | close_action( &TC, result, queue_snd_id ); |
|
80 | close_action( &TC, result, queue_snd_id ); | |
81 | break; |
|
81 | break; | |
82 | case TC_SUBTYPE_LOAD_BURST: |
|
82 | case TC_SUBTYPE_LOAD_BURST: | |
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
84 | close_action( &TC, result, queue_snd_id ); |
|
84 | close_action( &TC, result, queue_snd_id ); | |
85 | break; |
|
85 | break; | |
86 | case TC_SUBTYPE_LOAD_SBM1: |
|
86 | case TC_SUBTYPE_LOAD_SBM1: | |
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
88 | close_action( &TC, result, queue_snd_id ); |
|
88 | close_action( &TC, result, queue_snd_id ); | |
89 | break; |
|
89 | break; | |
90 | case TC_SUBTYPE_LOAD_SBM2: |
|
90 | case TC_SUBTYPE_LOAD_SBM2: | |
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
92 | close_action( &TC, result, queue_snd_id ); |
|
92 | close_action( &TC, result, queue_snd_id ); | |
93 | break; |
|
93 | break; | |
94 | case TC_SUBTYPE_DUMP: |
|
94 | case TC_SUBTYPE_DUMP: | |
95 | result = action_dump_par( &TC, queue_snd_id ); |
|
95 | result = action_dump_par( &TC, queue_snd_id ); | |
96 | close_action( &TC, result, queue_snd_id ); |
|
96 | close_action( &TC, result, queue_snd_id ); | |
97 | break; |
|
97 | break; | |
98 | case TC_SUBTYPE_ENTER: |
|
98 | case TC_SUBTYPE_ENTER: | |
99 | result = action_enter_mode( &TC, queue_snd_id ); |
|
99 | result = action_enter_mode( &TC, queue_snd_id ); | |
100 | close_action( &TC, result, queue_snd_id ); |
|
100 | close_action( &TC, result, queue_snd_id ); | |
101 | break; |
|
101 | break; | |
102 | case TC_SUBTYPE_UPDT_INFO: |
|
102 | case TC_SUBTYPE_UPDT_INFO: | |
103 | result = action_update_info( &TC, queue_snd_id ); |
|
103 | result = action_update_info( &TC, queue_snd_id ); | |
104 | close_action( &TC, result, queue_snd_id ); |
|
104 | close_action( &TC, result, queue_snd_id ); | |
105 | break; |
|
105 | break; | |
106 | case TC_SUBTYPE_EN_CAL: |
|
106 | case TC_SUBTYPE_EN_CAL: | |
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
108 | close_action( &TC, result, queue_snd_id ); |
|
108 | close_action( &TC, result, queue_snd_id ); | |
109 | break; |
|
109 | break; | |
110 | case TC_SUBTYPE_DIS_CAL: |
|
110 | case TC_SUBTYPE_DIS_CAL: | |
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
112 | close_action( &TC, result, queue_snd_id ); |
|
112 | close_action( &TC, result, queue_snd_id ); | |
113 | break; |
|
113 | break; | |
114 | case TC_SUBTYPE_LOAD_K: |
|
114 | case TC_SUBTYPE_LOAD_K: | |
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id ); |
|
116 | close_action( &TC, result, queue_snd_id ); | |
117 | break; |
|
117 | break; | |
118 | case TC_SUBTYPE_DUMP_K: |
|
118 | case TC_SUBTYPE_DUMP_K: | |
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
120 | close_action( &TC, result, queue_snd_id ); |
|
120 | close_action( &TC, result, queue_snd_id ); | |
121 | break; |
|
121 | break; | |
122 | case TC_SUBTYPE_LOAD_FBINS: |
|
122 | case TC_SUBTYPE_LOAD_FBINS: | |
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
124 | close_action( &TC, result, queue_snd_id ); |
|
124 | close_action( &TC, result, queue_snd_id ); | |
125 | break; |
|
125 | break; | |
126 | case TC_SUBTYPE_UPDT_TIME: |
|
126 | case TC_SUBTYPE_UPDT_TIME: | |
127 | result = action_update_time( &TC ); |
|
127 | result = action_update_time( &TC ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
128 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
129 | break; | |
130 | default: |
|
130 | default: | |
131 | break; |
|
131 | break; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | //*********** |
|
137 | //*********** | |
138 | // TC ACTIONS |
|
138 | // TC ACTIONS | |
139 |
|
139 | |||
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
141 | { |
|
141 | { | |
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
143 | * |
|
143 | * | |
144 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | * @param TC points to the TeleCommand packet that is being processed | |
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
146 | * |
|
146 | * | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 |
|
|
149 | PRINTF("this is the end!!!\n") | |
150 | exit(0); |
|
150 | exit(0); | |
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
152 | return LFR_DEFAULT; |
|
152 | return LFR_DEFAULT; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
156 | { |
|
156 | { | |
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
158 | * |
|
158 | * | |
159 | * @param TC points to the TeleCommand packet that is being processed |
|
159 | * @param TC points to the TeleCommand packet that is being processed | |
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
161 | * |
|
161 | * | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | rtems_status_code status; |
|
164 | rtems_status_code status; | |
165 | unsigned char requestedMode; |
|
165 | unsigned char requestedMode; | |
166 | unsigned int *transitionCoarseTime_ptr; |
|
166 | unsigned int *transitionCoarseTime_ptr; | |
167 | unsigned int transitionCoarseTime; |
|
167 | unsigned int transitionCoarseTime; | |
168 | unsigned char * bytePosPtr; |
|
168 | unsigned char * bytePosPtr; | |
169 |
|
169 | |||
170 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
170 | bytePosPtr = (unsigned char *) &TC->packetID; | |
171 |
|
171 | |||
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; | |
175 |
|
175 | |||
176 | status = check_mode_value( requestedMode ); |
|
176 | status = check_mode_value( requestedMode ); | |
177 |
|
177 | |||
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
179 | { |
|
179 | { | |
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
181 | } |
|
181 | } | |
182 | else // the mode value is valid, check the transition |
|
182 | else // the mode value is valid, check the transition | |
183 | { |
|
183 | { | |
184 | status = check_mode_transition(requestedMode); |
|
184 | status = check_mode_transition(requestedMode); | |
185 | if (status != LFR_SUCCESSFUL) |
|
185 | if (status != LFR_SUCCESSFUL) | |
186 | { |
|
186 | { | |
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
193 | { |
|
193 | { | |
194 | status = check_transition_date( transitionCoarseTime ); |
|
194 | status = check_transition_date( transitionCoarseTime ); | |
195 | if (status != LFR_SUCCESSFUL) |
|
195 | if (status != LFR_SUCCESSFUL) | |
196 | { |
|
196 | { | |
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") | |
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, | |
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, | |
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); | |
201 | } |
|
201 | } | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
205 | { |
|
205 | { | |
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
207 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
207 | status = enter_mode( requestedMode, transitionCoarseTime ); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | return status; |
|
210 | return status; | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
214 | { |
|
214 | { | |
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
216 | * |
|
216 | * | |
217 | * @param TC points to the TeleCommand packet that is being processed |
|
217 | * @param TC points to the TeleCommand packet that is being processed | |
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
219 | * |
|
219 | * | |
220 | * @return LFR directive status code: |
|
220 | * @return LFR directive status code: | |
221 | * - LFR_DEFAULT |
|
221 | * - LFR_DEFAULT | |
222 | * - LFR_SUCCESSFUL |
|
222 | * - LFR_SUCCESSFUL | |
223 | * |
|
223 | * | |
224 | */ |
|
224 | */ | |
225 |
|
225 | |||
226 | unsigned int val; |
|
226 | unsigned int val; | |
227 | int result; |
|
227 | int result; | |
228 | unsigned int status; |
|
228 | unsigned int status; | |
229 | unsigned char mode; |
|
229 | unsigned char mode; | |
230 | unsigned char * bytePosPtr; |
|
230 | unsigned char * bytePosPtr; | |
231 |
|
231 | |||
232 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
232 | bytePosPtr = (unsigned char *) &TC->packetID; | |
233 |
|
233 | |||
234 | // check LFR mode |
|
234 | // check LFR mode | |
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
236 | status = check_update_info_hk_lfr_mode( mode ); |
|
236 | status = check_update_info_hk_lfr_mode( mode ); | |
237 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
237 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
238 | { |
|
238 | { | |
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
240 | status = check_update_info_hk_tds_mode( mode ); |
|
240 | status = check_update_info_hk_tds_mode( mode ); | |
241 | } |
|
241 | } | |
242 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
242 | if (status == LFR_SUCCESSFUL) // check THR mode | |
243 | { |
|
243 | { | |
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
245 | status = check_update_info_hk_thr_mode( mode ); |
|
245 | status = check_update_info_hk_thr_mode( mode ); | |
246 | } |
|
246 | } | |
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
248 | { |
|
248 | { | |
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
251 | val++; |
|
251 | val++; | |
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | // pa_bia_status_info |
|
256 | // pa_bia_status_info | |
257 | // => pa_bia_mode_mux_set 3 bits |
|
257 | // => pa_bia_mode_mux_set 3 bits | |
258 | // => pa_bia_mode_hv_enabled 1 bit |
|
258 | // => pa_bia_mode_hv_enabled 1 bit | |
259 | // => pa_bia_mode_bias1_enabled 1 bit |
|
259 | // => pa_bia_mode_bias1_enabled 1 bit | |
260 | // => pa_bia_mode_bias2_enabled 1 bit |
|
260 | // => pa_bia_mode_bias2_enabled 1 bit | |
261 | // => pa_bia_mode_bias3_enabled 1 bit |
|
261 | // => pa_bia_mode_bias3_enabled 1 bit | |
262 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
262 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
263 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] |
|
263 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] | |
264 | pa_bia_status_info = pa_bia_status_info |
|
264 | pa_bia_status_info = pa_bia_status_info | |
265 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); |
|
265 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); | |
266 |
|
266 | |||
267 | result = status; |
|
267 | result = status; | |
268 |
|
268 | |||
269 | return result; |
|
269 | return result; | |
270 | } |
|
270 | } | |
271 |
|
271 | |||
272 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
272 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
273 | { |
|
273 | { | |
274 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
274 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
275 | * |
|
275 | * | |
276 | * @param TC points to the TeleCommand packet that is being processed |
|
276 | * @param TC points to the TeleCommand packet that is being processed | |
277 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
277 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
278 | * |
|
278 | * | |
279 | */ |
|
279 | */ | |
280 |
|
280 | |||
281 | int result; |
|
281 | int result; | |
282 |
|
282 | |||
283 | result = LFR_DEFAULT; |
|
283 | result = LFR_DEFAULT; | |
284 |
|
284 | |||
285 | setCalibration( true ); |
|
285 | setCalibration( true ); | |
286 |
|
286 | |||
287 | result = LFR_SUCCESSFUL; |
|
287 | result = LFR_SUCCESSFUL; | |
288 |
|
288 | |||
289 | return result; |
|
289 | return result; | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
292 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
293 | { |
|
293 | { | |
294 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
294 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
295 | * |
|
295 | * | |
296 | * @param TC points to the TeleCommand packet that is being processed |
|
296 | * @param TC points to the TeleCommand packet that is being processed | |
297 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
297 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
298 | * |
|
298 | * | |
299 | */ |
|
299 | */ | |
300 |
|
300 | |||
301 | int result; |
|
301 | int result; | |
302 |
|
302 | |||
303 | result = LFR_DEFAULT; |
|
303 | result = LFR_DEFAULT; | |
304 |
|
304 | |||
305 | setCalibration( false ); |
|
305 | setCalibration( false ); | |
306 |
|
306 | |||
307 | result = LFR_SUCCESSFUL; |
|
307 | result = LFR_SUCCESSFUL; | |
308 |
|
308 | |||
309 | return result; |
|
309 | return result; | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
312 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
313 | { |
|
313 | { | |
314 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
314 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
315 | * |
|
315 | * | |
316 | * @param TC points to the TeleCommand packet that is being processed |
|
316 | * @param TC points to the TeleCommand packet that is being processed | |
317 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
317 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
318 | * |
|
318 | * | |
319 | * @return LFR_SUCCESSFUL |
|
319 | * @return LFR_SUCCESSFUL | |
320 | * |
|
320 | * | |
321 | */ |
|
321 | */ | |
322 |
|
322 | |||
323 | unsigned int val; |
|
323 | unsigned int val; | |
324 |
|
324 | |||
325 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
325 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
326 | + (TC->dataAndCRC[1] << 16) |
|
326 | + (TC->dataAndCRC[1] << 16) | |
327 | + (TC->dataAndCRC[2] << 8) |
|
327 | + (TC->dataAndCRC[2] << 8) | |
328 | + TC->dataAndCRC[3]; |
|
328 | + TC->dataAndCRC[3]; | |
329 |
|
329 | |||
330 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
330 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
331 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
331 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
332 | val++; |
|
332 | val++; | |
333 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
333 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
334 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
334 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
335 |
|
335 | |||
336 | return LFR_SUCCESSFUL; |
|
336 | return LFR_SUCCESSFUL; | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | //******************* |
|
339 | //******************* | |
340 | // ENTERING THE MODES |
|
340 | // ENTERING THE MODES | |
341 | int check_mode_value( unsigned char requestedMode ) |
|
341 | int check_mode_value( unsigned char requestedMode ) | |
342 | { |
|
342 | { | |
343 | int status; |
|
343 | int status; | |
344 |
|
344 | |||
345 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
345 | if ( (requestedMode != LFR_MODE_STANDBY) | |
346 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
346 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
347 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
347 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
348 | { |
|
348 | { | |
349 | status = LFR_DEFAULT; |
|
349 | status = LFR_DEFAULT; | |
350 | } |
|
350 | } | |
351 | else |
|
351 | else | |
352 | { |
|
352 | { | |
353 | status = LFR_SUCCESSFUL; |
|
353 | status = LFR_SUCCESSFUL; | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | return status; |
|
356 | return status; | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | int check_mode_transition( unsigned char requestedMode ) |
|
359 | int check_mode_transition( unsigned char requestedMode ) | |
360 | { |
|
360 | { | |
361 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
361 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
362 | * |
|
362 | * | |
363 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
363 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
364 | * |
|
364 | * | |
365 | * @return LFR directive status codes: |
|
365 | * @return LFR directive status codes: | |
366 | * - LFR_SUCCESSFUL - the transition is authorized |
|
366 | * - LFR_SUCCESSFUL - the transition is authorized | |
367 | * - LFR_DEFAULT - the transition is not authorized |
|
367 | * - LFR_DEFAULT - the transition is not authorized | |
368 | * |
|
368 | * | |
369 | */ |
|
369 | */ | |
370 |
|
370 | |||
371 | int status; |
|
371 | int status; | |
372 |
|
372 | |||
373 | switch (requestedMode) |
|
373 | switch (requestedMode) | |
374 | { |
|
374 | { | |
375 | case LFR_MODE_STANDBY: |
|
375 | case LFR_MODE_STANDBY: | |
376 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
376 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
377 | status = LFR_DEFAULT; |
|
377 | status = LFR_DEFAULT; | |
378 | } |
|
378 | } | |
379 | else |
|
379 | else | |
380 | { |
|
380 | { | |
381 | status = LFR_SUCCESSFUL; |
|
381 | status = LFR_SUCCESSFUL; | |
382 | } |
|
382 | } | |
383 | break; |
|
383 | break; | |
384 | case LFR_MODE_NORMAL: |
|
384 | case LFR_MODE_NORMAL: | |
385 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
385 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
386 | status = LFR_DEFAULT; |
|
386 | status = LFR_DEFAULT; | |
387 | } |
|
387 | } | |
388 | else { |
|
388 | else { | |
389 | status = LFR_SUCCESSFUL; |
|
389 | status = LFR_SUCCESSFUL; | |
390 | } |
|
390 | } | |
391 | break; |
|
391 | break; | |
392 | case LFR_MODE_BURST: |
|
392 | case LFR_MODE_BURST: | |
393 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
393 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
394 | status = LFR_DEFAULT; |
|
394 | status = LFR_DEFAULT; | |
395 | } |
|
395 | } | |
396 | else { |
|
396 | else { | |
397 | status = LFR_SUCCESSFUL; |
|
397 | status = LFR_SUCCESSFUL; | |
398 | } |
|
398 | } | |
399 | break; |
|
399 | break; | |
400 | case LFR_MODE_SBM1: |
|
400 | case LFR_MODE_SBM1: | |
401 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
401 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
402 | status = LFR_DEFAULT; |
|
402 | status = LFR_DEFAULT; | |
403 | } |
|
403 | } | |
404 | else { |
|
404 | else { | |
405 | status = LFR_SUCCESSFUL; |
|
405 | status = LFR_SUCCESSFUL; | |
406 | } |
|
406 | } | |
407 | break; |
|
407 | break; | |
408 | case LFR_MODE_SBM2: |
|
408 | case LFR_MODE_SBM2: | |
409 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
409 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
410 | status = LFR_DEFAULT; |
|
410 | status = LFR_DEFAULT; | |
411 | } |
|
411 | } | |
412 | else { |
|
412 | else { | |
413 | status = LFR_SUCCESSFUL; |
|
413 | status = LFR_SUCCESSFUL; | |
414 | } |
|
414 | } | |
415 | break; |
|
415 | break; | |
416 | default: |
|
416 | default: | |
417 | status = LFR_DEFAULT; |
|
417 | status = LFR_DEFAULT; | |
418 | break; |
|
418 | break; | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | return status; |
|
421 | return status; | |
422 | } |
|
422 | } | |
423 |
|
423 | |||
424 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
424 | int check_transition_date( unsigned int transitionCoarseTime ) | |
425 | { |
|
425 | { | |
426 | int status; |
|
426 | int status; | |
427 | unsigned int localCoarseTime; |
|
427 | unsigned int localCoarseTime; | |
428 | unsigned int deltaCoarseTime; |
|
428 | unsigned int deltaCoarseTime; | |
429 |
|
429 | |||
430 | status = LFR_SUCCESSFUL; |
|
430 | status = LFR_SUCCESSFUL; | |
431 |
|
431 | |||
432 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
432 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
433 | { |
|
433 | { | |
434 | status = LFR_SUCCESSFUL; |
|
434 | status = LFR_SUCCESSFUL; | |
435 | } |
|
435 | } | |
436 | else |
|
436 | else | |
437 | { |
|
437 | { | |
438 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
438 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
439 |
|
439 | |||
440 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) |
|
440 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) | |
441 |
|
441 | |||
442 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
442 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
443 | { |
|
443 | { | |
444 | status = LFR_DEFAULT; |
|
444 | status = LFR_DEFAULT; | |
445 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") |
|
445 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | if (status == LFR_SUCCESSFUL) |
|
448 | if (status == LFR_SUCCESSFUL) | |
449 | { |
|
449 | { | |
450 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
450 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
451 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
451 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
452 | { |
|
452 | { | |
453 | status = LFR_DEFAULT; |
|
453 | status = LFR_DEFAULT; | |
454 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
454 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
455 | } |
|
455 | } | |
456 | } |
|
456 | } | |
457 | } |
|
457 | } | |
458 |
|
458 | |||
459 | return status; |
|
459 | return status; | |
460 | } |
|
460 | } | |
461 |
|
461 | |||
462 | int stop_current_mode( void ) |
|
462 | int stop_current_mode( void ) | |
463 | { |
|
463 | { | |
464 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
464 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
465 | * |
|
465 | * | |
466 | * @return RTEMS directive status codes: |
|
466 | * @return RTEMS directive status codes: | |
467 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
467 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
468 | * - RTEMS_INVALID_ID - task id invalid |
|
468 | * - RTEMS_INVALID_ID - task id invalid | |
469 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
469 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
470 | * |
|
470 | * | |
471 | */ |
|
471 | */ | |
472 |
|
472 | |||
473 | rtems_status_code status; |
|
473 | rtems_status_code status; | |
474 |
|
474 | |||
475 | status = RTEMS_SUCCESSFUL; |
|
475 | status = RTEMS_SUCCESSFUL; | |
476 |
|
476 | |||
477 | // (1) mask interruptions |
|
477 | // (1) mask interruptions | |
478 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
478 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
479 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
479 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
480 |
|
480 | |||
481 | // (2) reset waveform picker registers |
|
481 | // (2) reset waveform picker registers | |
482 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
482 | reset_wfp_burst_enable(); // reset burst and enable bits | |
483 | reset_wfp_status(); // reset all the status bits |
|
483 | reset_wfp_status(); // reset all the status bits | |
484 |
|
484 | |||
485 | // (3) reset spectral matrices registers |
|
485 | // (3) reset spectral matrices registers | |
486 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
486 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
487 | reset_sm_status(); |
|
487 | reset_sm_status(); | |
488 |
|
488 | |||
489 | // reset lfr VHDL module |
|
489 | // reset lfr VHDL module | |
490 | reset_lfr(); |
|
490 | reset_lfr(); | |
491 |
|
491 | |||
492 | reset_extractSWF(); // reset the extractSWF flag to false |
|
492 | reset_extractSWF(); // reset the extractSWF flag to false | |
493 |
|
493 | |||
494 | // (4) clear interruptions |
|
494 | // (4) clear interruptions | |
495 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
495 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
496 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
496 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
497 |
|
497 | |||
498 | // <Spectral Matrices simulator> |
|
498 | // <Spectral Matrices simulator> | |
499 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
499 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator | |
500 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
500 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
501 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
501 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator | |
502 | // </Spectral Matrices simulator> |
|
502 | // </Spectral Matrices simulator> | |
503 |
|
503 | |||
504 | // suspend several tasks |
|
504 | // suspend several tasks | |
505 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
505 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
506 | status = suspend_science_tasks(); |
|
506 | status = suspend_science_tasks(); | |
507 | } |
|
507 | } | |
508 |
|
508 | |||
509 | if (status != RTEMS_SUCCESSFUL) |
|
509 | if (status != RTEMS_SUCCESSFUL) | |
510 | { |
|
510 | { | |
511 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
511 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
512 | } |
|
512 | } | |
513 |
|
513 | |||
514 | return status; |
|
514 | return status; | |
515 | } |
|
515 | } | |
516 |
|
516 | |||
517 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
517 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) | |
518 | { |
|
518 | { | |
519 | /** This function is launched after a mode transition validation. |
|
519 | /** This function is launched after a mode transition validation. | |
520 | * |
|
520 | * | |
521 | * @param mode is the mode in which LFR will be put. |
|
521 | * @param mode is the mode in which LFR will be put. | |
522 | * |
|
522 | * | |
523 | * @return RTEMS directive status codes: |
|
523 | * @return RTEMS directive status codes: | |
524 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
524 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully | |
525 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
525 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully | |
526 | * |
|
526 | * | |
527 | */ |
|
527 | */ | |
528 |
|
528 | |||
529 | rtems_status_code status; |
|
529 | rtems_status_code status; | |
530 |
|
530 | |||
531 | //********************** |
|
531 | //********************** | |
532 | // STOP THE CURRENT MODE |
|
532 | // STOP THE CURRENT MODE | |
533 | status = stop_current_mode(); |
|
533 | status = stop_current_mode(); | |
534 | if (status != RTEMS_SUCCESSFUL) |
|
534 | if (status != RTEMS_SUCCESSFUL) | |
535 | { |
|
535 | { | |
536 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
536 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) | |
537 | } |
|
537 | } | |
538 |
|
538 | |||
539 | //************************* |
|
539 | //************************* | |
540 | // ENTER THE REQUESTED MODE |
|
540 | // ENTER THE REQUESTED MODE | |
541 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped |
|
541 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped | |
542 | { |
|
542 | { | |
543 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
543 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) | |
544 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
544 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) | |
545 | { |
|
545 | { | |
546 | #ifdef PRINT_TASK_STATISTICS |
|
546 | #ifdef PRINT_TASK_STATISTICS | |
547 | rtems_cpu_usage_reset(); |
|
547 | rtems_cpu_usage_reset(); | |
548 | #endif |
|
548 | #endif | |
549 | status = restart_science_tasks( mode ); |
|
549 | status = restart_science_tasks( mode ); | |
550 | if (status == RTEMS_SUCCESSFUL) |
|
550 | if (status == RTEMS_SUCCESSFUL) | |
551 | { |
|
551 | { | |
552 | launch_spectral_matrix( ); |
|
552 | launch_spectral_matrix( ); | |
553 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
553 | launch_waveform_picker( mode, transitionCoarseTime ); | |
554 | } |
|
554 | } | |
555 | } |
|
555 | } | |
556 | else if ( mode == LFR_MODE_STANDBY ) |
|
556 | else if ( mode == LFR_MODE_STANDBY ) | |
557 | { |
|
557 | { | |
558 | #ifdef PRINT_TASK_STATISTICS |
|
558 | #ifdef PRINT_TASK_STATISTICS | |
559 | rtems_cpu_usage_report(); |
|
559 | rtems_cpu_usage_report(); | |
560 | #endif |
|
560 | #endif | |
561 |
|
561 | |||
562 | #ifdef PRINT_STACK_REPORT |
|
562 | #ifdef PRINT_STACK_REPORT | |
563 | PRINTF("stack report selected\n") |
|
563 | PRINTF("stack report selected\n") | |
564 | rtems_stack_checker_report_usage(); |
|
564 | rtems_stack_checker_report_usage(); | |
565 | #endif |
|
565 | #endif | |
566 | } |
|
566 | } | |
567 | else |
|
567 | else | |
568 | { |
|
568 | { | |
569 | status = RTEMS_UNSATISFIED; |
|
569 | status = RTEMS_UNSATISFIED; | |
570 | } |
|
570 | } | |
571 | } |
|
571 | } | |
572 |
|
572 | |||
573 | if (status != RTEMS_SUCCESSFUL) |
|
573 | if (status != RTEMS_SUCCESSFUL) | |
574 | { |
|
574 | { | |
575 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
575 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) | |
576 | status = RTEMS_UNSATISFIED; |
|
576 | status = RTEMS_UNSATISFIED; | |
577 | } |
|
577 | } | |
578 |
|
578 | |||
579 | return status; |
|
579 | return status; | |
580 | } |
|
580 | } | |
581 |
|
581 | |||
582 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
582 | int restart_science_tasks(unsigned char lfrRequestedMode ) | |
583 | { |
|
583 | { | |
584 | /** This function is used to restart all science tasks. |
|
584 | /** This function is used to restart all science tasks. | |
585 | * |
|
585 | * | |
586 | * @return RTEMS directive status codes: |
|
586 | * @return RTEMS directive status codes: | |
587 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
587 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
588 | * - RTEMS_INVALID_ID - task id invalid |
|
588 | * - RTEMS_INVALID_ID - task id invalid | |
589 | * - RTEMS_INCORRECT_STATE - task never started |
|
589 | * - RTEMS_INCORRECT_STATE - task never started | |
590 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
590 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
591 | * |
|
591 | * | |
592 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
592 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
593 | * |
|
593 | * | |
594 | */ |
|
594 | */ | |
595 |
|
595 | |||
596 | rtems_status_code status[10]; |
|
596 | rtems_status_code status[10]; | |
597 | rtems_status_code ret; |
|
597 | rtems_status_code ret; | |
598 |
|
598 | |||
599 | ret = RTEMS_SUCCESSFUL; |
|
599 | ret = RTEMS_SUCCESSFUL; | |
600 |
|
600 | |||
601 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
601 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
602 | if (status[0] != RTEMS_SUCCESSFUL) |
|
602 | if (status[0] != RTEMS_SUCCESSFUL) | |
603 | { |
|
603 | { | |
604 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
604 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
605 | } |
|
605 | } | |
606 |
|
606 | |||
607 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
607 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
608 | if (status[1] != RTEMS_SUCCESSFUL) |
|
608 | if (status[1] != RTEMS_SUCCESSFUL) | |
609 | { |
|
609 | { | |
610 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
610 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
611 | } |
|
611 | } | |
612 |
|
612 | |||
613 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
613 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
614 | if (status[2] != RTEMS_SUCCESSFUL) |
|
614 | if (status[2] != RTEMS_SUCCESSFUL) | |
615 | { |
|
615 | { | |
616 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
616 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
617 | } |
|
617 | } | |
618 |
|
618 | |||
619 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
619 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
620 | if (status[3] != RTEMS_SUCCESSFUL) |
|
620 | if (status[3] != RTEMS_SUCCESSFUL) | |
621 | { |
|
621 | { | |
622 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
622 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
623 | } |
|
623 | } | |
624 |
|
624 | |||
625 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
625 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
626 | if (status[4] != RTEMS_SUCCESSFUL) |
|
626 | if (status[4] != RTEMS_SUCCESSFUL) | |
627 | { |
|
627 | { | |
628 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
628 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
629 | } |
|
629 | } | |
630 |
|
630 | |||
631 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
631 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
632 | if (status[5] != RTEMS_SUCCESSFUL) |
|
632 | if (status[5] != RTEMS_SUCCESSFUL) | |
633 | { |
|
633 | { | |
634 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
634 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
635 | } |
|
635 | } | |
636 |
|
636 | |||
637 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
637 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
638 | if (status[6] != RTEMS_SUCCESSFUL) |
|
638 | if (status[6] != RTEMS_SUCCESSFUL) | |
639 | { |
|
639 | { | |
640 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
640 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
641 | } |
|
641 | } | |
642 |
|
642 | |||
643 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
643 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
644 | if (status[7] != RTEMS_SUCCESSFUL) |
|
644 | if (status[7] != RTEMS_SUCCESSFUL) | |
645 | { |
|
645 | { | |
646 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
646 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
647 | } |
|
647 | } | |
648 |
|
648 | |||
649 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
649 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
650 | if (status[8] != RTEMS_SUCCESSFUL) |
|
650 | if (status[8] != RTEMS_SUCCESSFUL) | |
651 | { |
|
651 | { | |
652 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
652 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
653 | } |
|
653 | } | |
654 |
|
654 | |||
655 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
655 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
656 | if (status[9] != RTEMS_SUCCESSFUL) |
|
656 | if (status[9] != RTEMS_SUCCESSFUL) | |
657 | { |
|
657 | { | |
658 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
658 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
659 | } |
|
659 | } | |
660 |
|
660 | |||
661 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
661 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
662 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
662 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
663 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
663 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
664 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
664 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
665 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
665 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
666 | { |
|
666 | { | |
667 | ret = RTEMS_UNSATISFIED; |
|
667 | ret = RTEMS_UNSATISFIED; | |
668 | } |
|
668 | } | |
669 |
|
669 | |||
670 | return ret; |
|
670 | return ret; | |
671 | } |
|
671 | } | |
672 |
|
672 | |||
673 | int suspend_science_tasks() |
|
673 | int suspend_science_tasks() | |
674 | { |
|
674 | { | |
675 | /** This function suspends the science tasks. |
|
675 | /** This function suspends the science tasks. | |
676 | * |
|
676 | * | |
677 | * @return RTEMS directive status codes: |
|
677 | * @return RTEMS directive status codes: | |
678 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
678 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
679 | * - RTEMS_INVALID_ID - task id invalid |
|
679 | * - RTEMS_INVALID_ID - task id invalid | |
680 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
680 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
681 | * |
|
681 | * | |
682 | */ |
|
682 | */ | |
683 |
|
683 | |||
684 | rtems_status_code status; |
|
684 | rtems_status_code status; | |
685 |
|
685 | |||
686 |
|
|
686 | PRINTF("in suspend_science_tasks\n") | |
687 |
|
687 | |||
688 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
688 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
690 | { |
|
690 | { | |
691 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
691 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
692 | } |
|
692 | } | |
693 | else |
|
693 | else | |
694 | { |
|
694 | { | |
695 | status = RTEMS_SUCCESSFUL; |
|
695 | status = RTEMS_SUCCESSFUL; | |
696 | } |
|
696 | } | |
697 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
697 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
698 | { |
|
698 | { | |
699 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
699 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
700 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
700 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
701 | { |
|
701 | { | |
702 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
702 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
703 | } |
|
703 | } | |
704 | else |
|
704 | else | |
705 | { |
|
705 | { | |
706 | status = RTEMS_SUCCESSFUL; |
|
706 | status = RTEMS_SUCCESSFUL; | |
707 | } |
|
707 | } | |
708 | } |
|
708 | } | |
709 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
709 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
710 | { |
|
710 | { | |
711 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
711 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
712 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
712 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
713 | { |
|
713 | { | |
714 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
714 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
715 | } |
|
715 | } | |
716 | else |
|
716 | else | |
717 | { |
|
717 | { | |
718 | status = RTEMS_SUCCESSFUL; |
|
718 | status = RTEMS_SUCCESSFUL; | |
719 | } |
|
719 | } | |
720 | } |
|
720 | } | |
721 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
721 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
722 | { |
|
722 | { | |
723 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
723 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
724 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
724 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
725 | { |
|
725 | { | |
726 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
726 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
727 | } |
|
727 | } | |
728 | else |
|
728 | else | |
729 | { |
|
729 | { | |
730 | status = RTEMS_SUCCESSFUL; |
|
730 | status = RTEMS_SUCCESSFUL; | |
731 | } |
|
731 | } | |
732 | } |
|
732 | } | |
733 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
733 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
734 | { |
|
734 | { | |
735 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
735 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
736 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
736 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
737 | { |
|
737 | { | |
738 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
738 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
739 | } |
|
739 | } | |
740 | else |
|
740 | else | |
741 | { |
|
741 | { | |
742 | status = RTEMS_SUCCESSFUL; |
|
742 | status = RTEMS_SUCCESSFUL; | |
743 | } |
|
743 | } | |
744 | } |
|
744 | } | |
745 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
745 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
746 | { |
|
746 | { | |
747 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
747 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
748 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
748 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
749 | { |
|
749 | { | |
750 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
750 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
751 | } |
|
751 | } | |
752 | else |
|
752 | else | |
753 | { |
|
753 | { | |
754 | status = RTEMS_SUCCESSFUL; |
|
754 | status = RTEMS_SUCCESSFUL; | |
755 | } |
|
755 | } | |
756 | } |
|
756 | } | |
757 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
757 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
758 | { |
|
758 | { | |
759 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
759 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
760 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
760 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
761 | { |
|
761 | { | |
762 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
762 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
763 | } |
|
763 | } | |
764 | else |
|
764 | else | |
765 | { |
|
765 | { | |
766 | status = RTEMS_SUCCESSFUL; |
|
766 | status = RTEMS_SUCCESSFUL; | |
767 | } |
|
767 | } | |
768 | } |
|
768 | } | |
769 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
769 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
770 | { |
|
770 | { | |
771 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
771 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
772 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
772 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
773 | { |
|
773 | { | |
774 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
774 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
775 | } |
|
775 | } | |
776 | else |
|
776 | else | |
777 | { |
|
777 | { | |
778 | status = RTEMS_SUCCESSFUL; |
|
778 | status = RTEMS_SUCCESSFUL; | |
779 | } |
|
779 | } | |
780 | } |
|
780 | } | |
781 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
781 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
782 | { |
|
782 | { | |
783 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
783 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
784 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
784 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
785 | { |
|
785 | { | |
786 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
786 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
787 | } |
|
787 | } | |
788 | else |
|
788 | else | |
789 | { |
|
789 | { | |
790 | status = RTEMS_SUCCESSFUL; |
|
790 | status = RTEMS_SUCCESSFUL; | |
791 | } |
|
791 | } | |
792 | } |
|
792 | } | |
793 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
793 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
794 | { |
|
794 | { | |
795 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
795 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
796 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
796 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
797 | { |
|
797 | { | |
798 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
798 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
799 | } |
|
799 | } | |
800 | else |
|
800 | else | |
801 | { |
|
801 | { | |
802 | status = RTEMS_SUCCESSFUL; |
|
802 | status = RTEMS_SUCCESSFUL; | |
803 | } |
|
803 | } | |
804 | } |
|
804 | } | |
805 |
|
805 | |||
806 | return status; |
|
806 | return status; | |
807 | } |
|
807 | } | |
808 |
|
808 | |||
809 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
809 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
810 | { |
|
810 | { | |
811 | WFP_reset_current_ring_nodes(); |
|
811 | WFP_reset_current_ring_nodes(); | |
812 |
|
812 | |||
813 | reset_waveform_picker_regs(); |
|
813 | reset_waveform_picker_regs(); | |
814 |
|
814 | |||
815 | set_wfp_burst_enable_register( mode ); |
|
815 | set_wfp_burst_enable_register( mode ); | |
816 |
|
816 | |||
817 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
817 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
818 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
818 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
819 |
|
819 | |||
820 | if (transitionCoarseTime == 0) |
|
820 | if (transitionCoarseTime == 0) | |
821 | { |
|
821 | { | |
822 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
822 | waveform_picker_regs->start_date = time_management_regs->coarse_time; | |
823 | } |
|
823 | } | |
824 | else |
|
824 | else | |
825 | { |
|
825 | { | |
826 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
826 | waveform_picker_regs->start_date = transitionCoarseTime; | |
827 | } |
|
827 | } | |
828 |
|
828 | |||
829 | } |
|
829 | } | |
830 |
|
830 | |||
831 | void launch_spectral_matrix( void ) |
|
831 | void launch_spectral_matrix( void ) | |
832 | { |
|
832 | { | |
833 | SM_reset_current_ring_nodes(); |
|
833 | SM_reset_current_ring_nodes(); | |
834 |
|
834 | |||
835 | reset_spectral_matrix_regs(); |
|
835 | reset_spectral_matrix_regs(); | |
836 |
|
836 | |||
837 | reset_nb_sm(); |
|
837 | reset_nb_sm(); | |
838 |
|
838 | |||
839 | set_sm_irq_onNewMatrix( 1 ); |
|
839 | set_sm_irq_onNewMatrix( 1 ); | |
840 |
|
840 | |||
841 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
841 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
842 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
842 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
843 |
|
843 | |||
844 | } |
|
844 | } | |
845 |
|
845 | |||
846 | void launch_spectral_matrix_simu( void ) |
|
846 | void launch_spectral_matrix_simu( void ) | |
847 | { |
|
847 | { | |
848 | SM_reset_current_ring_nodes(); |
|
848 | SM_reset_current_ring_nodes(); | |
849 | reset_spectral_matrix_regs(); |
|
849 | reset_spectral_matrix_regs(); | |
850 | reset_nb_sm(); |
|
850 | reset_nb_sm(); | |
851 |
|
851 | |||
852 | // Spectral Matrices simulator |
|
852 | // Spectral Matrices simulator | |
853 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
853 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
854 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
854 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
855 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
855 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
856 | } |
|
856 | } | |
857 |
|
857 | |||
858 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
858 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
859 | { |
|
859 | { | |
860 | if (value == 1) |
|
860 | if (value == 1) | |
861 | { |
|
861 | { | |
862 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
862 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
863 | } |
|
863 | } | |
864 | else |
|
864 | else | |
865 | { |
|
865 | { | |
866 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
866 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
867 | } |
|
867 | } | |
868 | } |
|
868 | } | |
869 |
|
869 | |||
870 | void set_sm_irq_onError( unsigned char value ) |
|
870 | void set_sm_irq_onError( unsigned char value ) | |
871 | { |
|
871 | { | |
872 | if (value == 1) |
|
872 | if (value == 1) | |
873 | { |
|
873 | { | |
874 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
874 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
875 | } |
|
875 | } | |
876 | else |
|
876 | else | |
877 | { |
|
877 | { | |
878 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
878 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
879 | } |
|
879 | } | |
880 | } |
|
880 | } | |
881 |
|
881 | |||
882 | //***************************** |
|
882 | //***************************** | |
883 | // CONFIGURE CALIBRATION SIGNAL |
|
883 | // CONFIGURE CALIBRATION SIGNAL | |
884 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
884 | void setCalibrationPrescaler( unsigned int prescaler ) | |
885 | { |
|
885 | { | |
886 | // prescaling of the master clock (25 MHz) |
|
886 | // prescaling of the master clock (25 MHz) | |
887 | // master clock is divided by 2^prescaler |
|
887 | // master clock is divided by 2^prescaler | |
888 | time_management_regs->calPrescaler = prescaler; |
|
888 | time_management_regs->calPrescaler = prescaler; | |
889 | } |
|
889 | } | |
890 |
|
890 | |||
891 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
891 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
892 | { |
|
892 | { | |
893 | // division of the prescaled clock by the division factor |
|
893 | // division of the prescaled clock by the division factor | |
894 | time_management_regs->calDivisor = divisionFactor; |
|
894 | time_management_regs->calDivisor = divisionFactor; | |
895 | } |
|
895 | } | |
896 |
|
896 | |||
897 | void setCalibrationData( void ){ |
|
897 | void setCalibrationData( void ){ | |
898 | unsigned int k; |
|
898 | unsigned int k; | |
899 | unsigned short data; |
|
899 | unsigned short data; | |
900 | float val; |
|
900 | float val; | |
901 | float f0; |
|
901 | float f0; | |
902 | float f1; |
|
902 | float f1; | |
903 | float fs; |
|
903 | float fs; | |
904 | float Ts; |
|
904 | float Ts; | |
905 | float scaleFactor; |
|
905 | float scaleFactor; | |
906 |
|
906 | |||
907 | f0 = 625; |
|
907 | f0 = 625; | |
908 | f1 = 10000; |
|
908 | f1 = 10000; | |
909 | fs = 160256.410; |
|
909 | fs = 160256.410; | |
910 | Ts = 1. / fs; |
|
910 | Ts = 1. / fs; | |
911 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
911 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
912 |
|
912 | |||
913 | time_management_regs->calDataPtr = 0x00; |
|
913 | time_management_regs->calDataPtr = 0x00; | |
914 |
|
914 | |||
915 | // build the signal for the SCM calibration |
|
915 | // build the signal for the SCM calibration | |
916 | for (k=0; k<256; k++) |
|
916 | for (k=0; k<256; k++) | |
917 | { |
|
917 | { | |
918 | val = sin( 2 * pi * f0 * k * Ts ) |
|
918 | val = sin( 2 * pi * f0 * k * Ts ) | |
919 | + sin( 2 * pi * f1 * k * Ts ); |
|
919 | + sin( 2 * pi * f1 * k * Ts ); | |
920 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
920 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
921 | time_management_regs->calData = data & 0xfff; |
|
921 | time_management_regs->calData = data & 0xfff; | |
922 | } |
|
922 | } | |
923 | } |
|
923 | } | |
924 |
|
924 | |||
925 | void setCalibrationDataInterleaved( void ){ |
|
925 | void setCalibrationDataInterleaved( void ){ | |
926 | unsigned int k; |
|
926 | unsigned int k; | |
927 | float val; |
|
927 | float val; | |
928 | float f0; |
|
928 | float f0; | |
929 | float f1; |
|
929 | float f1; | |
930 | float fs; |
|
930 | float fs; | |
931 | float Ts; |
|
931 | float Ts; | |
932 | unsigned short data[384]; |
|
932 | unsigned short data[384]; | |
933 | unsigned char *dataPtr; |
|
933 | unsigned char *dataPtr; | |
934 |
|
934 | |||
935 | f0 = 625; |
|
935 | f0 = 625; | |
936 | f1 = 10000; |
|
936 | f1 = 10000; | |
937 | fs = 240384.615; |
|
937 | fs = 240384.615; | |
938 | Ts = 1. / fs; |
|
938 | Ts = 1. / fs; | |
939 |
|
939 | |||
940 | time_management_regs->calDataPtr = 0x00; |
|
940 | time_management_regs->calDataPtr = 0x00; | |
941 |
|
941 | |||
942 | // build the signal for the SCM calibration |
|
942 | // build the signal for the SCM calibration | |
943 | for (k=0; k<384; k++) |
|
943 | for (k=0; k<384; k++) | |
944 | { |
|
944 | { | |
945 | val = sin( 2 * pi * f0 * k * Ts ) |
|
945 | val = sin( 2 * pi * f0 * k * Ts ) | |
946 | + sin( 2 * pi * f1 * k * Ts ); |
|
946 | + sin( 2 * pi * f1 * k * Ts ); | |
947 | data[k] = (unsigned short) (val * 512 + 2048); |
|
947 | data[k] = (unsigned short) (val * 512 + 2048); | |
948 | } |
|
948 | } | |
949 |
|
949 | |||
950 | // write the signal in interleaved mode |
|
950 | // write the signal in interleaved mode | |
951 | for (k=0; k<128; k++) |
|
951 | for (k=0; k<128; k++) | |
952 | { |
|
952 | { | |
953 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
953 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
954 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
954 | time_management_regs->calData = (data[k*3] & 0xfff) | |
955 | + ( (dataPtr[0] & 0x3f) << 12); |
|
955 | + ( (dataPtr[0] & 0x3f) << 12); | |
956 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
956 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
957 | + ( (dataPtr[1] & 0x3f) << 12); |
|
957 | + ( (dataPtr[1] & 0x3f) << 12); | |
958 | } |
|
958 | } | |
959 | } |
|
959 | } | |
960 |
|
960 | |||
961 | void setCalibrationReload( bool state) |
|
961 | void setCalibrationReload( bool state) | |
962 | { |
|
962 | { | |
963 | if (state == true) |
|
963 | if (state == true) | |
964 | { |
|
964 | { | |
965 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
965 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
966 | } |
|
966 | } | |
967 | else |
|
967 | else | |
968 | { |
|
968 | { | |
969 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
969 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
970 | } |
|
970 | } | |
971 | } |
|
971 | } | |
972 |
|
972 | |||
973 | void setCalibrationEnable( bool state ) |
|
973 | void setCalibrationEnable( bool state ) | |
974 | { |
|
974 | { | |
975 | // this bit drives the multiplexer |
|
975 | // this bit drives the multiplexer | |
976 | if (state == true) |
|
976 | if (state == true) | |
977 | { |
|
977 | { | |
978 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
978 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
979 | } |
|
979 | } | |
980 | else |
|
980 | else | |
981 | { |
|
981 | { | |
982 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
982 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
983 | } |
|
983 | } | |
984 | } |
|
984 | } | |
985 |
|
985 | |||
986 | void setCalibrationInterleaved( bool state ) |
|
986 | void setCalibrationInterleaved( bool state ) | |
987 | { |
|
987 | { | |
988 | // this bit drives the multiplexer |
|
988 | // this bit drives the multiplexer | |
989 | if (state == true) |
|
989 | if (state == true) | |
990 | { |
|
990 | { | |
991 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
991 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
992 | } |
|
992 | } | |
993 | else |
|
993 | else | |
994 | { |
|
994 | { | |
995 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
995 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
996 | } |
|
996 | } | |
997 | } |
|
997 | } | |
998 |
|
998 | |||
999 | void setCalibration( bool state ) |
|
999 | void setCalibration( bool state ) | |
1000 | { |
|
1000 | { | |
1001 | if (state == true) |
|
1001 | if (state == true) | |
1002 | { |
|
1002 | { | |
1003 | setCalibrationEnable( true ); |
|
1003 | setCalibrationEnable( true ); | |
1004 | setCalibrationReload( false ); |
|
1004 | setCalibrationReload( false ); | |
1005 | set_hk_lfr_calib_enable( true ); |
|
1005 | set_hk_lfr_calib_enable( true ); | |
1006 | } |
|
1006 | } | |
1007 | else |
|
1007 | else | |
1008 | { |
|
1008 | { | |
1009 | setCalibrationEnable( false ); |
|
1009 | setCalibrationEnable( false ); | |
1010 | setCalibrationReload( true ); |
|
1010 | setCalibrationReload( true ); | |
1011 | set_hk_lfr_calib_enable( false ); |
|
1011 | set_hk_lfr_calib_enable( false ); | |
1012 | } |
|
1012 | } | |
1013 | } |
|
1013 | } | |
1014 |
|
1014 | |||
1015 | void configureCalibration( bool interleaved ) |
|
1015 | void configureCalibration( bool interleaved ) | |
1016 | { |
|
1016 | { | |
1017 | setCalibration( false ); |
|
1017 | setCalibration( false ); | |
1018 | if ( interleaved == true ) |
|
1018 | if ( interleaved == true ) | |
1019 | { |
|
1019 | { | |
1020 | setCalibrationInterleaved( true ); |
|
1020 | setCalibrationInterleaved( true ); | |
1021 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1021 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1022 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1022 | setCalibrationDivisor( 26 ); // => 240 384 | |
1023 | setCalibrationDataInterleaved(); |
|
1023 | setCalibrationDataInterleaved(); | |
1024 | } |
|
1024 | } | |
1025 | else |
|
1025 | else | |
1026 | { |
|
1026 | { | |
1027 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1027 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1028 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1028 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1029 | setCalibrationData(); |
|
1029 | setCalibrationData(); | |
1030 | } |
|
1030 | } | |
1031 | } |
|
1031 | } | |
1032 |
|
1032 | |||
1033 | //**************** |
|
1033 | //**************** | |
1034 | // CLOSING ACTIONS |
|
1034 | // CLOSING ACTIONS | |
1035 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1035 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1036 | { |
|
1036 | { | |
1037 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1037 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1038 | * |
|
1038 | * | |
1039 | * @param TC points to the TC being processed |
|
1039 | * @param TC points to the TC being processed | |
1040 | * @param time is the time used to date the TC execution |
|
1040 | * @param time is the time used to date the TC execution | |
1041 | * |
|
1041 | * | |
1042 | */ |
|
1042 | */ | |
1043 |
|
1043 | |||
1044 | unsigned int val; |
|
1044 | unsigned int val; | |
1045 |
|
1045 | |||
1046 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1046 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1047 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1047 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1048 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1048 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1049 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1049 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1050 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1050 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1051 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1051 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1052 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1052 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1053 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1053 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1054 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1054 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1055 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1055 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1056 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1056 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1057 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1057 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1058 |
|
1058 | |||
1059 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1059 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1060 | val++; |
|
1060 | val++; | |
1061 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1061 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1062 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1062 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1063 | } |
|
1063 | } | |
1064 |
|
1064 | |||
1065 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1065 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1066 | { |
|
1066 | { | |
1067 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1067 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1068 | * |
|
1068 | * | |
1069 | * @param TC points to the TC being processed |
|
1069 | * @param TC points to the TC being processed | |
1070 | * @param time is the time used to date the TC rejection |
|
1070 | * @param time is the time used to date the TC rejection | |
1071 | * |
|
1071 | * | |
1072 | */ |
|
1072 | */ | |
1073 |
|
1073 | |||
1074 | unsigned int val; |
|
1074 | unsigned int val; | |
1075 |
|
1075 | |||
1076 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1076 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1077 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1077 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1078 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1078 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1079 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1079 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1080 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1080 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1081 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1081 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1082 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1082 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1083 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1083 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1084 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1084 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1085 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1085 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1086 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1086 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1087 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1087 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1088 |
|
1088 | |||
1089 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1089 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1090 | val++; |
|
1090 | val++; | |
1091 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1091 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1092 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1092 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1093 | } |
|
1093 | } | |
1094 |
|
1094 | |||
1095 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1095 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1096 | { |
|
1096 | { | |
1097 | /** This function is the last step of the TC execution workflow. |
|
1097 | /** This function is the last step of the TC execution workflow. | |
1098 | * |
|
1098 | * | |
1099 | * @param TC points to the TC being processed |
|
1099 | * @param TC points to the TC being processed | |
1100 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1100 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1101 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1101 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1102 | * @param time is the time used to date the TC execution |
|
1102 | * @param time is the time used to date the TC execution | |
1103 | * |
|
1103 | * | |
1104 | */ |
|
1104 | */ | |
1105 |
|
1105 | |||
1106 | unsigned char requestedMode; |
|
1106 | unsigned char requestedMode; | |
1107 |
|
1107 | |||
1108 | if (result == LFR_SUCCESSFUL) |
|
1108 | if (result == LFR_SUCCESSFUL) | |
1109 | { |
|
1109 | { | |
1110 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1110 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1111 | & |
|
1111 | & | |
1112 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1112 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1113 | ) |
|
1113 | ) | |
1114 | { |
|
1114 | { | |
1115 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1115 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1116 | } |
|
1116 | } | |
1117 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1117 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1118 | { |
|
1118 | { | |
1119 | //********************************** |
|
1119 | //********************************** | |
1120 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1120 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1121 | requestedMode = TC->dataAndCRC[1]; |
|
1121 | requestedMode = TC->dataAndCRC[1]; | |
1122 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1122 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1123 | updateLFRCurrentMode(); |
|
1123 | updateLFRCurrentMode(); | |
1124 | } |
|
1124 | } | |
1125 | } |
|
1125 | } | |
1126 | else if (result == LFR_EXE_ERROR) |
|
1126 | else if (result == LFR_EXE_ERROR) | |
1127 | { |
|
1127 | { | |
1128 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1128 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1129 | } |
|
1129 | } | |
1130 | } |
|
1130 | } | |
1131 |
|
1131 | |||
1132 | //*************************** |
|
1132 | //*************************** | |
1133 | // Interrupt Service Routines |
|
1133 | // Interrupt Service Routines | |
1134 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1134 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1135 | { |
|
1135 | { | |
1136 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1136 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1137 |
|
|
1137 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1138 | } |
|
1138 | } | |
1139 | } |
|
1139 | } | |
1140 |
|
1140 | |||
1141 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1141 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1142 | { |
|
1142 | { | |
1143 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1143 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1144 |
|
|
1144 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1145 | } |
|
1145 | } | |
1146 | } |
|
1146 | } | |
1147 |
|
1147 | |||
1148 | //**************** |
|
1148 | //**************** | |
1149 | // OTHER FUNCTIONS |
|
1149 | // OTHER FUNCTIONS | |
1150 | void updateLFRCurrentMode() |
|
1150 | void updateLFRCurrentMode() | |
1151 | { |
|
1151 | { | |
1152 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1152 | /** This function updates the value of the global variable lfrCurrentMode. | |
1153 | * |
|
1153 | * | |
1154 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1154 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1155 | * |
|
1155 | * | |
1156 | */ |
|
1156 | */ | |
1157 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1157 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1158 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
1158 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
1159 | } |
|
1159 | } | |
1160 |
|
1160 | |||
1161 | void set_lfr_soft_reset( unsigned char value ) |
|
1161 | void set_lfr_soft_reset( unsigned char value ) | |
1162 | { |
|
1162 | { | |
1163 | if (value == 1) |
|
1163 | if (value == 1) | |
1164 | { |
|
1164 | { | |
1165 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1165 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1166 | } |
|
1166 | } | |
1167 | else |
|
1167 | else | |
1168 | { |
|
1168 | { | |
1169 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1169 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1170 | } |
|
1170 | } | |
1171 | } |
|
1171 | } | |
1172 |
|
1172 | |||
1173 | void reset_lfr( void ) |
|
1173 | void reset_lfr( void ) | |
1174 | { |
|
1174 | { | |
1175 | set_lfr_soft_reset( 1 ); |
|
1175 | set_lfr_soft_reset( 1 ); | |
1176 |
|
1176 | |||
1177 | set_lfr_soft_reset( 0 ); |
|
1177 | set_lfr_soft_reset( 0 ); | |
1178 |
|
1178 | |||
1179 | set_hk_lfr_sc_potential_flag( true ); |
|
1179 | set_hk_lfr_sc_potential_flag( true ); | |
1180 | } |
|
1180 | } |
@@ -1,1175 +1,1201 | |||||
1 | /** Functions to load and dump parameters in the LFR registers. |
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
9 | * TC_LFR_LOAD_BURST_PAR\n |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
12 | * |
|
12 | * | |
13 | */ |
|
13 | */ | |
14 |
|
14 | |||
15 | #include "tc_load_dump_parameters.h" |
|
15 | #include "tc_load_dump_parameters.h" | |
16 |
|
16 | |||
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; | |
19 | ring_node kcoefficient_node_1; |
|
19 | ring_node kcoefficient_node_1; | |
20 | ring_node kcoefficient_node_2; |
|
20 | ring_node kcoefficient_node_2; | |
21 |
|
21 | |||
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
23 | { |
|
23 | { | |
24 | /** This function updates the LFR registers with the incoming common parameters. |
|
24 | /** This function updates the LFR registers with the incoming common parameters. | |
25 | * |
|
25 | * | |
26 | * @param TC points to the TeleCommand packet that is being processed |
|
26 | * @param TC points to the TeleCommand packet that is being processed | |
27 | * |
|
27 | * | |
28 | * |
|
28 | * | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; | |
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; | |
33 | set_wfp_data_shaping( ); |
|
33 | set_wfp_data_shaping( ); | |
34 | return LFR_SUCCESSFUL; |
|
34 | return LFR_SUCCESSFUL; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
38 | { |
|
38 | { | |
39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
39 | /** This function updates the LFR registers with the incoming normal parameters. | |
40 | * |
|
40 | * | |
41 | * @param TC points to the TeleCommand packet that is being processed |
|
41 | * @param TC points to the TeleCommand packet that is being processed | |
42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
42 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
43 | * |
|
43 | * | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | int result; |
|
46 | int result; | |
47 | int flag; |
|
47 | int flag; | |
48 | rtems_status_code status; |
|
48 | rtems_status_code status; | |
49 |
|
49 | |||
50 | flag = LFR_SUCCESSFUL; |
|
50 | flag = LFR_SUCCESSFUL; | |
51 |
|
51 | |||
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || | |
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { | |
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
55 | flag = LFR_DEFAULT; |
|
55 | flag = LFR_DEFAULT; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
58 | // CHECK THE PARAMETERS SET CONSISTENCY | |
59 | if (flag == LFR_SUCCESSFUL) |
|
59 | if (flag == LFR_SUCCESSFUL) | |
60 | { |
|
60 | { | |
61 | flag = check_common_par_consistency( TC, queue_id ); |
|
61 | flag = check_common_par_consistency( TC, queue_id ); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT | |
65 | if (flag == LFR_SUCCESSFUL) |
|
65 | if (flag == LFR_SUCCESSFUL) | |
66 | { |
|
66 | { | |
67 | result = set_sy_lfr_n_swf_l( TC ); |
|
67 | result = set_sy_lfr_n_swf_l( TC ); | |
68 | result = set_sy_lfr_n_swf_p( TC ); |
|
68 | result = set_sy_lfr_n_swf_p( TC ); | |
69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
69 | result = set_sy_lfr_n_bp_p0( TC ); | |
70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
70 | result = set_sy_lfr_n_bp_p1( TC ); | |
71 | result = set_sy_lfr_n_asm_p( TC ); |
|
71 | result = set_sy_lfr_n_asm_p( TC ); | |
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | return flag; |
|
75 | return flag; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
79 | { |
|
79 | { | |
80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
80 | /** This function updates the LFR registers with the incoming burst parameters. | |
81 | * |
|
81 | * | |
82 | * @param TC points to the TeleCommand packet that is being processed |
|
82 | * @param TC points to the TeleCommand packet that is being processed | |
83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
83 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
84 | * |
|
84 | * | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | int flag; |
|
87 | int flag; | |
88 | rtems_status_code status; |
|
88 | rtems_status_code status; | |
89 | unsigned char sy_lfr_b_bp_p0; |
|
89 | unsigned char sy_lfr_b_bp_p0; | |
90 | unsigned char sy_lfr_b_bp_p1; |
|
90 | unsigned char sy_lfr_b_bp_p1; | |
91 | float aux; |
|
91 | float aux; | |
92 |
|
92 | |||
93 | flag = LFR_SUCCESSFUL; |
|
93 | flag = LFR_SUCCESSFUL; | |
94 |
|
94 | |||
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
97 | flag = LFR_DEFAULT; |
|
97 | flag = LFR_DEFAULT; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
102 |
|
102 | |||
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value |
|
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value | |
104 | if (flag == LFR_SUCCESSFUL) |
|
104 | if (flag == LFR_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) | |
107 | { |
|
107 | { | |
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); | |
109 | flag = WRONG_APP_DATA; |
|
109 | flag = WRONG_APP_DATA; | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value |
|
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value | |
113 | if (flag == LFR_SUCCESSFUL) |
|
113 | if (flag == LFR_SUCCESSFUL) | |
114 | { |
|
114 | { | |
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) | |
116 | { |
|
116 | { | |
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); | |
118 | flag = WRONG_APP_DATA; |
|
118 | flag = WRONG_APP_DATA; | |
119 | } |
|
119 | } | |
120 | } |
|
120 | } | |
121 | //**************************************************************** |
|
121 | //**************************************************************** | |
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 | |
123 | if (flag == LFR_SUCCESSFUL) |
|
123 | if (flag == LFR_SUCCESSFUL) | |
124 | { |
|
124 | { | |
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); | |
128 | if (aux > FLOAT_EQUAL_ZERO) |
|
128 | if (aux > FLOAT_EQUAL_ZERO) | |
129 | { |
|
129 | { | |
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); | |
131 | flag = LFR_DEFAULT; |
|
131 | flag = LFR_DEFAULT; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // SET THE PARAMETERS |
|
135 | // SET THE PARAMETERS | |
136 | if (flag == LFR_SUCCESSFUL) |
|
136 | if (flag == LFR_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
138 | flag = set_sy_lfr_b_bp_p0( TC ); | |
139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
139 | flag = set_sy_lfr_b_bp_p1( TC ); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | return flag; |
|
142 | return flag; | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
146 | { |
|
146 | { | |
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
148 | * |
|
148 | * | |
149 | * @param TC points to the TeleCommand packet that is being processed |
|
149 | * @param TC points to the TeleCommand packet that is being processed | |
150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
150 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
151 | * |
|
151 | * | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | int flag; |
|
154 | int flag; | |
155 | rtems_status_code status; |
|
155 | rtems_status_code status; | |
156 | unsigned char sy_lfr_s1_bp_p0; |
|
156 | unsigned char sy_lfr_s1_bp_p0; | |
157 | unsigned char sy_lfr_s1_bp_p1; |
|
157 | unsigned char sy_lfr_s1_bp_p1; | |
158 | float aux; |
|
158 | float aux; | |
159 |
|
159 | |||
160 | flag = LFR_SUCCESSFUL; |
|
160 | flag = LFR_SUCCESSFUL; | |
161 |
|
161 | |||
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
164 | flag = LFR_DEFAULT; |
|
164 | flag = LFR_DEFAULT; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
169 |
|
169 | |||
170 | // sy_lfr_s1_bp_p0 |
|
170 | // sy_lfr_s1_bp_p0 | |
171 | if (flag == LFR_SUCCESSFUL) |
|
171 | if (flag == LFR_SUCCESSFUL) | |
172 | { |
|
172 | { | |
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) | |
174 | { |
|
174 | { | |
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); | |
176 | flag = WRONG_APP_DATA; |
|
176 | flag = WRONG_APP_DATA; | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 | // sy_lfr_s1_bp_p1 |
|
179 | // sy_lfr_s1_bp_p1 | |
180 | if (flag == LFR_SUCCESSFUL) |
|
180 | if (flag == LFR_SUCCESSFUL) | |
181 | { |
|
181 | { | |
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) | |
183 | { |
|
183 | { | |
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); | |
185 | flag = WRONG_APP_DATA; |
|
185 | flag = WRONG_APP_DATA; | |
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 | //****************************************************************** |
|
188 | //****************************************************************** | |
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 | |
190 | if (flag == LFR_SUCCESSFUL) |
|
190 | if (flag == LFR_SUCCESSFUL) | |
191 | { |
|
191 | { | |
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); |
|
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); | |
193 | if (aux > FLOAT_EQUAL_ZERO) |
|
193 | if (aux > FLOAT_EQUAL_ZERO) | |
194 | { |
|
194 | { | |
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); | |
196 | flag = LFR_DEFAULT; |
|
196 | flag = LFR_DEFAULT; | |
197 | } |
|
197 | } | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | // SET THE PARAMETERS |
|
200 | // SET THE PARAMETERS | |
201 | if (flag == LFR_SUCCESSFUL) |
|
201 | if (flag == LFR_SUCCESSFUL) | |
202 | { |
|
202 | { | |
203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
203 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | return flag; |
|
207 | return flag; | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
211 | { |
|
211 | { | |
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
213 | * |
|
213 | * | |
214 | * @param TC points to the TeleCommand packet that is being processed |
|
214 | * @param TC points to the TeleCommand packet that is being processed | |
215 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
215 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
216 | * |
|
216 | * | |
217 | */ |
|
217 | */ | |
218 |
|
218 | |||
219 | int flag; |
|
219 | int flag; | |
220 | rtems_status_code status; |
|
220 | rtems_status_code status; | |
221 | unsigned char sy_lfr_s2_bp_p0; |
|
221 | unsigned char sy_lfr_s2_bp_p0; | |
222 | unsigned char sy_lfr_s2_bp_p1; |
|
222 | unsigned char sy_lfr_s2_bp_p1; | |
223 | float aux; |
|
223 | float aux; | |
224 |
|
224 | |||
225 | flag = LFR_SUCCESSFUL; |
|
225 | flag = LFR_SUCCESSFUL; | |
226 |
|
226 | |||
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
229 | flag = LFR_DEFAULT; |
|
229 | flag = LFR_DEFAULT; | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
234 |
|
234 | |||
235 | // sy_lfr_s2_bp_p0 |
|
235 | // sy_lfr_s2_bp_p0 | |
236 | if (flag == LFR_SUCCESSFUL) |
|
236 | if (flag == LFR_SUCCESSFUL) | |
237 | { |
|
237 | { | |
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
239 | { |
|
239 | { | |
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); | |
241 | flag = WRONG_APP_DATA; |
|
241 | flag = WRONG_APP_DATA; | |
242 | } |
|
242 | } | |
243 | } |
|
243 | } | |
244 | // sy_lfr_s2_bp_p1 |
|
244 | // sy_lfr_s2_bp_p1 | |
245 | if (flag == LFR_SUCCESSFUL) |
|
245 | if (flag == LFR_SUCCESSFUL) | |
246 | { |
|
246 | { | |
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
248 | { |
|
248 | { | |
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); | |
250 | flag = WRONG_APP_DATA; |
|
250 | flag = WRONG_APP_DATA; | |
251 | } |
|
251 | } | |
252 | } |
|
252 | } | |
253 | //****************************************************************** |
|
253 | //****************************************************************** | |
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
255 | if (flag == LFR_SUCCESSFUL) |
|
255 | if (flag == LFR_SUCCESSFUL) | |
256 | { |
|
256 | { | |
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); | |
260 | if (aux > FLOAT_EQUAL_ZERO) |
|
260 | if (aux > FLOAT_EQUAL_ZERO) | |
261 | { |
|
261 | { | |
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); | |
263 | flag = LFR_DEFAULT; |
|
263 | flag = LFR_DEFAULT; | |
264 | } |
|
264 | } | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | // SET THE PARAMETERS |
|
267 | // SET THE PARAMETERS | |
268 | if (flag == LFR_SUCCESSFUL) |
|
268 | if (flag == LFR_SUCCESSFUL) | |
269 | { |
|
269 | { | |
270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
270 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | return flag; |
|
274 | return flag; | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
278 | { |
|
278 | { | |
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
280 | * |
|
280 | * | |
281 | * @param TC points to the TeleCommand packet that is being processed |
|
281 | * @param TC points to the TeleCommand packet that is being processed | |
282 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
282 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
283 | * |
|
283 | * | |
284 | */ |
|
284 | */ | |
285 |
|
285 | |||
286 | int flag; |
|
286 | int flag; | |
287 |
|
287 | |||
288 | flag = LFR_DEFAULT; |
|
288 | flag = LFR_DEFAULT; | |
289 |
|
289 | |||
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
291 |
|
291 | |||
292 | return flag; |
|
292 | return flag; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
296 | { |
|
296 | { | |
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
298 | * |
|
298 | * | |
299 | * @param TC points to the TeleCommand packet that is being processed |
|
299 | * @param TC points to the TeleCommand packet that is being processed | |
300 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
300 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
301 | * |
|
301 | * | |
302 | */ |
|
302 | */ | |
303 |
|
303 | |||
304 | int flag; |
|
304 | int flag; | |
305 |
|
305 | |||
306 | flag = LFR_DEFAULT; |
|
306 | flag = LFR_DEFAULT; | |
307 |
|
307 | |||
308 | flag = set_sy_lfr_fbins( TC ); |
|
308 | flag = set_sy_lfr_fbins( TC ); | |
309 |
|
309 | |||
310 | return flag; |
|
310 | return flag; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff) |
|
|||
314 | { |
|
|||
315 | printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n", |
|
|||
316 | freq, |
|
|||
317 | bin, |
|
|||
318 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ], |
|
|||
319 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ], |
|
|||
320 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ], |
|
|||
321 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ], |
|
|||
322 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]); |
|
|||
323 | } |
|
|||
324 |
|
||||
325 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
313 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
326 | { |
|
314 | { | |
327 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
328 | * |
|
316 | * | |
329 | * @param TC points to the TeleCommand packet that is being processed |
|
317 | * @param TC points to the TeleCommand packet that is being processed | |
330 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
318 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
331 | * |
|
319 | * | |
332 | */ |
|
320 | */ | |
333 |
|
321 | |||
334 | unsigned int address; |
|
322 | unsigned int address; | |
335 | rtems_status_code status; |
|
323 | rtems_status_code status; | |
336 | unsigned int freq; |
|
324 | unsigned int freq; | |
337 | unsigned int bin; |
|
325 | unsigned int bin; | |
338 | unsigned int coeff; |
|
326 | unsigned int coeff; | |
339 | unsigned char *kCoeffPtr; |
|
327 | unsigned char *kCoeffPtr; | |
340 | unsigned char *kCoeffDumpPtr; |
|
328 | unsigned char *kCoeffDumpPtr; | |
341 |
|
329 | |||
342 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
330 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
343 | // F0 => 11 bins |
|
331 | // F0 => 11 bins | |
344 | // F1 => 13 bins |
|
332 | // F1 => 13 bins | |
345 | // F2 => 12 bins |
|
333 | // F2 => 12 bins | |
346 | // 36 bins to dump in two packets (30 bins max per packet) |
|
334 | // 36 bins to dump in two packets (30 bins max per packet) | |
347 |
|
335 | |||
348 | //********* |
|
336 | //********* | |
349 | // PACKET 1 |
|
337 | // PACKET 1 | |
350 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
338 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
351 | kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
|||
352 | kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
|||
353 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
339 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
354 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
340 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
355 | for( freq=0; |
|
341 | for( freq=0; | |
356 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
342 | freq<NB_BINS_COMPRESSED_SM_F0; | |
357 | freq++ ) |
|
343 | freq++ ) | |
358 | { |
|
344 | { | |
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
345 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; | |
360 | bin = freq; |
|
346 | bin = freq; | |
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
347 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
348 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
363 | { |
|
349 | { | |
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
350 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
351 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
352 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
367 | } |
|
353 | } | |
368 | } |
|
354 | } | |
369 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
355 | for( freq=NB_BINS_COMPRESSED_SM_F0; | |
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
356 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
371 | freq++ ) |
|
357 | freq++ ) | |
372 | { |
|
358 | { | |
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
374 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
360 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
377 | { |
|
363 | { | |
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
381 | } |
|
367 | } | |
382 | } |
|
368 | } | |
383 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
369 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
384 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); | |
385 | freq++ ) |
|
371 | freq++ ) | |
386 | { |
|
372 | { | |
387 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
388 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
374 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
389 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
390 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
391 | { |
|
377 | { | |
392 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
393 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
394 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
395 | } |
|
381 | } | |
396 | } |
|
382 | } | |
397 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
383 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
398 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
384 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
399 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
385 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
400 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
386 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
401 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
387 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
402 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
388 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); | |
403 | // SEND DATA |
|
389 | // SEND DATA | |
404 | kcoefficient_node_1.status = 1; |
|
390 | kcoefficient_node_1.status = 1; | |
405 | address = (unsigned int) &kcoefficient_node_1; |
|
391 | address = (unsigned int) &kcoefficient_node_1; | |
406 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
392 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
407 | if (status != RTEMS_SUCCESSFUL) { |
|
393 | if (status != RTEMS_SUCCESSFUL) { | |
408 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
394 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
409 | } |
|
395 | } | |
410 |
|
396 | |||
411 | //******** |
|
397 | //******** | |
412 | // PACKET 2 |
|
398 | // PACKET 2 | |
413 | // 6 F2 bins |
|
399 | // 6 F2 bins | |
414 | kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
|||
415 | kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
|||
416 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
400 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
417 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
401 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
418 | for( freq=0; freq<6; freq++ ) |
|
402 | for( freq=0; freq<6; freq++ ) | |
419 | { |
|
403 | { | |
420 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
404 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; | |
421 | bin = freq + 6; |
|
405 | bin = freq + 6; | |
422 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
406 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
423 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
407 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
424 | { |
|
408 | { | |
425 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
409 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
426 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
410 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
427 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
411 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
428 | } |
|
412 | } | |
429 | } |
|
413 | } | |
430 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
414 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
431 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
415 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
432 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
416 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
433 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
417 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
434 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
418 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
435 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
419 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); | |
436 | // SEND DATA |
|
420 | // SEND DATA | |
437 | kcoefficient_node_2.status = 1; |
|
421 | kcoefficient_node_2.status = 1; | |
438 | address = (unsigned int) &kcoefficient_node_2; |
|
422 | address = (unsigned int) &kcoefficient_node_2; | |
439 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
423 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
440 | if (status != RTEMS_SUCCESSFUL) { |
|
424 | if (status != RTEMS_SUCCESSFUL) { | |
441 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
425 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
442 | } |
|
426 | } | |
443 |
|
427 | |||
444 | return status; |
|
428 | return status; | |
445 | } |
|
429 | } | |
446 |
|
430 | |||
447 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
431 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
448 | { |
|
432 | { | |
449 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
433 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
450 | * |
|
434 | * | |
451 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
435 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
452 | * |
|
436 | * | |
453 | * @return RTEMS directive status codes: |
|
437 | * @return RTEMS directive status codes: | |
454 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
438 | * - RTEMS_SUCCESSFUL - message sent successfully | |
455 | * - RTEMS_INVALID_ID - invalid queue id |
|
439 | * - RTEMS_INVALID_ID - invalid queue id | |
456 | * - RTEMS_INVALID_SIZE - invalid message size |
|
440 | * - RTEMS_INVALID_SIZE - invalid message size | |
457 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
441 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
458 | * - RTEMS_UNSATISFIED - out of message buffers |
|
442 | * - RTEMS_UNSATISFIED - out of message buffers | |
459 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
443 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
460 | * |
|
444 | * | |
461 | */ |
|
445 | */ | |
462 |
|
446 | |||
463 | int status; |
|
447 | int status; | |
464 |
|
448 | |||
465 | // UPDATE TIME |
|
449 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
466 | parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
|||
467 | parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
|||
468 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
|||
469 | parameter_dump_packet.destinationID = TC->sourceID; |
|
450 | parameter_dump_packet.destinationID = TC->sourceID; | |
470 |
|
451 | |||
|
452 | // UPDATE TIME | |||
471 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
453 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
472 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
454 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
473 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
455 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
474 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
456 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
475 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
457 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
476 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
458 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
477 | // SEND DATA |
|
459 | // SEND DATA | |
478 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
460 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
479 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
461 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
480 | if (status != RTEMS_SUCCESSFUL) { |
|
462 | if (status != RTEMS_SUCCESSFUL) { | |
481 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
463 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
482 | } |
|
464 | } | |
483 |
|
465 | |||
484 | return status; |
|
466 | return status; | |
485 | } |
|
467 | } | |
486 |
|
468 | |||
487 | //*********************** |
|
469 | //*********************** | |
488 | // NORMAL MODE PARAMETERS |
|
470 | // NORMAL MODE PARAMETERS | |
489 |
|
471 | |||
490 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
472 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
491 | { |
|
473 | { | |
492 | unsigned char msb; |
|
474 | unsigned char msb; | |
493 | unsigned char lsb; |
|
475 | unsigned char lsb; | |
494 | int flag; |
|
476 | int flag; | |
495 | float aux; |
|
477 | float aux; | |
496 | rtems_status_code status; |
|
478 | rtems_status_code status; | |
497 |
|
479 | |||
498 | unsigned int sy_lfr_n_swf_l; |
|
480 | unsigned int sy_lfr_n_swf_l; | |
499 | unsigned int sy_lfr_n_swf_p; |
|
481 | unsigned int sy_lfr_n_swf_p; | |
500 | unsigned int sy_lfr_n_asm_p; |
|
482 | unsigned int sy_lfr_n_asm_p; | |
501 | unsigned char sy_lfr_n_bp_p0; |
|
483 | unsigned char sy_lfr_n_bp_p0; | |
502 | unsigned char sy_lfr_n_bp_p1; |
|
484 | unsigned char sy_lfr_n_bp_p1; | |
503 | unsigned char sy_lfr_n_cwf_long_f3; |
|
485 | unsigned char sy_lfr_n_cwf_long_f3; | |
504 |
|
486 | |||
505 | flag = LFR_SUCCESSFUL; |
|
487 | flag = LFR_SUCCESSFUL; | |
506 |
|
488 | |||
507 | //*************** |
|
489 | //*************** | |
508 | // get parameters |
|
490 | // get parameters | |
509 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
491 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
510 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
492 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
511 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
493 | sy_lfr_n_swf_l = msb * 256 + lsb; | |
512 |
|
494 | |||
513 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
495 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
514 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
496 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
515 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
497 | sy_lfr_n_swf_p = msb * 256 + lsb; | |
516 |
|
498 | |||
517 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
499 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
518 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
500 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
519 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
501 | sy_lfr_n_asm_p = msb * 256 + lsb; | |
520 |
|
502 | |||
521 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
503 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
522 |
|
504 | |||
523 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
505 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
524 |
|
506 | |||
525 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
507 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
526 |
|
508 | |||
527 | //****************** |
|
509 | //****************** | |
528 | // check consistency |
|
510 | // check consistency | |
529 | // sy_lfr_n_swf_l |
|
511 | // sy_lfr_n_swf_l | |
530 | if (sy_lfr_n_swf_l != 2048) |
|
512 | if (sy_lfr_n_swf_l != 2048) | |
531 | { |
|
513 | { | |
532 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
514 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); | |
533 | flag = WRONG_APP_DATA; |
|
515 | flag = WRONG_APP_DATA; | |
534 | } |
|
516 | } | |
535 | // sy_lfr_n_swf_p |
|
517 | // sy_lfr_n_swf_p | |
536 | if (flag == LFR_SUCCESSFUL) |
|
518 | if (flag == LFR_SUCCESSFUL) | |
537 | { |
|
519 | { | |
538 | if ( sy_lfr_n_swf_p < 16 ) |
|
520 | if ( sy_lfr_n_swf_p < 16 ) | |
539 | { |
|
521 | { | |
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
522 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); | |
541 | flag = WRONG_APP_DATA; |
|
523 | flag = WRONG_APP_DATA; | |
542 | } |
|
524 | } | |
543 | } |
|
525 | } | |
544 | // sy_lfr_n_bp_p0 |
|
526 | // sy_lfr_n_bp_p0 | |
545 | if (flag == LFR_SUCCESSFUL) |
|
527 | if (flag == LFR_SUCCESSFUL) | |
546 | { |
|
528 | { | |
547 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
529 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
548 | { |
|
530 | { | |
549 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
531 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); | |
550 | flag = WRONG_APP_DATA; |
|
532 | flag = WRONG_APP_DATA; | |
551 | } |
|
533 | } | |
552 | } |
|
534 | } | |
553 | // sy_lfr_n_asm_p |
|
535 | // sy_lfr_n_asm_p | |
554 | if (flag == LFR_SUCCESSFUL) |
|
536 | if (flag == LFR_SUCCESSFUL) | |
555 | { |
|
537 | { | |
556 | if (sy_lfr_n_asm_p == 0) |
|
538 | if (sy_lfr_n_asm_p == 0) | |
557 | { |
|
539 | { | |
558 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
559 | flag = WRONG_APP_DATA; |
|
541 | flag = WRONG_APP_DATA; | |
560 | } |
|
542 | } | |
561 | } |
|
543 | } | |
562 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
544 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
563 | if (flag == LFR_SUCCESSFUL) |
|
545 | if (flag == LFR_SUCCESSFUL) | |
564 | { |
|
546 | { | |
565 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
547 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
566 | if (aux > FLOAT_EQUAL_ZERO) |
|
548 | if (aux > FLOAT_EQUAL_ZERO) | |
567 | { |
|
549 | { | |
568 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
550 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
569 | flag = WRONG_APP_DATA; |
|
551 | flag = WRONG_APP_DATA; | |
570 | } |
|
552 | } | |
571 | } |
|
553 | } | |
572 | // sy_lfr_n_bp_p1 |
|
554 | // sy_lfr_n_bp_p1 | |
573 | if (flag == LFR_SUCCESSFUL) |
|
555 | if (flag == LFR_SUCCESSFUL) | |
574 | { |
|
556 | { | |
575 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
557 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
576 | { |
|
558 | { | |
577 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
559 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
578 | flag = WRONG_APP_DATA; |
|
560 | flag = WRONG_APP_DATA; | |
579 | } |
|
561 | } | |
580 | } |
|
562 | } | |
581 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
563 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
582 | if (flag == LFR_SUCCESSFUL) |
|
564 | if (flag == LFR_SUCCESSFUL) | |
583 | { |
|
565 | { | |
584 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
566 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
585 | if (aux > FLOAT_EQUAL_ZERO) |
|
567 | if (aux > FLOAT_EQUAL_ZERO) | |
586 | { |
|
568 | { | |
587 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
569 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
588 | flag = LFR_DEFAULT; |
|
570 | flag = LFR_DEFAULT; | |
589 | } |
|
571 | } | |
590 | } |
|
572 | } | |
591 | // sy_lfr_n_cwf_long_f3 |
|
573 | // sy_lfr_n_cwf_long_f3 | |
592 |
|
574 | |||
593 | return flag; |
|
575 | return flag; | |
594 | } |
|
576 | } | |
595 |
|
577 | |||
596 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
578 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
597 | { |
|
579 | { | |
598 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
580 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
599 | * |
|
581 | * | |
600 | * @param TC points to the TeleCommand packet that is being processed |
|
582 | * @param TC points to the TeleCommand packet that is being processed | |
601 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
583 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
602 | * |
|
584 | * | |
603 | */ |
|
585 | */ | |
604 |
|
586 | |||
605 | int result; |
|
587 | int result; | |
606 |
|
588 | |||
607 | result = LFR_SUCCESSFUL; |
|
589 | result = LFR_SUCCESSFUL; | |
608 |
|
590 | |||
609 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
591 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
610 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
592 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
611 |
|
593 | |||
612 | return result; |
|
594 | return result; | |
613 | } |
|
595 | } | |
614 |
|
596 | |||
615 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
597 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
616 | { |
|
598 | { | |
617 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
599 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
618 | * |
|
600 | * | |
619 | * @param TC points to the TeleCommand packet that is being processed |
|
601 | * @param TC points to the TeleCommand packet that is being processed | |
620 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
602 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
621 | * |
|
603 | * | |
622 | */ |
|
604 | */ | |
623 |
|
605 | |||
624 | int result; |
|
606 | int result; | |
625 |
|
607 | |||
626 | result = LFR_SUCCESSFUL; |
|
608 | result = LFR_SUCCESSFUL; | |
627 |
|
609 | |||
628 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
610 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
629 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
611 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
630 |
|
612 | |||
631 | return result; |
|
613 | return result; | |
632 | } |
|
614 | } | |
633 |
|
615 | |||
634 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
616 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
635 | { |
|
617 | { | |
636 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
618 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
637 | * |
|
619 | * | |
638 | * @param TC points to the TeleCommand packet that is being processed |
|
620 | * @param TC points to the TeleCommand packet that is being processed | |
639 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
621 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
640 | * |
|
622 | * | |
641 | */ |
|
623 | */ | |
642 |
|
624 | |||
643 | int result; |
|
625 | int result; | |
644 |
|
626 | |||
645 | result = LFR_SUCCESSFUL; |
|
627 | result = LFR_SUCCESSFUL; | |
646 |
|
628 | |||
647 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
629 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
648 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
630 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
649 |
|
631 | |||
650 | return result; |
|
632 | return result; | |
651 | } |
|
633 | } | |
652 |
|
634 | |||
653 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
635 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
654 | { |
|
636 | { | |
655 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
637 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
656 | * |
|
638 | * | |
657 | * @param TC points to the TeleCommand packet that is being processed |
|
639 | * @param TC points to the TeleCommand packet that is being processed | |
658 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
640 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
659 | * |
|
641 | * | |
660 | */ |
|
642 | */ | |
661 |
|
643 | |||
662 | int status; |
|
644 | int status; | |
663 |
|
645 | |||
664 | status = LFR_SUCCESSFUL; |
|
646 | status = LFR_SUCCESSFUL; | |
665 |
|
647 | |||
666 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
648 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
667 |
|
649 | |||
668 | return status; |
|
650 | return status; | |
669 | } |
|
651 | } | |
670 |
|
652 | |||
671 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
653 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
672 | { |
|
654 | { | |
673 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
655 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
674 | * |
|
656 | * | |
675 | * @param TC points to the TeleCommand packet that is being processed |
|
657 | * @param TC points to the TeleCommand packet that is being processed | |
676 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
658 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
677 | * |
|
659 | * | |
678 | */ |
|
660 | */ | |
679 |
|
661 | |||
680 | int status; |
|
662 | int status; | |
681 |
|
663 | |||
682 | status = LFR_SUCCESSFUL; |
|
664 | status = LFR_SUCCESSFUL; | |
683 |
|
665 | |||
684 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
666 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
685 |
|
667 | |||
686 | return status; |
|
668 | return status; | |
687 | } |
|
669 | } | |
688 |
|
670 | |||
689 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
671 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
690 | { |
|
672 | { | |
691 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
673 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
692 | * |
|
674 | * | |
693 | * @param TC points to the TeleCommand packet that is being processed |
|
675 | * @param TC points to the TeleCommand packet that is being processed | |
694 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
676 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
695 | * |
|
677 | * | |
696 | */ |
|
678 | */ | |
697 |
|
679 | |||
698 | int status; |
|
680 | int status; | |
699 |
|
681 | |||
700 | status = LFR_SUCCESSFUL; |
|
682 | status = LFR_SUCCESSFUL; | |
701 |
|
683 | |||
702 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
684 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
703 |
|
685 | |||
704 | return status; |
|
686 | return status; | |
705 | } |
|
687 | } | |
706 |
|
688 | |||
707 | //********************** |
|
689 | //********************** | |
708 | // BURST MODE PARAMETERS |
|
690 | // BURST MODE PARAMETERS | |
709 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
691 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
710 | { |
|
692 | { | |
711 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
693 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
712 | * |
|
694 | * | |
713 | * @param TC points to the TeleCommand packet that is being processed |
|
695 | * @param TC points to the TeleCommand packet that is being processed | |
714 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
696 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
715 | * |
|
697 | * | |
716 | */ |
|
698 | */ | |
717 |
|
699 | |||
718 | int status; |
|
700 | int status; | |
719 |
|
701 | |||
720 | status = LFR_SUCCESSFUL; |
|
702 | status = LFR_SUCCESSFUL; | |
721 |
|
703 | |||
722 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
704 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
723 |
|
705 | |||
724 | return status; |
|
706 | return status; | |
725 | } |
|
707 | } | |
726 |
|
708 | |||
727 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
709 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
728 | { |
|
710 | { | |
729 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
711 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
730 | * |
|
712 | * | |
731 | * @param TC points to the TeleCommand packet that is being processed |
|
713 | * @param TC points to the TeleCommand packet that is being processed | |
732 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
714 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
733 | * |
|
715 | * | |
734 | */ |
|
716 | */ | |
735 |
|
717 | |||
736 | int status; |
|
718 | int status; | |
737 |
|
719 | |||
738 | status = LFR_SUCCESSFUL; |
|
720 | status = LFR_SUCCESSFUL; | |
739 |
|
721 | |||
740 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
722 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
741 |
|
723 | |||
742 | return status; |
|
724 | return status; | |
743 | } |
|
725 | } | |
744 |
|
726 | |||
745 | //********************* |
|
727 | //********************* | |
746 | // SBM1 MODE PARAMETERS |
|
728 | // SBM1 MODE PARAMETERS | |
747 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
729 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
748 | { |
|
730 | { | |
749 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
731 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
750 | * |
|
732 | * | |
751 | * @param TC points to the TeleCommand packet that is being processed |
|
733 | * @param TC points to the TeleCommand packet that is being processed | |
752 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
734 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
753 | * |
|
735 | * | |
754 | */ |
|
736 | */ | |
755 |
|
737 | |||
756 | int status; |
|
738 | int status; | |
757 |
|
739 | |||
758 | status = LFR_SUCCESSFUL; |
|
740 | status = LFR_SUCCESSFUL; | |
759 |
|
741 | |||
760 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
742 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
761 |
|
743 | |||
762 | return status; |
|
744 | return status; | |
763 | } |
|
745 | } | |
764 |
|
746 | |||
765 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
747 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
766 | { |
|
748 | { | |
767 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
749 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
768 | * |
|
750 | * | |
769 | * @param TC points to the TeleCommand packet that is being processed |
|
751 | * @param TC points to the TeleCommand packet that is being processed | |
770 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
752 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
771 | * |
|
753 | * | |
772 | */ |
|
754 | */ | |
773 |
|
755 | |||
774 | int status; |
|
756 | int status; | |
775 |
|
757 | |||
776 | status = LFR_SUCCESSFUL; |
|
758 | status = LFR_SUCCESSFUL; | |
777 |
|
759 | |||
778 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
760 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
779 |
|
761 | |||
780 | return status; |
|
762 | return status; | |
781 | } |
|
763 | } | |
782 |
|
764 | |||
783 | //********************* |
|
765 | //********************* | |
784 | // SBM2 MODE PARAMETERS |
|
766 | // SBM2 MODE PARAMETERS | |
785 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
767 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) | |
786 | { |
|
768 | { | |
787 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
769 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
788 | * |
|
770 | * | |
789 | * @param TC points to the TeleCommand packet that is being processed |
|
771 | * @param TC points to the TeleCommand packet that is being processed | |
790 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
772 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
791 | * |
|
773 | * | |
792 | */ |
|
774 | */ | |
793 |
|
775 | |||
794 | int status; |
|
776 | int status; | |
795 |
|
777 | |||
796 | status = LFR_SUCCESSFUL; |
|
778 | status = LFR_SUCCESSFUL; | |
797 |
|
779 | |||
798 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
780 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
799 |
|
781 | |||
800 | return status; |
|
782 | return status; | |
801 | } |
|
783 | } | |
802 |
|
784 | |||
803 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
785 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
804 | { |
|
786 | { | |
805 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
787 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
806 | * |
|
788 | * | |
807 | * @param TC points to the TeleCommand packet that is being processed |
|
789 | * @param TC points to the TeleCommand packet that is being processed | |
808 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
790 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
809 | * |
|
791 | * | |
810 | */ |
|
792 | */ | |
811 |
|
793 | |||
812 | int status; |
|
794 | int status; | |
813 |
|
795 | |||
814 | status = LFR_SUCCESSFUL; |
|
796 | status = LFR_SUCCESSFUL; | |
815 |
|
797 | |||
816 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
798 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
817 |
|
799 | |||
818 | return status; |
|
800 | return status; | |
819 | } |
|
801 | } | |
820 |
|
802 | |||
821 | //******************* |
|
803 | //******************* | |
822 | // TC_LFR_UPDATE_INFO |
|
804 | // TC_LFR_UPDATE_INFO | |
823 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
805 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
824 | { |
|
806 | { | |
825 | unsigned int status; |
|
807 | unsigned int status; | |
826 |
|
808 | |||
827 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
809 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
828 | || (mode == LFR_MODE_BURST) |
|
810 | || (mode == LFR_MODE_BURST) | |
829 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
811 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
830 | { |
|
812 | { | |
831 | status = LFR_SUCCESSFUL; |
|
813 | status = LFR_SUCCESSFUL; | |
832 | } |
|
814 | } | |
833 | else |
|
815 | else | |
834 | { |
|
816 | { | |
835 | status = LFR_DEFAULT; |
|
817 | status = LFR_DEFAULT; | |
836 | } |
|
818 | } | |
837 |
|
819 | |||
838 | return status; |
|
820 | return status; | |
839 | } |
|
821 | } | |
840 |
|
822 | |||
841 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
823 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
842 | { |
|
824 | { | |
843 | unsigned int status; |
|
825 | unsigned int status; | |
844 |
|
826 | |||
845 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
827 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
846 | || (mode == TDS_MODE_BURST) |
|
828 | || (mode == TDS_MODE_BURST) | |
847 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
829 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
848 | || (mode == TDS_MODE_LFM)) |
|
830 | || (mode == TDS_MODE_LFM)) | |
849 | { |
|
831 | { | |
850 | status = LFR_SUCCESSFUL; |
|
832 | status = LFR_SUCCESSFUL; | |
851 | } |
|
833 | } | |
852 | else |
|
834 | else | |
853 | { |
|
835 | { | |
854 | status = LFR_DEFAULT; |
|
836 | status = LFR_DEFAULT; | |
855 | } |
|
837 | } | |
856 |
|
838 | |||
857 | return status; |
|
839 | return status; | |
858 | } |
|
840 | } | |
859 |
|
841 | |||
860 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
842 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
861 | { |
|
843 | { | |
862 | unsigned int status; |
|
844 | unsigned int status; | |
863 |
|
845 | |||
864 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
846 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
865 | || (mode == THR_MODE_BURST)) |
|
847 | || (mode == THR_MODE_BURST)) | |
866 | { |
|
848 | { | |
867 | status = LFR_SUCCESSFUL; |
|
849 | status = LFR_SUCCESSFUL; | |
868 | } |
|
850 | } | |
869 | else |
|
851 | else | |
870 | { |
|
852 | { | |
871 | status = LFR_DEFAULT; |
|
853 | status = LFR_DEFAULT; | |
872 | } |
|
854 | } | |
873 |
|
855 | |||
874 | return status; |
|
856 | return status; | |
875 | } |
|
857 | } | |
876 |
|
858 | |||
877 | //*********** |
|
859 | //*********** | |
878 | // FBINS MASK |
|
860 | // FBINS MASK | |
879 |
|
861 | |||
880 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
862 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
881 | { |
|
863 | { | |
882 | int status; |
|
864 | int status; | |
883 | unsigned int k; |
|
865 | unsigned int k; | |
884 | unsigned char *fbins_mask_dump; |
|
866 | unsigned char *fbins_mask_dump; | |
885 | unsigned char *fbins_mask_TC; |
|
867 | unsigned char *fbins_mask_TC; | |
886 |
|
868 | |||
887 | status = LFR_SUCCESSFUL; |
|
869 | status = LFR_SUCCESSFUL; | |
888 |
|
870 | |||
889 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
871 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
890 | fbins_mask_TC = TC->dataAndCRC; |
|
872 | fbins_mask_TC = TC->dataAndCRC; | |
891 |
|
873 | |||
892 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
874 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
893 | { |
|
875 | { | |
894 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
876 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
895 | } |
|
877 | } | |
896 | for (k=0; k < NB_FBINS_MASKS; k++) |
|
878 | for (k=0; k < NB_FBINS_MASKS; k++) | |
897 | { |
|
879 | { | |
898 | unsigned char *auxPtr; |
|
880 | unsigned char *auxPtr; | |
899 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; |
|
881 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; | |
900 | printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]); |
|
|||
901 | } |
|
882 | } | |
902 |
|
883 | |||
903 |
|
884 | |||
904 | return status; |
|
885 | return status; | |
905 | } |
|
886 | } | |
906 |
|
887 | |||
907 | //************** |
|
888 | //************** | |
908 | // KCOEFFICIENTS |
|
889 | // KCOEFFICIENTS | |
909 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
890 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
910 | { |
|
891 | { | |
911 | unsigned int kcoeff; |
|
892 | unsigned int kcoeff; | |
912 | unsigned short sy_lfr_kcoeff_frequency; |
|
893 | unsigned short sy_lfr_kcoeff_frequency; | |
913 | unsigned short bin; |
|
894 | unsigned short bin; | |
914 | unsigned short *freqPtr; |
|
895 | unsigned short *freqPtr; | |
915 | float *kcoeffPtr_norm; |
|
896 | float *kcoeffPtr_norm; | |
916 | float *kcoeffPtr_sbm; |
|
897 | float *kcoeffPtr_sbm; | |
917 | int status; |
|
898 | int status; | |
918 | unsigned char *kcoeffLoadPtr; |
|
899 | unsigned char *kcoeffLoadPtr; | |
919 | unsigned char *kcoeffNormPtr; |
|
900 | unsigned char *kcoeffNormPtr; | |
920 | unsigned char *kcoeffSbmPtr_a; |
|
901 | unsigned char *kcoeffSbmPtr_a; | |
921 | unsigned char *kcoeffSbmPtr_b; |
|
902 | unsigned char *kcoeffSbmPtr_b; | |
922 |
|
903 | |||
923 | status = LFR_SUCCESSFUL; |
|
904 | status = LFR_SUCCESSFUL; | |
924 |
|
905 | |||
925 | kcoeffPtr_norm = NULL; |
|
906 | kcoeffPtr_norm = NULL; | |
926 | kcoeffPtr_sbm = NULL; |
|
907 | kcoeffPtr_sbm = NULL; | |
927 | bin = 0; |
|
908 | bin = 0; | |
928 |
|
909 | |||
929 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
910 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; | |
930 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
911 | sy_lfr_kcoeff_frequency = *freqPtr; | |
931 |
|
912 | |||
932 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
913 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
933 | { |
|
914 | { | |
934 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
915 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
935 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
916 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, | |
936 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
917 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
937 | status = LFR_DEFAULT; |
|
918 | status = LFR_DEFAULT; | |
938 | } |
|
919 | } | |
939 | else |
|
920 | else | |
940 | { |
|
921 | { | |
941 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
922 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
942 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
923 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
943 | { |
|
924 | { | |
944 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
925 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
945 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
926 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
946 | bin = sy_lfr_kcoeff_frequency; |
|
927 | bin = sy_lfr_kcoeff_frequency; | |
947 | } |
|
928 | } | |
948 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
929 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
949 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
930 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
950 | { |
|
931 | { | |
951 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
932 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
952 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
933 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
953 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
934 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
954 | } |
|
935 | } | |
955 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
936 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
956 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
937 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
957 | { |
|
938 | { | |
958 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
939 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
959 | kcoeffPtr_sbm = NULL; |
|
940 | kcoeffPtr_sbm = NULL; | |
960 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
941 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
961 | } |
|
942 | } | |
962 | } |
|
943 | } | |
963 |
|
944 | |||
964 | printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin); |
|
|||
965 |
|
||||
966 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
945 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
967 | { |
|
946 | { | |
968 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
947 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
969 | { |
|
948 | { | |
970 | // destination |
|
949 | // destination | |
971 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
950 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
972 | // source |
|
951 | // source | |
973 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
952 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
974 | // copy source to destination |
|
953 | // copy source to destination | |
975 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
954 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
976 | } |
|
955 | } | |
977 | } |
|
956 | } | |
978 |
|
957 | |||
979 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
958 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
980 | { |
|
959 | { | |
981 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
960 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
982 | { |
|
961 | { | |
983 | // destination |
|
962 | // destination | |
984 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
963 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; | |
985 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
964 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; | |
986 | // source |
|
965 | // source | |
987 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
966 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
988 | // copy source to destination |
|
967 | // copy source to destination | |
989 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
968 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
990 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
969 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
991 | } |
|
970 | } | |
992 | } |
|
971 | } | |
993 |
|
972 | |||
994 | // print_k_coeff(); |
|
973 | // print_k_coeff(); | |
995 |
|
974 | |||
996 | return status; |
|
975 | return status; | |
997 | } |
|
976 | } | |
998 |
|
977 | |||
999 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
978 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
1000 | { |
|
979 | { | |
1001 | destination[0] = source[0]; |
|
980 | destination[0] = source[0]; | |
1002 | destination[1] = source[1]; |
|
981 | destination[1] = source[1]; | |
1003 | destination[2] = source[2]; |
|
982 | destination[2] = source[2]; | |
1004 | destination[3] = source[3]; |
|
983 | destination[3] = source[3]; | |
1005 | } |
|
984 | } | |
1006 |
|
985 | |||
1007 | //********** |
|
986 | //********** | |
1008 | // init dump |
|
987 | // init dump | |
1009 |
|
988 | |||
1010 | void init_parameter_dump( void ) |
|
989 | void init_parameter_dump( void ) | |
1011 | { |
|
990 | { | |
1012 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
991 | /** This function initialize the parameter_dump_packet global variable with default values. | |
1013 | * |
|
992 | * | |
1014 | */ |
|
993 | */ | |
1015 |
|
994 | |||
1016 | unsigned int k; |
|
995 | unsigned int k; | |
1017 |
|
996 | |||
1018 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
997 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1019 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
998 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1020 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
999 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1021 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1000 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1022 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1001 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); | |
1023 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1002 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1024 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1003 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1025 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1004 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1026 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1005 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
1027 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1006 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1028 | // DATA FIELD HEADER |
|
1007 | // DATA FIELD HEADER | |
1029 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1008 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1030 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1009 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1031 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1010 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1032 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1011 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1033 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1012 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1034 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1013 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1035 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1014 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1036 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1015 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
1037 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1016 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1038 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1017 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
1039 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1018 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1040 |
|
1019 | |||
1041 | //****************** |
|
1020 | //****************** | |
1042 | // COMMON PARAMETERS |
|
1021 | // COMMON PARAMETERS | |
1043 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1022 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1044 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1023 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1045 |
|
1024 | |||
1046 | //****************** |
|
1025 | //****************** | |
1047 | // NORMAL PARAMETERS |
|
1026 | // NORMAL PARAMETERS | |
1048 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1027 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); | |
1049 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1028 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1050 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1029 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); | |
1051 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1030 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1052 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1031 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); | |
1053 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1032 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1054 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1033 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1055 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1034 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1056 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1035 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1057 |
|
1036 | |||
1058 | //***************** |
|
1037 | //***************** | |
1059 | // BURST PARAMETERS |
|
1038 | // BURST PARAMETERS | |
1060 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1039 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1061 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1040 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1062 |
|
1041 | |||
1063 | //**************** |
|
1042 | //**************** | |
1064 | // SBM1 PARAMETERS |
|
1043 | // SBM1 PARAMETERS | |
1065 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
1044 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period | |
1066 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1045 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1067 |
|
1046 | |||
1068 | //**************** |
|
1047 | //**************** | |
1069 | // SBM2 PARAMETERS |
|
1048 | // SBM2 PARAMETERS | |
1070 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1049 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1071 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1050 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1072 |
|
1051 | |||
1073 | //************ |
|
1052 | //************ | |
1074 | // FBINS MASKS |
|
1053 | // FBINS MASKS | |
1075 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1054 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
1076 | { |
|
1055 | { | |
1077 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1056 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; | |
1078 | } |
|
1057 | } | |
1079 | } |
|
1058 | } | |
1080 |
|
1059 | |||
1081 | void init_kcoefficients_dump( void ) |
|
1060 | void init_kcoefficients_dump( void ) | |
1082 | { |
|
1061 | { | |
1083 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1062 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); | |
1084 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1063 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); | |
1085 |
|
1064 | |||
1086 | kcoefficient_node_1.previous = NULL; |
|
1065 | kcoefficient_node_1.previous = NULL; | |
1087 | kcoefficient_node_1.next = NULL; |
|
1066 | kcoefficient_node_1.next = NULL; | |
1088 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1067 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1089 | kcoefficient_node_1.coarseTime = 0x00; |
|
1068 | kcoefficient_node_1.coarseTime = 0x00; | |
1090 | kcoefficient_node_1.fineTime = 0x00; |
|
1069 | kcoefficient_node_1.fineTime = 0x00; | |
1091 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1070 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1092 | kcoefficient_node_1.status = 0x00; |
|
1071 | kcoefficient_node_1.status = 0x00; | |
1093 |
|
1072 | |||
1094 | kcoefficient_node_2.previous = NULL; |
|
1073 | kcoefficient_node_2.previous = NULL; | |
1095 | kcoefficient_node_2.next = NULL; |
|
1074 | kcoefficient_node_2.next = NULL; | |
1096 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1075 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1097 | kcoefficient_node_2.coarseTime = 0x00; |
|
1076 | kcoefficient_node_2.coarseTime = 0x00; | |
1098 | kcoefficient_node_2.fineTime = 0x00; |
|
1077 | kcoefficient_node_2.fineTime = 0x00; | |
1099 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1078 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1100 | kcoefficient_node_2.status = 0x00; |
|
1079 | kcoefficient_node_2.status = 0x00; | |
1101 | } |
|
1080 | } | |
1102 |
|
1081 | |||
1103 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1082 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1104 | { |
|
1083 | { | |
1105 | unsigned int k; |
|
1084 | unsigned int k; | |
1106 | unsigned int packetLength; |
|
1085 | unsigned int packetLength; | |
1107 |
|
1086 | |||
1108 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1087 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1109 |
|
1088 | |||
1110 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1089 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1111 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1090 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1112 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1091 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1113 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1092 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1114 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1093 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; | |
1115 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1094 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; | |
1116 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1095 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1117 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1096 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1118 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1097 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); | |
1119 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1098 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1120 | // DATA FIELD HEADER |
|
1099 | // DATA FIELD HEADER | |
1121 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1100 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1122 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1101 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1123 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1102 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1124 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1103 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1125 | kcoefficients_dump->time[0] = 0x00; |
|
1104 | kcoefficients_dump->time[0] = 0x00; | |
1126 | kcoefficients_dump->time[1] = 0x00; |
|
1105 | kcoefficients_dump->time[1] = 0x00; | |
1127 | kcoefficients_dump->time[2] = 0x00; |
|
1106 | kcoefficients_dump->time[2] = 0x00; | |
1128 | kcoefficients_dump->time[3] = 0x00; |
|
1107 | kcoefficients_dump->time[3] = 0x00; | |
1129 | kcoefficients_dump->time[4] = 0x00; |
|
1108 | kcoefficients_dump->time[4] = 0x00; | |
1130 | kcoefficients_dump->time[5] = 0x00; |
|
1109 | kcoefficients_dump->time[5] = 0x00; | |
1131 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1110 | kcoefficients_dump->sid = SID_K_DUMP; | |
1132 |
|
1111 | |||
1133 | kcoefficients_dump->pkt_cnt = 2; |
|
1112 | kcoefficients_dump->pkt_cnt = 2; | |
1134 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1113 | kcoefficients_dump->pkt_nr = pkt_nr; | |
1135 | kcoefficients_dump->blk_nr = blk_nr; |
|
1114 | kcoefficients_dump->blk_nr = blk_nr; | |
1136 |
|
1115 | |||
1137 | //****************** |
|
1116 | //****************** | |
1138 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1117 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1139 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1118 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1140 | for (k=0; k<3900; k++) |
|
1119 | for (k=0; k<3900; k++) | |
1141 | { |
|
1120 | { | |
1142 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1121 | kcoefficients_dump->kcoeff_blks[k] = 0x00; | |
1143 | } |
|
1122 | } | |
1144 | } |
|
1123 | } | |
1145 |
|
1124 | |||
1146 | void print_k_coeff() |
|
1125 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1147 | { |
|
1126 | { | |
1148 | unsigned int kcoeff; |
|
1127 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1149 | unsigned int bin; |
|
1128 | * | |
|
1129 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |||
|
1130 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |||
|
1131 | * | |||
|
1132 | * If the destination ID is not known, a dedicated counter is incremented. | |||
|
1133 | * | |||
|
1134 | */ | |||
1150 |
|
1135 | |||
1151 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1136 | unsigned short sequence_cnt; | |
|
1137 | unsigned short segmentation_grouping_flag; | |||
|
1138 | unsigned short new_packet_sequence_control; | |||
|
1139 | unsigned char i; | |||
|
1140 | ||||
|
1141 | switch (destination_id) | |||
1152 | { |
|
1142 | { | |
1153 | printf("kcoeff = %d *** ", kcoeff); |
|
1143 | case SID_TC_GROUND: | |
1154 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) |
|
1144 | i = GROUND; | |
1155 |
|
|
1145 | break; | |
1156 | printf( "%f ", k_coeff_intercalib_f0_norm[bin*NB_K_COEFF_PER_BIN+kcoeff] ); |
|
1146 | case SID_TC_MISSION_TIMELINE: | |
1157 | } |
|
1147 | i = MISSION_TIMELINE; | |
1158 | printf("\n"); |
|
1148 | break; | |
|
1149 | case SID_TC_TC_SEQUENCES: | |||
|
1150 | i = TC_SEQUENCES; | |||
|
1151 | break; | |||
|
1152 | case SID_TC_RECOVERY_ACTION_CMD: | |||
|
1153 | i = RECOVERY_ACTION_CMD; | |||
|
1154 | break; | |||
|
1155 | case SID_TC_BACKUP_MISSION_TIMELINE: | |||
|
1156 | i = BACKUP_MISSION_TIMELINE; | |||
|
1157 | break; | |||
|
1158 | case SID_TC_DIRECT_CMD: | |||
|
1159 | i = DIRECT_CMD; | |||
|
1160 | break; | |||
|
1161 | case SID_TC_SPARE_GRD_SRC1: | |||
|
1162 | i = SPARE_GRD_SRC1; | |||
|
1163 | break; | |||
|
1164 | case SID_TC_SPARE_GRD_SRC2: | |||
|
1165 | i = SPARE_GRD_SRC2; | |||
|
1166 | break; | |||
|
1167 | case SID_TC_OBCP: | |||
|
1168 | i = OBCP; | |||
|
1169 | break; | |||
|
1170 | case SID_TC_SYSTEM_CONTROL: | |||
|
1171 | i = SYSTEM_CONTROL; | |||
|
1172 | break; | |||
|
1173 | case SID_TC_AOCS: | |||
|
1174 | i = AOCS; | |||
|
1175 | break; | |||
|
1176 | case SID_TC_RPW_INTERNAL: | |||
|
1177 | i = RPW_INTERNAL; | |||
|
1178 | break; | |||
|
1179 | default: | |||
|
1180 | i = GROUND; | |||
|
1181 | break; | |||
1159 | } |
|
1182 | } | |
1160 |
|
1183 | |||
1161 | printf("\n"); |
|
1184 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
|
1185 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; | |||
|
1186 | ||||
|
1187 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |||
1162 |
|
1188 | |||
1163 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1189 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
|
1190 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |||
|
1191 | ||||
|
1192 | // increment the sequence counter | |||
|
1193 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |||
1164 | { |
|
1194 | { | |
1165 | printf("kcoeff = %d *** ", kcoeff); |
|
1195 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
1166 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) |
|
1196 | } | |
1167 | { |
|
1197 | else | |
1168 | printf( "[%f, %f] ", |
|
1198 | { | |
1169 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN )*2 + kcoeff], |
|
1199 | sequenceCounters_TM_DUMP[ i ] = 0; | |
1170 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN+1)*2 + kcoeff]); |
|
|||
1171 | } |
|
|||
1172 | printf("\n"); |
|
|||
1173 | } |
|
1200 | } | |
1174 | } |
|
1201 | } | |
1175 |
|
@@ -1,1372 +1,1373 | |||||
1 | /** Functions and tasks related to waveform packet generation. |
|
1 | /** Functions and tasks related to waveform packet generation. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 |
|
11 | |||
12 | //*************** |
|
12 | //*************** | |
13 | // waveform rings |
|
13 | // waveform rings | |
14 | // F0 |
|
14 | // F0 | |
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; | |
16 | ring_node *current_ring_node_f0; |
|
16 | ring_node *current_ring_node_f0; | |
17 | ring_node *ring_node_to_send_swf_f0; |
|
17 | ring_node *ring_node_to_send_swf_f0; | |
18 | // F1 |
|
18 | // F1 | |
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; | |
20 | ring_node *current_ring_node_f1; |
|
20 | ring_node *current_ring_node_f1; | |
21 | ring_node *ring_node_to_send_swf_f1; |
|
21 | ring_node *ring_node_to_send_swf_f1; | |
22 | ring_node *ring_node_to_send_cwf_f1; |
|
22 | ring_node *ring_node_to_send_cwf_f1; | |
23 | // F2 |
|
23 | // F2 | |
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; | |
25 | ring_node *current_ring_node_f2; |
|
25 | ring_node *current_ring_node_f2; | |
26 | ring_node *ring_node_to_send_swf_f2; |
|
26 | ring_node *ring_node_to_send_swf_f2; | |
27 | ring_node *ring_node_to_send_cwf_f2; |
|
27 | ring_node *ring_node_to_send_cwf_f2; | |
28 | // F3 |
|
28 | // F3 | |
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; |
|
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; | |
30 | ring_node *current_ring_node_f3; |
|
30 | ring_node *current_ring_node_f3; | |
31 | ring_node *ring_node_to_send_cwf_f3; |
|
31 | ring_node *ring_node_to_send_cwf_f3; | |
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; |
|
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; | |
33 |
|
33 | |||
34 | bool extractSWF = false; |
|
34 | bool extractSWF = false; | |
35 | bool swf_f0_ready = false; |
|
35 | bool swf_f0_ready = false; | |
36 | bool swf_f1_ready = false; |
|
36 | bool swf_f1_ready = false; | |
37 | bool swf_f2_ready = false; |
|
37 | bool swf_f2_ready = false; | |
38 |
|
38 | |||
39 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; |
|
39 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; | |
40 | ring_node ring_node_wf_snap_extracted; |
|
40 | ring_node ring_node_wf_snap_extracted; | |
41 |
|
41 | |||
42 | //********************* |
|
42 | //********************* | |
43 | // Interrupt SubRoutine |
|
43 | // Interrupt SubRoutine | |
44 |
|
44 | |||
45 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) |
|
45 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) | |
46 | { |
|
46 | { | |
47 | ring_node *node; |
|
47 | ring_node *node; | |
48 |
|
48 | |||
49 | node = NULL; |
|
49 | node = NULL; | |
50 | switch ( frequencyChannel ) { |
|
50 | switch ( frequencyChannel ) { | |
51 | case 1: |
|
51 | case 1: | |
52 | node = ring_node_to_send_cwf_f1; |
|
52 | node = ring_node_to_send_cwf_f1; | |
53 | break; |
|
53 | break; | |
54 | case 2: |
|
54 | case 2: | |
55 | node = ring_node_to_send_cwf_f2; |
|
55 | node = ring_node_to_send_cwf_f2; | |
56 | break; |
|
56 | break; | |
57 | case 3: |
|
57 | case 3: | |
58 | node = ring_node_to_send_cwf_f3; |
|
58 | node = ring_node_to_send_cwf_f3; | |
59 | break; |
|
59 | break; | |
60 | default: |
|
60 | default: | |
61 | break; |
|
61 | break; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | return node; |
|
64 | return node; | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) |
|
67 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) | |
68 | { |
|
68 | { | |
69 | ring_node *node; |
|
69 | ring_node *node; | |
70 |
|
70 | |||
71 | node = NULL; |
|
71 | node = NULL; | |
72 | switch ( frequencyChannel ) { |
|
72 | switch ( frequencyChannel ) { | |
73 | case 0: |
|
73 | case 0: | |
74 | node = ring_node_to_send_swf_f0; |
|
74 | node = ring_node_to_send_swf_f0; | |
75 | break; |
|
75 | break; | |
76 | case 1: |
|
76 | case 1: | |
77 | node = ring_node_to_send_swf_f1; |
|
77 | node = ring_node_to_send_swf_f1; | |
78 | break; |
|
78 | break; | |
79 | case 2: |
|
79 | case 2: | |
80 | node = ring_node_to_send_swf_f2; |
|
80 | node = ring_node_to_send_swf_f2; | |
81 | break; |
|
81 | break; | |
82 | default: |
|
82 | default: | |
83 | break; |
|
83 | break; | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | return node; |
|
86 | return node; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void reset_extractSWF( void ) |
|
89 | void reset_extractSWF( void ) | |
90 | { |
|
90 | { | |
91 | extractSWF = false; |
|
91 | extractSWF = false; | |
92 | swf_f0_ready = false; |
|
92 | swf_f0_ready = false; | |
93 | swf_f1_ready = false; |
|
93 | swf_f1_ready = false; | |
94 | swf_f2_ready = false; |
|
94 | swf_f2_ready = false; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | inline void waveforms_isr_f3( void ) |
|
97 | inline void waveforms_isr_f3( void ) | |
98 | { |
|
98 | { | |
99 | rtems_status_code spare_status; |
|
99 | rtems_status_code spare_status; | |
100 |
|
100 | |||
101 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet |
|
101 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet | |
102 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
102 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
103 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
103 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
104 | //*** |
|
104 | //*** | |
105 | // F3 |
|
105 | // F3 | |
106 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits |
|
106 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits | |
107 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; |
|
107 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; | |
108 | current_ring_node_f3 = current_ring_node_f3->next; |
|
108 | current_ring_node_f3 = current_ring_node_f3->next; | |
109 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full |
|
109 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full | |
110 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; |
|
110 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; | |
111 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; |
|
111 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; | |
112 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; |
|
112 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; | |
113 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] |
|
113 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] | |
114 | } |
|
114 | } | |
115 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full |
|
115 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full | |
116 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; |
|
116 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; | |
117 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; |
|
117 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; | |
118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; |
|
118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; | |
119 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] |
|
119 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] | |
120 | } |
|
120 | } | |
121 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
121 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
122 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
122 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
123 | } |
|
123 | } | |
124 | } |
|
124 | } | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | inline void waveforms_isr_normal( void ) |
|
128 | inline void waveforms_isr_normal( void ) | |
129 | { |
|
129 | { | |
130 | rtems_status_code status; |
|
130 | rtems_status_code status; | |
131 |
|
131 | |||
132 | if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits |
|
132 | if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits | |
133 | && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits |
|
133 | && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits | |
134 | && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits |
|
134 | && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits | |
135 | { |
|
135 | { | |
136 | //*** |
|
136 | //*** | |
137 | // F0 |
|
137 | // F0 | |
138 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
138 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
139 | current_ring_node_f0 = current_ring_node_f0->next; |
|
139 | current_ring_node_f0 = current_ring_node_f0->next; | |
140 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
140 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
141 | { |
|
141 | { | |
142 |
|
142 | |||
143 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
143 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
144 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
144 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
145 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
145 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
147 | } |
|
147 | } | |
148 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
148 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
149 | { |
|
149 | { | |
150 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
150 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
151 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
151 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
152 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
152 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
153 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
153 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | //*** |
|
156 | //*** | |
157 | // F1 |
|
157 | // F1 | |
158 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
158 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
159 | current_ring_node_f1 = current_ring_node_f1->next; |
|
159 | current_ring_node_f1 = current_ring_node_f1->next; | |
160 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
160 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
161 | { |
|
161 | { | |
162 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
162 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
163 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
163 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
164 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
164 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
165 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
165 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
166 | } |
|
166 | } | |
167 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
167 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
168 | { |
|
168 | { | |
169 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
169 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
170 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
170 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
171 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
171 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | //*** |
|
175 | //*** | |
176 | // F2 |
|
176 | // F2 | |
177 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
177 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
178 | current_ring_node_f2 = current_ring_node_f2->next; |
|
178 | current_ring_node_f2 = current_ring_node_f2->next; | |
179 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
179 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
180 | { |
|
180 | { | |
181 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
181 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
182 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
182 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
183 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
183 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
184 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
184 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
185 | } |
|
185 | } | |
186 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
186 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
187 | { |
|
187 | { | |
188 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
188 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
189 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
189 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
190 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
190 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
191 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
191 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
192 | } |
|
192 | } | |
193 | // |
|
193 | // | |
194 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); |
|
194 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); | |
195 | if ( status != RTEMS_SUCCESSFUL) |
|
195 | if ( status != RTEMS_SUCCESSFUL) | |
196 | { |
|
196 | { | |
197 | status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
197 | status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | inline void waveforms_isr_burst( void ) |
|
202 | inline void waveforms_isr_burst( void ) | |
203 | { |
|
203 | { | |
204 | unsigned char status; |
|
204 | unsigned char status; | |
205 | rtems_status_code spare_status; |
|
205 | rtems_status_code spare_status; | |
206 |
|
206 | |||
207 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 |
|
207 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 | |
208 |
|
208 | |||
209 |
|
209 | |||
210 | switch(status) |
|
210 | switch(status) | |
211 | { |
|
211 | { | |
212 | case 1: |
|
212 | case 1: | |
213 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
213 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
214 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
214 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
215 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
215 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
216 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
216 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
217 | current_ring_node_f2 = current_ring_node_f2->next; |
|
217 | current_ring_node_f2 = current_ring_node_f2->next; | |
218 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
218 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
219 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
219 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
220 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
220 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
221 | } |
|
221 | } | |
222 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
222 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
223 | break; |
|
223 | break; | |
224 | case 2: |
|
224 | case 2: | |
225 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
225 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
226 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
226 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
227 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
227 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
228 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
228 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
229 | current_ring_node_f2 = current_ring_node_f2->next; |
|
229 | current_ring_node_f2 = current_ring_node_f2->next; | |
230 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
230 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
231 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
231 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
232 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
232 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
233 | } |
|
233 | } | |
234 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
234 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
235 | break; |
|
235 | break; | |
236 | default: |
|
236 | default: | |
237 | break; |
|
237 | break; | |
238 | } |
|
238 | } | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | inline void waveforms_isr_sbm1( void ) |
|
241 | inline void waveforms_isr_sbm1( void ) | |
242 | { |
|
242 | { | |
243 | rtems_status_code status; |
|
243 | rtems_status_code status; | |
244 |
|
244 | |||
245 | //*** |
|
245 | //*** | |
246 | // F1 |
|
246 | // F1 | |
247 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits |
|
247 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits | |
248 | // (1) change the receiving buffer for the waveform picker |
|
248 | // (1) change the receiving buffer for the waveform picker | |
249 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; |
|
249 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; | |
250 | current_ring_node_f1 = current_ring_node_f1->next; |
|
250 | current_ring_node_f1 = current_ring_node_f1->next; | |
251 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
251 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
252 | { |
|
252 | { | |
253 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
253 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
254 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
254 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
255 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
255 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
256 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
256 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
257 | } |
|
257 | } | |
258 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
258 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
259 | { |
|
259 | { | |
260 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
260 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
261 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
261 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
262 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
262 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
263 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
263 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
264 | } |
|
264 | } | |
265 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
265 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
266 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
266 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | //*** |
|
269 | //*** | |
270 | // F0 |
|
270 | // F0 | |
271 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits |
|
271 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits | |
272 | swf_f0_ready = true; |
|
272 | swf_f0_ready = true; | |
273 | // change f0 buffer |
|
273 | // change f0 buffer | |
274 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
274 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
275 | current_ring_node_f0 = current_ring_node_f0->next; |
|
275 | current_ring_node_f0 = current_ring_node_f0->next; | |
276 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
276 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
277 | { |
|
277 | { | |
278 |
|
278 | |||
279 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
279 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
280 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
280 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
281 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
281 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
282 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
282 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
283 | } |
|
283 | } | |
284 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
284 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
285 | { |
|
285 | { | |
286 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
286 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
287 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
287 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
288 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
288 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
289 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
289 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | //*** |
|
293 | //*** | |
294 | // F2 |
|
294 | // F2 | |
295 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits |
|
295 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits | |
296 | swf_f2_ready = true; |
|
296 | swf_f2_ready = true; | |
297 | // change f2 buffer |
|
297 | // change f2 buffer | |
298 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
298 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
299 | current_ring_node_f2 = current_ring_node_f2->next; |
|
299 | current_ring_node_f2 = current_ring_node_f2->next; | |
300 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
300 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
301 | { |
|
301 | { | |
302 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
302 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
303 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
303 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
304 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
304 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
305 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
305 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
306 | } |
|
306 | } | |
307 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
307 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
308 | { |
|
308 | { | |
309 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
309 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
310 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
310 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
311 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
311 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
312 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
312 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
313 | } |
|
313 | } | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | inline void waveforms_isr_sbm2( void ) |
|
317 | inline void waveforms_isr_sbm2( void ) | |
318 | { |
|
318 | { | |
319 | rtems_status_code status; |
|
319 | rtems_status_code status; | |
320 |
|
320 | |||
321 | //*** |
|
321 | //*** | |
322 | // F2 |
|
322 | // F2 | |
323 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit |
|
323 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit | |
324 | // (1) change the receiving buffer for the waveform picker |
|
324 | // (1) change the receiving buffer for the waveform picker | |
325 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
325 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
326 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; |
|
326 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; | |
327 | current_ring_node_f2 = current_ring_node_f2->next; |
|
327 | current_ring_node_f2 = current_ring_node_f2->next; | |
328 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
328 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
329 | { |
|
329 | { | |
330 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
330 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
331 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
331 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
332 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
332 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
333 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
333 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
334 | } |
|
334 | } | |
335 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
335 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
336 | { |
|
336 | { | |
337 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
337 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
338 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
338 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
339 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
339 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
340 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
340 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
341 | } |
|
341 | } | |
342 | // (2) send an event for the waveforms transmission |
|
342 | // (2) send an event for the waveforms transmission | |
343 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
343 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | //*** |
|
346 | //*** | |
347 | // F0 |
|
347 | // F0 | |
348 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit |
|
348 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit | |
349 | swf_f0_ready = true; |
|
349 | swf_f0_ready = true; | |
350 | // change f0 buffer |
|
350 | // change f0 buffer | |
351 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
351 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
352 | current_ring_node_f0 = current_ring_node_f0->next; |
|
352 | current_ring_node_f0 = current_ring_node_f0->next; | |
353 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
353 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
354 | { |
|
354 | { | |
355 |
|
355 | |||
356 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
356 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
357 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
357 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
358 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
358 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
359 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
359 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
360 | } |
|
360 | } | |
361 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
361 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
362 | { |
|
362 | { | |
363 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
363 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
364 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
364 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
365 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
365 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
366 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
366 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | //*** |
|
370 | //*** | |
371 | // F1 |
|
371 | // F1 | |
372 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit |
|
372 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit | |
373 | swf_f1_ready = true; |
|
373 | swf_f1_ready = true; | |
374 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
374 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
375 | current_ring_node_f1 = current_ring_node_f1->next; |
|
375 | current_ring_node_f1 = current_ring_node_f1->next; | |
376 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
376 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
377 | { |
|
377 | { | |
378 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
378 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
379 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
379 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
380 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
380 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
381 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
381 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
382 | } |
|
382 | } | |
383 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
383 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
384 | { |
|
384 | { | |
385 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
385 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
386 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
386 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
387 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
387 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
388 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
388 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
389 | } |
|
389 | } | |
390 | } |
|
390 | } | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
393 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
394 | { |
|
394 | { | |
395 | /** This is the interrupt sub routine called by the waveform picker core. |
|
395 | /** This is the interrupt sub routine called by the waveform picker core. | |
396 | * |
|
396 | * | |
397 | * This ISR launch different actions depending mainly on two pieces of information: |
|
397 | * This ISR launch different actions depending mainly on two pieces of information: | |
398 | * 1. the values read in the registers of the waveform picker. |
|
398 | * 1. the values read in the registers of the waveform picker. | |
399 | * 2. the current LFR mode. |
|
399 | * 2. the current LFR mode. | |
400 | * |
|
400 | * | |
401 | */ |
|
401 | */ | |
402 |
|
402 | |||
403 | // STATUS |
|
403 | // STATUS | |
404 | // new error error buffer full |
|
404 | // new error error buffer full | |
405 | // 15 14 13 12 11 10 9 8 |
|
405 | // 15 14 13 12 11 10 9 8 | |
406 | // f3 f2 f1 f0 f3 f2 f1 f0 |
|
406 | // f3 f2 f1 f0 f3 f2 f1 f0 | |
407 | // |
|
407 | // | |
408 | // ready buffer |
|
408 | // ready buffer | |
409 | // 7 6 5 4 3 2 1 0 |
|
409 | // 7 6 5 4 3 2 1 0 | |
410 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 |
|
410 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 | |
411 |
|
411 | |||
412 | rtems_status_code spare_status; |
|
412 | rtems_status_code spare_status; | |
413 |
|
413 | |||
414 | waveforms_isr_f3(); |
|
414 | waveforms_isr_f3(); | |
415 |
|
415 | |||
416 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits |
|
416 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits | |
417 | { |
|
417 | { | |
418 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); |
|
418 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | switch(lfrCurrentMode) |
|
421 | switch(lfrCurrentMode) | |
422 | { |
|
422 | { | |
423 | //******** |
|
423 | //******** | |
424 | // STANDBY |
|
424 | // STANDBY | |
425 | case(LFR_MODE_STANDBY): |
|
425 | case(LFR_MODE_STANDBY): | |
426 | break; |
|
426 | break; | |
427 |
|
427 | |||
428 | //****** |
|
428 | //****** | |
429 | // NORMAL |
|
429 | // NORMAL | |
430 | case(LFR_MODE_NORMAL): |
|
430 | case(LFR_MODE_NORMAL): | |
431 | waveforms_isr_normal(); |
|
431 | waveforms_isr_normal(); | |
432 | break; |
|
432 | break; | |
433 |
|
433 | |||
434 | //****** |
|
434 | //****** | |
435 | // BURST |
|
435 | // BURST | |
436 | case(LFR_MODE_BURST): |
|
436 | case(LFR_MODE_BURST): | |
437 | waveforms_isr_burst(); |
|
437 | waveforms_isr_burst(); | |
438 | break; |
|
438 | break; | |
439 |
|
439 | |||
440 | //***** |
|
440 | //***** | |
441 | // SBM1 |
|
441 | // SBM1 | |
442 | case(LFR_MODE_SBM1): |
|
442 | case(LFR_MODE_SBM1): | |
443 | waveforms_isr_sbm1(); |
|
443 | waveforms_isr_sbm1(); | |
444 | break; |
|
444 | break; | |
445 |
|
445 | |||
446 | //***** |
|
446 | //***** | |
447 | // SBM2 |
|
447 | // SBM2 | |
448 | case(LFR_MODE_SBM2): |
|
448 | case(LFR_MODE_SBM2): | |
449 | waveforms_isr_sbm2(); |
|
449 | waveforms_isr_sbm2(); | |
450 | break; |
|
450 | break; | |
451 |
|
451 | |||
452 | //******** |
|
452 | //******** | |
453 | // DEFAULT |
|
453 | // DEFAULT | |
454 | default: |
|
454 | default: | |
455 | break; |
|
455 | break; | |
456 | } |
|
456 | } | |
457 | } |
|
457 | } | |
458 |
|
458 | |||
459 | //************ |
|
459 | //************ | |
460 | // RTEMS TASKS |
|
460 | // RTEMS TASKS | |
461 |
|
461 | |||
462 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
462 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
463 | { |
|
463 | { | |
464 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
464 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
465 | * |
|
465 | * | |
466 | * @param unused is the starting argument of the RTEMS task |
|
466 | * @param unused is the starting argument of the RTEMS task | |
467 | * |
|
467 | * | |
468 | * The following data packets are sent by this task: |
|
468 | * The following data packets are sent by this task: | |
469 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
469 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
470 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
470 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
471 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
471 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
472 | * |
|
472 | * | |
473 | */ |
|
473 | */ | |
474 |
|
474 | |||
475 | rtems_event_set event_out; |
|
475 | rtems_event_set event_out; | |
476 | rtems_id queue_id; |
|
476 | rtems_id queue_id; | |
477 | rtems_status_code status; |
|
477 | rtems_status_code status; | |
478 | bool resynchronisationEngaged; |
|
478 | bool resynchronisationEngaged; | |
479 | ring_node *ring_node_wf_snap_extracted_ptr; |
|
479 | ring_node *ring_node_wf_snap_extracted_ptr; | |
480 |
|
480 | |||
481 | ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted; |
|
481 | ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted; | |
482 |
|
482 | |||
483 | resynchronisationEngaged = false; |
|
483 | resynchronisationEngaged = false; | |
484 |
|
484 | |||
485 | status = get_message_queue_id_send( &queue_id ); |
|
485 | status = get_message_queue_id_send( &queue_id ); | |
486 | if (status != RTEMS_SUCCESSFUL) |
|
486 | if (status != RTEMS_SUCCESSFUL) | |
487 | { |
|
487 | { | |
488 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
488 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | BOOT_PRINTF("in WFRM ***\n") |
|
491 | BOOT_PRINTF("in WFRM ***\n") | |
492 |
|
492 | |||
493 | while(1){ |
|
493 | while(1){ | |
494 | // wait for an RTEMS_EVENT |
|
494 | // wait for an RTEMS_EVENT | |
495 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
495 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 | |
496 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
496 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, | |
497 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
497 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
498 | if(resynchronisationEngaged == false) |
|
498 | if(resynchronisationEngaged == false) | |
499 | { // engage resynchronisation |
|
499 | { // engage resynchronisation | |
500 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
500 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
501 | resynchronisationEngaged = true; |
|
501 | resynchronisationEngaged = true; | |
502 | } |
|
502 | } | |
503 | else |
|
503 | else | |
504 | { // reset delta_snapshot to the nominal value |
|
504 | { // reset delta_snapshot to the nominal value | |
505 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") |
|
505 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") | |
506 | set_wfp_delta_snapshot(); |
|
506 | set_wfp_delta_snapshot(); | |
507 | resynchronisationEngaged = false; |
|
507 | resynchronisationEngaged = false; | |
508 | } |
|
508 | } | |
509 | // |
|
509 | // | |
510 |
|
510 | |||
511 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
511 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
512 | { |
|
512 | { | |
513 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
513 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") | |
514 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
514 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
515 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; |
|
515 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; | |
516 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; |
|
516 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; | |
517 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
517 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
518 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); |
|
518 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); | |
519 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); |
|
519 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); | |
520 | } |
|
520 | } | |
521 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
521 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
522 | { |
|
522 | { | |
523 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
523 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") | |
524 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
524 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
525 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1; |
|
525 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1; | |
526 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; |
|
526 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; | |
527 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
527 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
528 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); |
|
528 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); | |
529 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); |
|
529 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); | |
530 | } |
|
530 | } | |
531 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
531 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
532 | { |
|
532 | { | |
533 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
533 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") | |
534 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
534 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
535 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; |
|
535 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; | |
536 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2; |
|
536 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2; | |
537 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
537 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
538 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); |
|
538 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); | |
539 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); |
|
539 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); | |
540 | } |
|
540 | } | |
541 | } |
|
541 | } | |
542 | } |
|
542 | } | |
543 |
|
543 | |||
544 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
544 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
545 | { |
|
545 | { | |
546 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
546 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
547 | * |
|
547 | * | |
548 | * @param unused is the starting argument of the RTEMS task |
|
548 | * @param unused is the starting argument of the RTEMS task | |
549 | * |
|
549 | * | |
550 | * The following data packet is sent by this task: |
|
550 | * The following data packet is sent by this task: | |
551 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
551 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
552 | * |
|
552 | * | |
553 | */ |
|
553 | */ | |
554 |
|
554 | |||
555 | rtems_event_set event_out; |
|
555 | rtems_event_set event_out; | |
556 | rtems_id queue_id; |
|
556 | rtems_id queue_id; | |
557 | rtems_status_code status; |
|
557 | rtems_status_code status; | |
558 | ring_node ring_node_cwf3_light; |
|
558 | ring_node ring_node_cwf3_light; | |
559 | ring_node *ring_node_to_send_cwf; |
|
559 | ring_node *ring_node_to_send_cwf; | |
560 |
|
560 | |||
561 | status = get_message_queue_id_send( &queue_id ); |
|
561 | status = get_message_queue_id_send( &queue_id ); | |
562 | if (status != RTEMS_SUCCESSFUL) |
|
562 | if (status != RTEMS_SUCCESSFUL) | |
563 | { |
|
563 | { | |
564 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
564 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
565 | } |
|
565 | } | |
566 |
|
566 | |||
567 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
567 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
568 |
|
568 | |||
569 | // init the ring_node_cwf3_light structure |
|
569 | // init the ring_node_cwf3_light structure | |
570 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; |
|
570 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; | |
571 | ring_node_cwf3_light.coarseTime = 0x00; |
|
571 | ring_node_cwf3_light.coarseTime = 0x00; | |
572 | ring_node_cwf3_light.fineTime = 0x00; |
|
572 | ring_node_cwf3_light.fineTime = 0x00; | |
573 | ring_node_cwf3_light.next = NULL; |
|
573 | ring_node_cwf3_light.next = NULL; | |
574 | ring_node_cwf3_light.previous = NULL; |
|
574 | ring_node_cwf3_light.previous = NULL; | |
575 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; |
|
575 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; | |
576 | ring_node_cwf3_light.status = 0x00; |
|
576 | ring_node_cwf3_light.status = 0x00; | |
577 |
|
577 | |||
578 | BOOT_PRINTF("in CWF3 ***\n") |
|
578 | BOOT_PRINTF("in CWF3 ***\n") | |
579 |
|
579 | |||
580 | while(1){ |
|
580 | while(1){ | |
581 | // wait for an RTEMS_EVENT |
|
581 | // wait for an RTEMS_EVENT | |
582 | rtems_event_receive( RTEMS_EVENT_0, |
|
582 | rtems_event_receive( RTEMS_EVENT_0, | |
583 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
583 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
584 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
584 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
585 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
585 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) | |
586 | { |
|
586 | { | |
587 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); |
|
587 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); | |
588 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
588 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
589 | { |
|
589 | { | |
590 | PRINTF("send CWF_LONG_F3\n") |
|
590 | PRINTF("send CWF_LONG_F3\n") | |
591 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
591 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
592 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
592 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
593 | } |
|
593 | } | |
594 | else |
|
594 | else | |
595 | { |
|
595 | { | |
596 | PRINTF("send CWF_F3 (light)\n") |
|
596 | PRINTF("send CWF_F3 (light)\n") | |
597 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); |
|
597 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); | |
598 | } |
|
598 | } | |
599 |
|
599 | |||
600 | } |
|
600 | } | |
601 | else |
|
601 | else | |
602 | { |
|
602 | { | |
603 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
603 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) | |
604 | } |
|
604 | } | |
605 | } |
|
605 | } | |
606 | } |
|
606 | } | |
607 |
|
607 | |||
608 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
608 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
609 | { |
|
609 | { | |
610 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
610 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
611 | * |
|
611 | * | |
612 | * @param unused is the starting argument of the RTEMS task |
|
612 | * @param unused is the starting argument of the RTEMS task | |
613 | * |
|
613 | * | |
614 | * The following data packet is sent by this function: |
|
614 | * The following data packet is sent by this function: | |
615 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
615 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
616 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
616 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
617 | * |
|
617 | * | |
618 | */ |
|
618 | */ | |
619 |
|
619 | |||
620 | rtems_event_set event_out; |
|
620 | rtems_event_set event_out; | |
621 | rtems_id queue_id; |
|
621 | rtems_id queue_id; | |
622 | rtems_status_code status; |
|
622 | rtems_status_code status; | |
623 | ring_node *ring_node_to_send; |
|
623 | ring_node *ring_node_to_send; | |
624 | unsigned long long int acquisitionTimeF0_asLong; |
|
624 | unsigned long long int acquisitionTimeF0_asLong; | |
625 |
|
625 | |||
626 | acquisitionTimeF0_asLong = 0x00; |
|
626 | acquisitionTimeF0_asLong = 0x00; | |
627 |
|
627 | |||
628 | status = get_message_queue_id_send( &queue_id ); |
|
628 | status = get_message_queue_id_send( &queue_id ); | |
629 | if (status != RTEMS_SUCCESSFUL) |
|
629 | if (status != RTEMS_SUCCESSFUL) | |
630 | { |
|
630 | { | |
631 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
631 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
632 | } |
|
632 | } | |
633 |
|
633 | |||
634 | BOOT_PRINTF("in CWF2 ***\n") |
|
634 | BOOT_PRINTF("in CWF2 ***\n") | |
635 |
|
635 | |||
636 | while(1){ |
|
636 | while(1){ | |
637 | // wait for an RTEMS_EVENT |
|
637 | // wait for an RTEMS_EVENT | |
638 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
638 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, | |
639 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
639 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
640 | ring_node_to_send = getRingNodeToSendCWF( 2 ); |
|
640 | ring_node_to_send = getRingNodeToSendCWF( 2 ); | |
641 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
641 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
642 | { |
|
642 | { | |
643 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
643 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
644 | } |
|
644 | } | |
645 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
645 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
646 | { |
|
646 | { | |
647 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
647 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
648 | // launch snapshot extraction if needed |
|
648 | // launch snapshot extraction if needed | |
649 | if (extractSWF == true) |
|
649 | if (extractSWF == true) | |
650 | { |
|
650 | { | |
651 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
651 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
652 | // extract the snapshot |
|
652 | // extract the snapshot | |
653 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong ); |
|
653 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong ); | |
654 | // send the snapshot when built |
|
654 | // send the snapshot when built | |
655 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
655 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
656 | extractSWF = false; |
|
656 | extractSWF = false; | |
657 | } |
|
657 | } | |
658 | if (swf_f0_ready && swf_f1_ready) |
|
658 | if (swf_f0_ready && swf_f1_ready) | |
659 | { |
|
659 | { | |
660 | extractSWF = true; |
|
660 | extractSWF = true; | |
661 | // record the acquition time of the fΓ snapshot to use to build the snapshot at f2 |
|
661 | // record the acquition time of the fΓ snapshot to use to build the snapshot at f2 | |
662 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
662 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
663 | swf_f0_ready = false; |
|
663 | swf_f0_ready = false; | |
664 | swf_f1_ready = false; |
|
664 | swf_f1_ready = false; | |
665 | } |
|
665 | } | |
666 | } |
|
666 | } | |
667 | } |
|
667 | } | |
668 | } |
|
668 | } | |
669 |
|
669 | |||
670 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
670 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
671 | { |
|
671 | { | |
672 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
672 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
673 | * |
|
673 | * | |
674 | * @param unused is the starting argument of the RTEMS task |
|
674 | * @param unused is the starting argument of the RTEMS task | |
675 | * |
|
675 | * | |
676 | * The following data packet is sent by this function: |
|
676 | * The following data packet is sent by this function: | |
677 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
677 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
678 | * |
|
678 | * | |
679 | */ |
|
679 | */ | |
680 |
|
680 | |||
681 | rtems_event_set event_out; |
|
681 | rtems_event_set event_out; | |
682 | rtems_id queue_id; |
|
682 | rtems_id queue_id; | |
683 | rtems_status_code status; |
|
683 | rtems_status_code status; | |
684 |
|
684 | |||
685 | ring_node *ring_node_to_send_cwf; |
|
685 | ring_node *ring_node_to_send_cwf; | |
686 |
|
686 | |||
687 | status = get_message_queue_id_send( &queue_id ); |
|
687 | status = get_message_queue_id_send( &queue_id ); | |
688 | if (status != RTEMS_SUCCESSFUL) |
|
688 | if (status != RTEMS_SUCCESSFUL) | |
689 | { |
|
689 | { | |
690 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
690 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
691 | } |
|
691 | } | |
692 |
|
692 | |||
693 | BOOT_PRINTF("in CWF1 ***\n") |
|
693 | BOOT_PRINTF("in CWF1 ***\n") | |
694 |
|
694 | |||
695 | while(1){ |
|
695 | while(1){ | |
696 | // wait for an RTEMS_EVENT |
|
696 | // wait for an RTEMS_EVENT | |
697 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
697 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, | |
698 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
698 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
699 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); |
|
699 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); | |
700 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; |
|
700 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; | |
701 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
701 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
702 | if (status != 0) |
|
702 | if (status != 0) | |
703 | printf("cwf sending failed\n"); |
|
703 | { | |
|
704 | PRINTF("cwf sending failed\n") | |||
|
705 | } | |||
704 | // launch snapshot extraction if needed |
|
706 | // launch snapshot extraction if needed | |
705 | if (extractSWF == true) |
|
707 | if (extractSWF == true) | |
706 | { |
|
708 | { | |
707 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; |
|
709 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; | |
708 | // launch the snapshot extraction |
|
710 | // launch the snapshot extraction | |
709 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
711 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); | |
710 | extractSWF = false; |
|
712 | extractSWF = false; | |
711 | } |
|
713 | } | |
712 | if (swf_f0_ready == true) |
|
714 | if (swf_f0_ready == true) | |
713 | { |
|
715 | { | |
714 | extractSWF = true; |
|
716 | extractSWF = true; | |
715 | swf_f0_ready = false; // this step shall be executed only one time |
|
717 | swf_f0_ready = false; // this step shall be executed only one time | |
716 | } |
|
718 | } | |
717 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
719 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction | |
718 | { |
|
720 | { | |
719 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
721 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); | |
720 | swf_f1_ready = false; |
|
722 | swf_f1_ready = false; | |
721 | swf_f2_ready = false; |
|
723 | swf_f2_ready = false; | |
722 | } |
|
724 | } | |
723 | } |
|
725 | } | |
724 | } |
|
726 | } | |
725 |
|
727 | |||
726 | rtems_task swbd_task(rtems_task_argument argument) |
|
728 | rtems_task swbd_task(rtems_task_argument argument) | |
727 | { |
|
729 | { | |
728 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
730 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. | |
729 | * |
|
731 | * | |
730 | * @param unused is the starting argument of the RTEMS task |
|
732 | * @param unused is the starting argument of the RTEMS task | |
731 | * |
|
733 | * | |
732 | */ |
|
734 | */ | |
733 |
|
735 | |||
734 | rtems_event_set event_out; |
|
736 | rtems_event_set event_out; | |
735 | unsigned long long int acquisitionTimeF0_asLong; |
|
737 | unsigned long long int acquisitionTimeF0_asLong; | |
736 |
|
738 | |||
737 | acquisitionTimeF0_asLong = 0x00; |
|
739 | acquisitionTimeF0_asLong = 0x00; | |
738 |
|
740 | |||
739 | BOOT_PRINTF("in SWBD ***\n") |
|
741 | BOOT_PRINTF("in SWBD ***\n") | |
740 |
|
742 | |||
741 | while(1){ |
|
743 | while(1){ | |
742 | // wait for an RTEMS_EVENT |
|
744 | // wait for an RTEMS_EVENT | |
743 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
745 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, | |
744 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
746 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
745 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
747 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
746 | { |
|
748 | { | |
747 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
749 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
748 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong ); |
|
750 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong ); | |
749 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
751 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent | |
750 | } |
|
752 | } | |
751 | else |
|
753 | else | |
752 | { |
|
754 | { | |
753 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
755 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) | |
754 | } |
|
756 | } | |
755 | } |
|
757 | } | |
756 | } |
|
758 | } | |
757 |
|
759 | |||
758 | //****************** |
|
760 | //****************** | |
759 | // general functions |
|
761 | // general functions | |
760 |
|
762 | |||
761 | void WFP_init_rings( void ) |
|
763 | void WFP_init_rings( void ) | |
762 | { |
|
764 | { | |
763 | // F0 RING |
|
765 | // F0 RING | |
764 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); |
|
766 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); | |
765 | // F1 RING |
|
767 | // F1 RING | |
766 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); |
|
768 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); | |
767 | // F2 RING |
|
769 | // F2 RING | |
768 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); |
|
770 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); | |
769 | // F3 RING |
|
771 | // F3 RING | |
770 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); |
|
772 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); | |
771 |
|
773 | |||
772 | ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted; |
|
774 | ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted; | |
773 |
|
775 | |||
774 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
776 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
775 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
777 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
776 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
778 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
777 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
779 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) | |
778 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) |
|
780 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) | |
779 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) |
|
781 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) | |
780 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) |
|
782 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) | |
781 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) |
|
783 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) | |
782 |
|
784 | |||
783 | } |
|
785 | } | |
784 |
|
786 | |||
785 | void WFP_reset_current_ring_nodes( void ) |
|
787 | void WFP_reset_current_ring_nodes( void ) | |
786 | { |
|
788 | { | |
787 | current_ring_node_f0 = waveform_ring_f0[0].next; |
|
789 | current_ring_node_f0 = waveform_ring_f0[0].next; | |
788 | current_ring_node_f1 = waveform_ring_f1[0].next; |
|
790 | current_ring_node_f1 = waveform_ring_f1[0].next; | |
789 | current_ring_node_f2 = waveform_ring_f2[0].next; |
|
791 | current_ring_node_f2 = waveform_ring_f2[0].next; | |
790 | current_ring_node_f3 = waveform_ring_f3[0].next; |
|
792 | current_ring_node_f3 = waveform_ring_f3[0].next; | |
791 |
|
793 | |||
792 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
794 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
793 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
795 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
794 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
796 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
795 |
|
797 | |||
796 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
798 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
797 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
799 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
798 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
800 | ring_node_to_send_cwf_f3 = waveform_ring_f3; | |
799 | } |
|
801 | } | |
800 |
|
802 | |||
801 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) |
|
803 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) | |
802 | { |
|
804 | { | |
803 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
805 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
804 | * |
|
806 | * | |
805 | * @param waveform points to the buffer containing the data that will be send. |
|
807 | * @param waveform points to the buffer containing the data that will be send. | |
806 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
808 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
807 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
809 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
808 | * contain information to setup the transmission of the data packets. |
|
810 | * contain information to setup the transmission of the data packets. | |
809 | * |
|
811 | * | |
810 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
812 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
811 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
813 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
812 | * |
|
814 | * | |
813 | */ |
|
815 | */ | |
814 |
|
816 | |||
815 | unsigned int i; |
|
817 | unsigned int i; | |
816 | int ret; |
|
818 | int ret; | |
817 | rtems_status_code status; |
|
819 | rtems_status_code status; | |
818 |
|
820 | |||
819 | char *sample; |
|
821 | char *sample; | |
820 | int *dataPtr; |
|
822 | int *dataPtr; | |
821 |
|
823 | |||
822 | ret = LFR_DEFAULT; |
|
824 | ret = LFR_DEFAULT; | |
823 |
|
825 | |||
824 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
826 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
825 |
|
827 | |||
826 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; |
|
828 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; | |
827 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; |
|
829 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; | |
828 |
|
830 | |||
829 | //********************** |
|
831 | //********************** | |
830 | // BUILD CWF3_light DATA |
|
832 | // BUILD CWF3_light DATA | |
831 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
833 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
832 | { |
|
834 | { | |
833 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; |
|
835 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; | |
834 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; | |
835 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
837 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; | |
836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
838 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; | |
837 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
839 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; | |
838 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
840 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; | |
839 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
841 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; | |
840 | } |
|
842 | } | |
841 |
|
843 | |||
842 | // SEND PACKET |
|
844 | // SEND PACKET | |
843 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); |
|
845 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); | |
844 | if (status != RTEMS_SUCCESSFUL) { |
|
846 | if (status != RTEMS_SUCCESSFUL) { | |
845 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
|||
846 | ret = LFR_DEFAULT; |
|
847 | ret = LFR_DEFAULT; | |
847 | } |
|
848 | } | |
848 |
|
849 | |||
849 | return ret; |
|
850 | return ret; | |
850 | } |
|
851 | } | |
851 |
|
852 | |||
852 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
853 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
853 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
854 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |
854 | { |
|
855 | { | |
855 | unsigned long long int acquisitionTimeAsLong; |
|
856 | unsigned long long int acquisitionTimeAsLong; | |
856 | unsigned char localAcquisitionTime[6]; |
|
857 | unsigned char localAcquisitionTime[6]; | |
857 | double deltaT; |
|
858 | double deltaT; | |
858 |
|
859 | |||
859 | deltaT = 0.; |
|
860 | deltaT = 0.; | |
860 |
|
861 | |||
861 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
862 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); | |
862 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
863 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); | |
863 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
864 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); | |
864 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
865 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); | |
865 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
866 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); | |
866 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
867 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); | |
867 |
|
868 | |||
868 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
869 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) | |
869 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
870 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) | |
870 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
871 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) | |
871 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
872 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) | |
872 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
873 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) | |
873 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
874 | + ( (unsigned long long int) localAcquisitionTime[5] ); | |
874 |
|
875 | |||
875 | switch( sid ) |
|
876 | switch( sid ) | |
876 | { |
|
877 | { | |
877 | case SID_NORM_SWF_F0: |
|
878 | case SID_NORM_SWF_F0: | |
878 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
879 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; | |
879 | break; |
|
880 | break; | |
880 |
|
881 | |||
881 | case SID_NORM_SWF_F1: |
|
882 | case SID_NORM_SWF_F1: | |
882 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
883 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; | |
883 | break; |
|
884 | break; | |
884 |
|
885 | |||
885 | case SID_NORM_SWF_F2: |
|
886 | case SID_NORM_SWF_F2: | |
886 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
887 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; | |
887 | break; |
|
888 | break; | |
888 |
|
889 | |||
889 | case SID_SBM1_CWF_F1: |
|
890 | case SID_SBM1_CWF_F1: | |
890 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
891 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; | |
891 | break; |
|
892 | break; | |
892 |
|
893 | |||
893 | case SID_SBM2_CWF_F2: |
|
894 | case SID_SBM2_CWF_F2: | |
894 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
895 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
895 | break; |
|
896 | break; | |
896 |
|
897 | |||
897 | case SID_BURST_CWF_F2: |
|
898 | case SID_BURST_CWF_F2: | |
898 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
899 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
899 | break; |
|
900 | break; | |
900 |
|
901 | |||
901 | case SID_NORM_CWF_F3: |
|
902 | case SID_NORM_CWF_F3: | |
902 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
903 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; | |
903 | break; |
|
904 | break; | |
904 |
|
905 | |||
905 | case SID_NORM_CWF_LONG_F3: |
|
906 | case SID_NORM_CWF_LONG_F3: | |
906 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
907 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; | |
907 | break; |
|
908 | break; | |
908 |
|
909 | |||
909 | default: |
|
910 | default: | |
910 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) |
|
911 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) | |
911 | deltaT = 0.; |
|
912 | deltaT = 0.; | |
912 | break; |
|
913 | break; | |
913 | } |
|
914 | } | |
914 |
|
915 | |||
915 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
916 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
916 | // |
|
917 | // | |
917 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
918 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); | |
918 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
919 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); | |
919 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
920 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); | |
920 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
921 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); | |
921 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
922 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); | |
922 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
923 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); | |
923 |
|
924 | |||
924 | } |
|
925 | } | |
925 |
|
926 | |||
926 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong ) |
|
927 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong ) | |
927 | { |
|
928 | { | |
928 | unsigned int i; |
|
929 | unsigned int i; | |
929 | unsigned long long int centerTime_asLong; |
|
930 | unsigned long long int centerTime_asLong; | |
930 | unsigned long long int acquisitionTime_asLong; |
|
931 | unsigned long long int acquisitionTime_asLong; | |
931 | unsigned long long int bufferAcquisitionTime_asLong; |
|
932 | unsigned long long int bufferAcquisitionTime_asLong; | |
932 | unsigned char *ptr1; |
|
933 | unsigned char *ptr1; | |
933 | unsigned char *ptr2; |
|
934 | unsigned char *ptr2; | |
934 | unsigned char *timeCharPtr; |
|
935 | unsigned char *timeCharPtr; | |
935 | unsigned char nb_ring_nodes; |
|
936 | unsigned char nb_ring_nodes; | |
936 | unsigned long long int frequency_asLong; |
|
937 | unsigned long long int frequency_asLong; | |
937 | unsigned long long int nbTicksPerSample_asLong; |
|
938 | unsigned long long int nbTicksPerSample_asLong; | |
938 | unsigned long long int nbSamplesPart1_asLong; |
|
939 | unsigned long long int nbSamplesPart1_asLong; | |
939 | unsigned long long int sampleOffset_asLong; |
|
940 | unsigned long long int sampleOffset_asLong; | |
940 |
|
941 | |||
941 | unsigned int deltaT_F0; |
|
942 | unsigned int deltaT_F0; | |
942 | unsigned int deltaT_F1; |
|
943 | unsigned int deltaT_F1; | |
943 | unsigned long long int deltaT_F2; |
|
944 | unsigned long long int deltaT_F2; | |
944 |
|
945 | |||
945 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
946 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
946 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
947 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; | |
947 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
948 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; | |
948 | sampleOffset_asLong = 0x00; |
|
949 | sampleOffset_asLong = 0x00; | |
949 |
|
950 | |||
950 | // (1) get the f0 acquisition time => the value is passed in argument |
|
951 | // (1) get the f0 acquisition time => the value is passed in argument | |
951 |
|
952 | |||
952 | // (2) compute the central reference time |
|
953 | // (2) compute the central reference time | |
953 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
954 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; | |
954 |
|
955 | |||
955 | // (3) compute the acquisition time of the current snapshot |
|
956 | // (3) compute the acquisition time of the current snapshot | |
956 | switch(frequencyChannel) |
|
957 | switch(frequencyChannel) | |
957 | { |
|
958 | { | |
958 | case 1: // 1 is for F1 = 4096 Hz |
|
959 | case 1: // 1 is for F1 = 4096 Hz | |
959 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
960 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; | |
960 | nb_ring_nodes = NB_RING_NODES_F1; |
|
961 | nb_ring_nodes = NB_RING_NODES_F1; | |
961 | frequency_asLong = 4096; |
|
962 | frequency_asLong = 4096; | |
962 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
963 | nbTicksPerSample_asLong = 16; // 65536 / 4096; | |
963 | break; |
|
964 | break; | |
964 | case 2: // 2 is for F2 = 256 Hz |
|
965 | case 2: // 2 is for F2 = 256 Hz | |
965 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
966 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; | |
966 | nb_ring_nodes = NB_RING_NODES_F2; |
|
967 | nb_ring_nodes = NB_RING_NODES_F2; | |
967 | frequency_asLong = 256; |
|
968 | frequency_asLong = 256; | |
968 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
969 | nbTicksPerSample_asLong = 256; // 65536 / 256; | |
969 | break; |
|
970 | break; | |
970 | default: |
|
971 | default: | |
971 | acquisitionTime_asLong = centerTime_asLong; |
|
972 | acquisitionTime_asLong = centerTime_asLong; | |
972 | frequency_asLong = 256; |
|
973 | frequency_asLong = 256; | |
973 | nbTicksPerSample_asLong = 256; |
|
974 | nbTicksPerSample_asLong = 256; | |
974 | break; |
|
975 | break; | |
975 | } |
|
976 | } | |
976 |
|
977 | |||
977 | //**************************************************************************** |
|
978 | //**************************************************************************** | |
978 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
979 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong | |
979 | for (i=0; i<nb_ring_nodes; i++) |
|
980 | for (i=0; i<nb_ring_nodes; i++) | |
980 | { |
|
981 | { | |
981 | PRINTF1("%d ... ", i) |
|
982 | PRINTF1("%d ... ", i) | |
982 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); |
|
983 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); | |
983 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
984 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) | |
984 | { |
|
985 | { | |
985 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
986 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) | |
986 | break; |
|
987 | break; | |
987 | } |
|
988 | } | |
988 | ring_node_to_send = ring_node_to_send->previous; |
|
989 | ring_node_to_send = ring_node_to_send->previous; | |
989 | } |
|
990 | } | |
990 |
|
991 | |||
991 | // (5) compute the number of samples to take in the current buffer |
|
992 | // (5) compute the number of samples to take in the current buffer | |
992 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
993 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; | |
993 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
994 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; | |
994 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
995 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) | |
995 |
|
996 | |||
996 | // (6) compute the final acquisition time |
|
997 | // (6) compute the final acquisition time | |
997 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
998 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + | |
998 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
999 | sampleOffset_asLong * nbTicksPerSample_asLong; | |
999 |
|
1000 | |||
1000 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
1001 | // (7) copy the acquisition time at the beginning of the extrated snapshot | |
1001 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
1002 | ptr1 = (unsigned char*) &acquisitionTime_asLong; | |
1002 | // fine time |
|
1003 | // fine time | |
1003 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime; |
|
1004 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime; | |
1004 | ptr2[2] = ptr1[ 4 + 2 ]; |
|
1005 | ptr2[2] = ptr1[ 4 + 2 ]; | |
1005 | ptr2[3] = ptr1[ 5 + 2 ]; |
|
1006 | ptr2[3] = ptr1[ 5 + 2 ]; | |
1006 | // coarse time |
|
1007 | // coarse time | |
1007 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime; |
|
1008 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime; | |
1008 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
1009 | ptr2[0] = ptr1[ 0 + 2 ]; | |
1009 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
1010 | ptr2[1] = ptr1[ 1 + 2 ]; | |
1010 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
1011 | ptr2[2] = ptr1[ 2 + 2 ]; | |
1011 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
1012 | ptr2[3] = ptr1[ 3 + 2 ]; | |
1012 |
|
1013 | |||
1013 | // re set the synchronization bit |
|
1014 | // re set the synchronization bit | |
1014 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; |
|
1015 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; | |
1015 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
1016 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] | |
1016 |
|
1017 | |||
1017 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
1018 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) | |
1018 | { |
|
1019 | { | |
1019 | nbSamplesPart1_asLong = 0; |
|
1020 | nbSamplesPart1_asLong = 0; | |
1020 | } |
|
1021 | } | |
1021 | // copy the part 1 of the snapshot in the extracted buffer |
|
1022 | // copy the part 1 of the snapshot in the extracted buffer | |
1022 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1023 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) | |
1023 | { |
|
1024 | { | |
1024 | wf_snap_extracted[i] = |
|
1025 | wf_snap_extracted[i] = | |
1025 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; |
|
1026 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; | |
1026 | } |
|
1027 | } | |
1027 | // copy the part 2 of the snapshot in the extracted buffer |
|
1028 | // copy the part 2 of the snapshot in the extracted buffer | |
1028 | ring_node_to_send = ring_node_to_send->next; |
|
1029 | ring_node_to_send = ring_node_to_send->next; | |
1029 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1030 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) | |
1030 | { |
|
1031 | { | |
1031 | wf_snap_extracted[i] = |
|
1032 | wf_snap_extracted[i] = | |
1032 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; |
|
1033 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; | |
1033 | } |
|
1034 | } | |
1034 | } |
|
1035 | } | |
1035 |
|
1036 | |||
1036 | void snapshot_resynchronization( unsigned char *timePtr ) |
|
1037 | void snapshot_resynchronization( unsigned char *timePtr ) | |
1037 | { |
|
1038 | { | |
1038 | unsigned long long int acquisitionTime; |
|
1039 | unsigned long long int acquisitionTime; | |
1039 | unsigned long long int centerTime; |
|
1040 | unsigned long long int centerTime; | |
1040 | unsigned long long int previousTick; |
|
1041 | unsigned long long int previousTick; | |
1041 | unsigned long long int nextTick; |
|
1042 | unsigned long long int nextTick; | |
1042 | unsigned long long int deltaPreviousTick; |
|
1043 | unsigned long long int deltaPreviousTick; | |
1043 | unsigned long long int deltaNextTick; |
|
1044 | unsigned long long int deltaNextTick; | |
1044 | unsigned int deltaTickInF2; |
|
1045 | unsigned int deltaTickInF2; | |
1045 | double deltaPrevious; |
|
1046 | double deltaPrevious; | |
1046 | double deltaNext; |
|
1047 | double deltaNext; | |
1047 |
|
1048 | |||
1048 | acquisitionTime = get_acquisition_time( timePtr ); |
|
1049 | acquisitionTime = get_acquisition_time( timePtr ); | |
1049 |
|
1050 | |||
1050 | // compute center time |
|
1051 | // compute center time | |
1051 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
1052 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
1052 | previousTick = centerTime - (centerTime & 0xffff); |
|
1053 | previousTick = centerTime - (centerTime & 0xffff); | |
1053 | nextTick = previousTick + 65536; |
|
1054 | nextTick = previousTick + 65536; | |
1054 |
|
1055 | |||
1055 | deltaPreviousTick = centerTime - previousTick; |
|
1056 | deltaPreviousTick = centerTime - previousTick; | |
1056 | deltaNextTick = nextTick - centerTime; |
|
1057 | deltaNextTick = nextTick - centerTime; | |
1057 |
|
1058 | |||
1058 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; |
|
1059 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; | |
1059 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; |
|
1060 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; | |
1060 |
|
1061 | |||
1061 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext) |
|
1062 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext) | |
1062 | PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick) |
|
1063 | PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick) | |
1063 |
|
1064 | |||
1064 | // which tick is the closest |
|
1065 | // which tick is the closest | |
1065 | if (deltaPreviousTick > deltaNextTick) |
|
1066 | if (deltaPreviousTick > deltaNextTick) | |
1066 | { |
|
1067 | { | |
1067 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here |
|
1068 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here | |
1068 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; |
|
1069 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; | |
1069 |
|
|
1070 | PRINTF1("correction of = + %u\n", deltaTickInF2) | |
1070 | } |
|
1071 | } | |
1071 | else |
|
1072 | else | |
1072 | { |
|
1073 | { | |
1073 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here |
|
1074 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here | |
1074 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; |
|
1075 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; | |
1075 |
|
|
1076 | PRINTF1("correction of = - %u\n", deltaTickInF2) | |
1076 | } |
|
1077 | } | |
1077 | } |
|
1078 | } | |
1078 |
|
1079 | |||
1079 | //************** |
|
1080 | //************** | |
1080 | // wfp registers |
|
1081 | // wfp registers | |
1081 | void reset_wfp_burst_enable( void ) |
|
1082 | void reset_wfp_burst_enable( void ) | |
1082 | { |
|
1083 | { | |
1083 | /** This function resets the waveform picker burst_enable register. |
|
1084 | /** This function resets the waveform picker burst_enable register. | |
1084 | * |
|
1085 | * | |
1085 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1086 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1086 | * |
|
1087 | * | |
1087 | */ |
|
1088 | */ | |
1088 |
|
1089 | |||
1089 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1090 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 | |
1090 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; |
|
1091 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; | |
1091 | } |
|
1092 | } | |
1092 |
|
1093 | |||
1093 | void reset_wfp_status( void ) |
|
1094 | void reset_wfp_status( void ) | |
1094 | { |
|
1095 | { | |
1095 | /** This function resets the waveform picker status register. |
|
1096 | /** This function resets the waveform picker status register. | |
1096 | * |
|
1097 | * | |
1097 | * All status bits are set to 0 [new_err full_err full]. |
|
1098 | * All status bits are set to 0 [new_err full_err full]. | |
1098 | * |
|
1099 | * | |
1099 | */ |
|
1100 | */ | |
1100 |
|
1101 | |||
1101 | waveform_picker_regs->status = 0xffff; |
|
1102 | waveform_picker_regs->status = 0xffff; | |
1102 | } |
|
1103 | } | |
1103 |
|
1104 | |||
1104 | void reset_wfp_buffer_addresses( void ) |
|
1105 | void reset_wfp_buffer_addresses( void ) | |
1105 | { |
|
1106 | { | |
1106 | // F0 |
|
1107 | // F0 | |
1107 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 |
|
1108 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 | |
1108 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c |
|
1109 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c | |
1109 | // F1 |
|
1110 | // F1 | |
1110 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 |
|
1111 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 | |
1111 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 |
|
1112 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 | |
1112 | // F2 |
|
1113 | // F2 | |
1113 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 |
|
1114 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 | |
1114 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c |
|
1115 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c | |
1115 | // F3 |
|
1116 | // F3 | |
1116 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 |
|
1117 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 | |
1117 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 |
|
1118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 | |
1118 | } |
|
1119 | } | |
1119 |
|
1120 | |||
1120 | void reset_waveform_picker_regs( void ) |
|
1121 | void reset_waveform_picker_regs( void ) | |
1121 | { |
|
1122 | { | |
1122 | /** This function resets the waveform picker module registers. |
|
1123 | /** This function resets the waveform picker module registers. | |
1123 | * |
|
1124 | * | |
1124 | * The registers affected by this function are located at the following offset addresses: |
|
1125 | * The registers affected by this function are located at the following offset addresses: | |
1125 | * - 0x00 data_shaping |
|
1126 | * - 0x00 data_shaping | |
1126 | * - 0x04 run_burst_enable |
|
1127 | * - 0x04 run_burst_enable | |
1127 | * - 0x08 addr_data_f0 |
|
1128 | * - 0x08 addr_data_f0 | |
1128 | * - 0x0C addr_data_f1 |
|
1129 | * - 0x0C addr_data_f1 | |
1129 | * - 0x10 addr_data_f2 |
|
1130 | * - 0x10 addr_data_f2 | |
1130 | * - 0x14 addr_data_f3 |
|
1131 | * - 0x14 addr_data_f3 | |
1131 | * - 0x18 status |
|
1132 | * - 0x18 status | |
1132 | * - 0x1C delta_snapshot |
|
1133 | * - 0x1C delta_snapshot | |
1133 | * - 0x20 delta_f0 |
|
1134 | * - 0x20 delta_f0 | |
1134 | * - 0x24 delta_f0_2 |
|
1135 | * - 0x24 delta_f0_2 | |
1135 | * - 0x28 delta_f1 |
|
1136 | * - 0x28 delta_f1 | |
1136 | * - 0x2c delta_f2 |
|
1137 | * - 0x2c delta_f2 | |
1137 | * - 0x30 nb_data_by_buffer |
|
1138 | * - 0x30 nb_data_by_buffer | |
1138 | * - 0x34 nb_snapshot_param |
|
1139 | * - 0x34 nb_snapshot_param | |
1139 | * - 0x38 start_date |
|
1140 | * - 0x38 start_date | |
1140 | * - 0x3c nb_word_in_buffer |
|
1141 | * - 0x3c nb_word_in_buffer | |
1141 | * |
|
1142 | * | |
1142 | */ |
|
1143 | */ | |
1143 |
|
1144 | |||
1144 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1145 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW | |
1145 |
|
1146 | |||
1146 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1147 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1147 |
|
1148 | |||
1148 | reset_wfp_buffer_addresses(); |
|
1149 | reset_wfp_buffer_addresses(); | |
1149 |
|
1150 | |||
1150 | reset_wfp_status(); // 0x18 |
|
1151 | reset_wfp_status(); // 0x18 | |
1151 |
|
1152 | |||
1152 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff |
|
1153 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff | |
1153 |
|
1154 | |||
1154 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1155 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1155 |
|
1156 | |||
1156 | set_wfp_delta_f1(); // 0x28 |
|
1157 | set_wfp_delta_f1(); // 0x28 | |
1157 |
|
1158 | |||
1158 | set_wfp_delta_f2(); // 0x2c |
|
1159 | set_wfp_delta_f2(); // 0x2c | |
1159 |
|
1160 | |||
1160 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1161 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) | |
1161 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1162 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) | |
1162 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1163 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) | |
1163 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1164 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) | |
1164 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1165 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) | |
1165 | // 2688 = 8 * 336 |
|
1166 | // 2688 = 8 * 336 | |
1166 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1167 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 | |
1167 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1168 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples | |
1168 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 |
|
1169 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 | |
1169 | // |
|
1170 | // | |
1170 | // coarse time and fine time registers are not initialized, they are volatile |
|
1171 | // coarse time and fine time registers are not initialized, they are volatile | |
1171 | // |
|
1172 | // | |
1172 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 |
|
1173 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 | |
1173 | } |
|
1174 | } | |
1174 |
|
1175 | |||
1175 | void set_wfp_data_shaping( void ) |
|
1176 | void set_wfp_data_shaping( void ) | |
1176 | { |
|
1177 | { | |
1177 | /** This function sets the data_shaping register of the waveform picker module. |
|
1178 | /** This function sets the data_shaping register of the waveform picker module. | |
1178 | * |
|
1179 | * | |
1179 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1180 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1180 | * bw_sp0_sp1_r0_r1 |
|
1181 | * bw_sp0_sp1_r0_r1 | |
1181 | * |
|
1182 | * | |
1182 | */ |
|
1183 | */ | |
1183 |
|
1184 | |||
1184 | unsigned char data_shaping; |
|
1185 | unsigned char data_shaping; | |
1185 |
|
1186 | |||
1186 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1187 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1187 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1188 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1188 |
|
1189 | |||
1189 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; |
|
1190 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; | |
1190 |
|
1191 | |||
1191 | waveform_picker_regs->data_shaping = |
|
1192 | waveform_picker_regs->data_shaping = | |
1192 | ( (data_shaping & 0x20) >> 5 ) // BW |
|
1193 | ( (data_shaping & 0x20) >> 5 ) // BW | |
1193 | + ( (data_shaping & 0x10) >> 3 ) // SP0 |
|
1194 | + ( (data_shaping & 0x10) >> 3 ) // SP0 | |
1194 | + ( (data_shaping & 0x08) >> 1 ) // SP1 |
|
1195 | + ( (data_shaping & 0x08) >> 1 ) // SP1 | |
1195 | + ( (data_shaping & 0x04) << 1 ) // R0 |
|
1196 | + ( (data_shaping & 0x04) << 1 ) // R0 | |
1196 | + ( (data_shaping & 0x02) << 3 ) // R1 |
|
1197 | + ( (data_shaping & 0x02) << 3 ) // R1 | |
1197 | + ( (data_shaping & 0x01) << 5 ); // R2 |
|
1198 | + ( (data_shaping & 0x01) << 5 ); // R2 | |
1198 | } |
|
1199 | } | |
1199 |
|
1200 | |||
1200 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1201 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1201 | { |
|
1202 | { | |
1202 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1203 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1203 | * |
|
1204 | * | |
1204 | * @param mode is the LFR mode to launch. |
|
1205 | * @param mode is the LFR mode to launch. | |
1205 | * |
|
1206 | * | |
1206 | * The burst bits shall be before the enable bits. |
|
1207 | * The burst bits shall be before the enable bits. | |
1207 | * |
|
1208 | * | |
1208 | */ |
|
1209 | */ | |
1209 |
|
1210 | |||
1210 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1211 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1211 | // the burst bits shall be set first, before the enable bits |
|
1212 | // the burst bits shall be set first, before the enable bits | |
1212 | switch(mode) { |
|
1213 | switch(mode) { | |
1213 | case(LFR_MODE_NORMAL): |
|
1214 | case(LFR_MODE_NORMAL): | |
1214 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1215 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable | |
1215 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1216 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 | |
1216 | break; |
|
1217 | break; | |
1217 | case(LFR_MODE_BURST): |
|
1218 | case(LFR_MODE_BURST): | |
1218 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1219 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1219 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1220 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 | |
1220 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 |
|
1221 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 | |
1221 | break; |
|
1222 | break; | |
1222 | case(LFR_MODE_SBM1): |
|
1223 | case(LFR_MODE_SBM1): | |
1223 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1224 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled | |
1224 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1225 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1225 | break; |
|
1226 | break; | |
1226 | case(LFR_MODE_SBM2): |
|
1227 | case(LFR_MODE_SBM2): | |
1227 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1228 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1228 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1229 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1229 | break; |
|
1230 | break; | |
1230 | default: |
|
1231 | default: | |
1231 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1232 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
1232 | break; |
|
1233 | break; | |
1233 | } |
|
1234 | } | |
1234 | } |
|
1235 | } | |
1235 |
|
1236 | |||
1236 | void set_wfp_delta_snapshot( void ) |
|
1237 | void set_wfp_delta_snapshot( void ) | |
1237 | { |
|
1238 | { | |
1238 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1239 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1239 | * |
|
1240 | * | |
1240 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1241 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1241 | * - sy_lfr_n_swf_p[0] |
|
1242 | * - sy_lfr_n_swf_p[0] | |
1242 | * - sy_lfr_n_swf_p[1] |
|
1243 | * - sy_lfr_n_swf_p[1] | |
1243 | * |
|
1244 | * | |
1244 | */ |
|
1245 | */ | |
1245 |
|
1246 | |||
1246 | unsigned int delta_snapshot; |
|
1247 | unsigned int delta_snapshot; | |
1247 | unsigned int delta_snapshot_in_T2; |
|
1248 | unsigned int delta_snapshot_in_T2; | |
1248 |
|
1249 | |||
1249 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1250 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
1250 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1251 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1251 |
|
1252 | |||
1252 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1253 | delta_snapshot_in_T2 = delta_snapshot * 256; | |
1253 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1254 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes | |
1254 | } |
|
1255 | } | |
1255 |
|
1256 | |||
1256 | void set_wfp_delta_f0_f0_2( void ) |
|
1257 | void set_wfp_delta_f0_f0_2( void ) | |
1257 | { |
|
1258 | { | |
1258 | unsigned int delta_snapshot; |
|
1259 | unsigned int delta_snapshot; | |
1259 | unsigned int nb_samples_per_snapshot; |
|
1260 | unsigned int nb_samples_per_snapshot; | |
1260 | float delta_f0_in_float; |
|
1261 | float delta_f0_in_float; | |
1261 |
|
1262 | |||
1262 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1263 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1263 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1264 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1264 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1265 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; | |
1265 |
|
1266 | |||
1266 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1267 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1267 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits |
|
1268 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits | |
1268 | } |
|
1269 | } | |
1269 |
|
1270 | |||
1270 | void set_wfp_delta_f1( void ) |
|
1271 | void set_wfp_delta_f1( void ) | |
1271 | { |
|
1272 | { | |
1272 | unsigned int delta_snapshot; |
|
1273 | unsigned int delta_snapshot; | |
1273 | unsigned int nb_samples_per_snapshot; |
|
1274 | unsigned int nb_samples_per_snapshot; | |
1274 | float delta_f1_in_float; |
|
1275 | float delta_f1_in_float; | |
1275 |
|
1276 | |||
1276 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1277 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1277 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1278 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1278 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1279 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; | |
1279 |
|
1280 | |||
1280 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1281 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1281 | } |
|
1282 | } | |
1282 |
|
1283 | |||
1283 | void set_wfp_delta_f2() |
|
1284 | void set_wfp_delta_f2() | |
1284 | { |
|
1285 | { | |
1285 | unsigned int delta_snapshot; |
|
1286 | unsigned int delta_snapshot; | |
1286 | unsigned int nb_samples_per_snapshot; |
|
1287 | unsigned int nb_samples_per_snapshot; | |
1287 |
|
1288 | |||
1288 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1289 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1289 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1290 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1290 |
|
1291 | |||
1291 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1292 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; | |
1292 | } |
|
1293 | } | |
1293 |
|
1294 | |||
1294 | //***************** |
|
1295 | //***************** | |
1295 | // local parameters |
|
1296 | // local parameters | |
1296 |
|
1297 | |||
1297 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1298 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1298 | { |
|
1299 | { | |
1299 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1300 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. | |
1300 | * |
|
1301 | * | |
1301 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1302 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. | |
1302 | * @param sid is the source identifier of the packet being updated. |
|
1303 | * @param sid is the source identifier of the packet being updated. | |
1303 | * |
|
1304 | * | |
1304 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1305 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 | |
1305 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1306 | * The sequence counters shall wrap around from 2^14 to zero. | |
1306 | * The sequence counter shall start at zero at startup. |
|
1307 | * The sequence counter shall start at zero at startup. | |
1307 | * |
|
1308 | * | |
1308 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1309 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 | |
1309 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1310 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 | |
1310 | * |
|
1311 | * | |
1311 | */ |
|
1312 | */ | |
1312 |
|
1313 | |||
1313 | unsigned short *sequence_cnt; |
|
1314 | unsigned short *sequence_cnt; | |
1314 | unsigned short segmentation_grouping_flag; |
|
1315 | unsigned short segmentation_grouping_flag; | |
1315 | unsigned short new_packet_sequence_control; |
|
1316 | unsigned short new_packet_sequence_control; | |
1316 | rtems_mode initial_mode_set; |
|
1317 | rtems_mode initial_mode_set; | |
1317 | rtems_mode current_mode_set; |
|
1318 | rtems_mode current_mode_set; | |
1318 | rtems_status_code status; |
|
1319 | rtems_status_code status; | |
1319 |
|
1320 | |||
1320 | //****************************************** |
|
1321 | //****************************************** | |
1321 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1322 | // CHANGE THE MODE OF THE CALLING RTEMS TASK | |
1322 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1323 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); | |
1323 |
|
1324 | |||
1324 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1325 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) | |
1325 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1326 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) | |
1326 | || (sid == SID_BURST_CWF_F2) |
|
1327 | || (sid == SID_BURST_CWF_F2) | |
1327 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1328 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) | |
1328 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1329 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |
1329 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1330 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |
1330 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1331 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) | |
1331 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1332 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) | |
1332 | { |
|
1333 | { | |
1333 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1334 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1334 | } |
|
1335 | } | |
1335 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1336 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) | |
1336 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1337 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |
1337 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1338 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) | |
1338 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1339 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) | |
1339 | { |
|
1340 | { | |
1340 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1341 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1341 | } |
|
1342 | } | |
1342 | else |
|
1343 | else | |
1343 | { |
|
1344 | { | |
1344 | sequence_cnt = (unsigned short *) NULL; |
|
1345 | sequence_cnt = (unsigned short *) NULL; | |
1345 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1346 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1346 | } |
|
1347 | } | |
1347 |
|
1348 | |||
1348 | if (sequence_cnt != NULL) |
|
1349 | if (sequence_cnt != NULL) | |
1349 | { |
|
1350 | { | |
1350 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1351 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1351 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1352 | *sequence_cnt = (*sequence_cnt) & 0x3fff; | |
1352 |
|
1353 | |||
1353 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1354 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; | |
1354 |
|
1355 | |||
1355 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1356 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1356 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1357 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1357 |
|
1358 | |||
1358 | // increment the sequence counter |
|
1359 | // increment the sequence counter | |
1359 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1360 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1360 | { |
|
1361 | { | |
1361 | *sequence_cnt = *sequence_cnt + 1; |
|
1362 | *sequence_cnt = *sequence_cnt + 1; | |
1362 | } |
|
1363 | } | |
1363 | else |
|
1364 | else | |
1364 | { |
|
1365 | { | |
1365 | *sequence_cnt = 0; |
|
1366 | *sequence_cnt = 0; | |
1366 | } |
|
1367 | } | |
1367 | } |
|
1368 | } | |
1368 |
|
1369 | |||
1369 | //*********************************** |
|
1370 | //*********************************** | |
1370 | // RESET THE MODE OF THE CALLING TASK |
|
1371 | // RESET THE MODE OF THE CALLING TASK | |
1371 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1372 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); | |
1372 | } |
|
1373 | } |
General Comments 0
You need to be logged in to leave comments.
Login now