##// END OF EJS Templates
major change in fsw_processing.h to save cpu load
paul -
r325:b06a3a324978 R3_plus draft
parent child
Show More
@@ -1,380 +1,371
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 #define SBM_COEFF_PER_NORM_COEFF 2
14 #define SBM_COEFF_PER_NORM_COEFF 2
15 #define MAX_SRC_DATA 780 // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
15 #define MAX_SRC_DATA 780 // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
16 #define MAX_SRC_DATA_WITH_SPARE 143 // 13 bins * 11 Bytes
16 #define MAX_SRC_DATA_WITH_SPARE 143 // 13 bins * 11 Bytes
17
17
18 #define NODE_0 0
18 #define NODE_0 0
19 #define NODE_1 1
19 #define NODE_1 1
20 #define NODE_2 2
20 #define NODE_2 2
21 #define NODE_3 3
21 #define NODE_3 3
22 #define NODE_4 4
22 #define NODE_4 4
23 #define NODE_5 5
23 #define NODE_5 5
24 #define NODE_6 6
24 #define NODE_6 6
25 #define NODE_7 7
25 #define NODE_7 7
26
26
27 typedef struct ring_node_asm
27 typedef struct ring_node_asm
28 {
28 {
29 struct ring_node_asm *next;
29 struct ring_node_asm *next;
30 float matrix[ TOTAL_SIZE_SM ];
30 float matrix[ TOTAL_SIZE_SM ];
31 unsigned int status;
31 unsigned int status;
32 } ring_node_asm;
32 } ring_node_asm;
33
33
34 typedef struct
34 typedef struct
35 {
35 {
36 unsigned char targetLogicalAddress;
36 unsigned char targetLogicalAddress;
37 unsigned char protocolIdentifier;
37 unsigned char protocolIdentifier;
38 unsigned char reserved;
38 unsigned char reserved;
39 unsigned char userApplication;
39 unsigned char userApplication;
40 unsigned char packetID[BYTES_PER_PACKETID];
40 unsigned char packetID[BYTES_PER_PACKETID];
41 unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL];
41 unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL];
42 unsigned char packetLength[BYTES_PER_PKT_LEN];
42 unsigned char packetLength[BYTES_PER_PKT_LEN];
43 // DATA FIELD HEADER
43 // DATA FIELD HEADER
44 unsigned char spare1_pusVersion_spare2;
44 unsigned char spare1_pusVersion_spare2;
45 unsigned char serviceType;
45 unsigned char serviceType;
46 unsigned char serviceSubType;
46 unsigned char serviceSubType;
47 unsigned char destinationID;
47 unsigned char destinationID;
48 unsigned char time[BYTES_PER_TIME];
48 unsigned char time[BYTES_PER_TIME];
49 // AUXILIARY HEADER
49 // AUXILIARY HEADER
50 unsigned char sid;
50 unsigned char sid;
51 unsigned char pa_bia_status_info;
51 unsigned char pa_bia_status_info;
52 unsigned char sy_lfr_common_parameters_spare;
52 unsigned char sy_lfr_common_parameters_spare;
53 unsigned char sy_lfr_common_parameters;
53 unsigned char sy_lfr_common_parameters;
54 unsigned char acquisitionTime[BYTES_PER_TIME];
54 unsigned char acquisitionTime[BYTES_PER_TIME];
55 unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR];
55 unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR];
56 // SOURCE DATA
56 // SOURCE DATA
57 unsigned char data[ MAX_SRC_DATA ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
57 unsigned char data[ MAX_SRC_DATA ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
58 } bp_packet;
58 } bp_packet;
59
59
60 typedef struct
60 typedef struct
61 {
61 {
62 unsigned char targetLogicalAddress;
62 unsigned char targetLogicalAddress;
63 unsigned char protocolIdentifier;
63 unsigned char protocolIdentifier;
64 unsigned char reserved;
64 unsigned char reserved;
65 unsigned char userApplication;
65 unsigned char userApplication;
66 unsigned char packetID[BYTES_PER_PACKETID];
66 unsigned char packetID[BYTES_PER_PACKETID];
67 unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL];
67 unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL];
68 unsigned char packetLength[BYTES_PER_PKT_LEN];
68 unsigned char packetLength[BYTES_PER_PKT_LEN];
69 // DATA FIELD HEADER
69 // DATA FIELD HEADER
70 unsigned char spare1_pusVersion_spare2;
70 unsigned char spare1_pusVersion_spare2;
71 unsigned char serviceType;
71 unsigned char serviceType;
72 unsigned char serviceSubType;
72 unsigned char serviceSubType;
73 unsigned char destinationID;
73 unsigned char destinationID;
74 unsigned char time[BYTES_PER_TIME];
74 unsigned char time[BYTES_PER_TIME];
75 // AUXILIARY HEADER
75 // AUXILIARY HEADER
76 unsigned char sid;
76 unsigned char sid;
77 unsigned char pa_bia_status_info;
77 unsigned char pa_bia_status_info;
78 unsigned char sy_lfr_common_parameters_spare;
78 unsigned char sy_lfr_common_parameters_spare;
79 unsigned char sy_lfr_common_parameters;
79 unsigned char sy_lfr_common_parameters;
80 unsigned char acquisitionTime[BYTES_PER_TIME];
80 unsigned char acquisitionTime[BYTES_PER_TIME];
81 unsigned char source_data_spare;
81 unsigned char source_data_spare;
82 unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR];
82 unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR];
83 // SOURCE DATA
83 // SOURCE DATA
84 unsigned char data[ MAX_SRC_DATA_WITH_SPARE ]; // 13 bins * 11 Bytes
84 unsigned char data[ MAX_SRC_DATA_WITH_SPARE ]; // 13 bins * 11 Bytes
85 } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
85 } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
86
86
87 typedef struct asm_msg
87 typedef struct asm_msg
88 {
88 {
89 ring_node_asm *norm;
89 ring_node_asm *norm;
90 ring_node_asm *burst_sbm;
90 ring_node_asm *burst_sbm;
91 rtems_event_set event;
91 rtems_event_set event;
92 unsigned int coarseTimeNORM;
92 unsigned int coarseTimeNORM;
93 unsigned int fineTimeNORM;
93 unsigned int fineTimeNORM;
94 unsigned int coarseTimeSBM;
94 unsigned int coarseTimeSBM;
95 unsigned int fineTimeSBM;
95 unsigned int fineTimeSBM;
96 unsigned int numberOfSMInASMNORM;
96 unsigned int numberOfSMInASMNORM;
97 unsigned int numberOfSMInASMSBM;
97 unsigned int numberOfSMInASMSBM;
98 } asm_msg;
98 } asm_msg;
99
99
100 extern unsigned char thisIsAnASMRestart;
100 extern unsigned char thisIsAnASMRestart;
101
101
102 extern volatile int sm_f0[ ];
102 extern volatile int sm_f0[ ];
103 extern volatile int sm_f1[ ];
103 extern volatile int sm_f1[ ];
104 extern volatile int sm_f2[ ];
104 extern volatile int sm_f2[ ];
105 extern unsigned int acquisitionDurations[];
105 extern unsigned int acquisitionDurations[];
106
106
107 // parameters
107 // parameters
108 extern struct param_local_str param_local;
108 extern struct param_local_str param_local;
109 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
109 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
110
110
111 // registers
111 // registers
112 extern time_management_regs_t *time_management_regs;
112 extern time_management_regs_t *time_management_regs;
113 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
113 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
114
114
115 extern rtems_name misc_name[];
115 extern rtems_name misc_name[];
116 extern rtems_id Task_id[]; /* array of task ids */
116 extern rtems_id Task_id[]; /* array of task ids */
117
117
118 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
118 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
119 // ISR
119 // ISR
120 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
120 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
121
121
122 //******************
122 //******************
123 // Spectral Matrices
123 // Spectral Matrices
124 void reset_nb_sm( void );
124 void reset_nb_sm( void );
125 // SM
125 // SM
126 void SM_init_rings( void );
126 void SM_init_rings( void );
127 void SM_reset_current_ring_nodes( void );
127 void SM_reset_current_ring_nodes( void );
128 // ASM
128 // ASM
129 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
129 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
130
130
131 //*****************
131 //*****************
132 // Basic Parameters
132 // Basic Parameters
133
133
134 void BP_reset_current_ring_nodes( void );
134 void BP_reset_current_ring_nodes( void );
135 void BP_init_header(bp_packet *packet,
135 void BP_init_header(bp_packet *packet,
136 unsigned int apid, unsigned char sid,
136 unsigned int apid, unsigned char sid,
137 unsigned int packetLength , unsigned char blkNr);
137 unsigned int packetLength , unsigned char blkNr);
138 void BP_init_header_with_spare(bp_packet_with_spare *packet,
138 void BP_init_header_with_spare(bp_packet_with_spare *packet,
139 unsigned int apid, unsigned char sid,
139 unsigned int apid, unsigned char sid,
140 unsigned int packetLength, unsigned char blkNr );
140 unsigned int packetLength, unsigned char blkNr );
141 void BP_send( char *data,
141 void BP_send( char *data,
142 rtems_id queue_id,
142 rtems_id queue_id,
143 unsigned int nbBytesToSend , unsigned int sid );
143 unsigned int nbBytesToSend , unsigned int sid );
144 void BP_send_s1_s2(char *data,
144 void BP_send_s1_s2(char *data,
145 rtems_id queue_id,
145 rtems_id queue_id,
146 unsigned int nbBytesToSend, unsigned int sid );
146 unsigned int nbBytesToSend, unsigned int sid );
147
147
148 //******************
148 //******************
149 // general functions
149 // general functions
150 void reset_sm_status( void );
150 void reset_sm_status( void );
151 void reset_spectral_matrix_regs( void );
151 void reset_spectral_matrix_regs( void );
152 void set_time(unsigned char *time, unsigned char *timeInBuffer );
152 void set_time(unsigned char *time, unsigned char *timeInBuffer );
153 unsigned long long int get_acquisition_time( unsigned char *timePtr );
153 unsigned long long int get_acquisition_time( unsigned char *timePtr );
154 unsigned char getSID( rtems_event_set event );
154 unsigned char getSID( rtems_event_set event );
155
155
156 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
156 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
157 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
157 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
158
158
159 //***************************************
159 //***************************************
160 // DEFINITIONS OF STATIC INLINE FUNCTIONS
160 // DEFINITIONS OF STATIC INLINE FUNCTIONS
161 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
161 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
162 ring_node *ring_node_tab[],
162 ring_node *ring_node_tab[],
163 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
163 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
164 asm_msg *msgForMATR , unsigned char channel);
164 asm_msg *msgForMATR , unsigned char channel);
165
165
166 void ASM_patch( float *inputASM, float *outputASM );
166 void ASM_patch( float *inputASM, float *outputASM );
167
167
168 void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent );
168 void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent );
169
169
170 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
170 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
171 float divider );
171 float divider );
172
172
173 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
173 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
174 float divider,
174 float divider,
175 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
175 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
176
176
177 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
177 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
178
178
179 unsigned char acquisitionTimeIsValid(unsigned int coarseTime, unsigned int fineTime, unsigned char channel);
179 unsigned char acquisitionTimeIsValid(unsigned int coarseTime, unsigned int fineTime, unsigned char channel);
180
180
181 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
181 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
182 ring_node *ring_node_tab[],
182 ring_node *ring_node_tab[],
183 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
183 unsigned int nbAverageNORM, unsigned int nbAverageSBM,
184 asm_msg *msgForMATR, unsigned char channel )
184 asm_msg *msgForMATR, unsigned char channel )
185 {
185 {
186 float sum;
186 float sum;
187 unsigned int i;
187 unsigned int i;
188 unsigned int k;
188 unsigned int k;
189 unsigned char incomingSMIsValid[NB_SM_BEFORE_AVF0_F1];
189 unsigned char incomingSMIsValid[NB_SM_BEFORE_AVF0_F1];
190 unsigned int numberOfValidSM;
190 unsigned int numberOfValidSM;
191 unsigned char isValid;
191 unsigned char isValid;
192
192
193 //**************
193 //**************
194 // PAS FILTERING
194 // PAS FILTERING
195 // check acquisitionTime of the incoming data
195 // check acquisitionTime of the incoming data
196 numberOfValidSM = 0;
196 numberOfValidSM = 0;
197 for (k=0; k<NB_SM_BEFORE_AVF0_F1; k++)
197 for (k=0; k<NB_SM_BEFORE_AVF0_F1; k++)
198 {
198 {
199 isValid = acquisitionTimeIsValid( ring_node_tab[k]->coarseTime, ring_node_tab[k]->fineTime, channel );
199 isValid = acquisitionTimeIsValid( ring_node_tab[k]->coarseTime, ring_node_tab[k]->fineTime, channel );
200 incomingSMIsValid[k] = isValid;
200 incomingSMIsValid[k] = isValid;
201 numberOfValidSM = numberOfValidSM + isValid;
201 numberOfValidSM = numberOfValidSM + isValid;
202 }
202 }
203
203
204 //************************
204 //************************
205 // AVERAGE SPECTRAL MATRIX
205 // AVERAGE SPECTRAL MATRIX
206 for(i=0; i<TOTAL_SIZE_SM; i++)
206 for(i=0; i<TOTAL_SIZE_SM; i++)
207 {
207 {
208 // sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
208 sum = INIT_FLOAT;
209 // + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
209 for ( k = 0; k < NB_SM_BEFORE_AVF0_F1; k++ )
210 // + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
210 {
211 // + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
211 if (incomingSMIsValid[k] == 1)
212 // + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
212 {
213 // + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
213 sum = sum + ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] ;
214 // + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
214 }
215 // + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
215 }
216
217 sum = ( incomingSMIsValid[BYTE_0] * ((int *)(ring_node_tab[NODE_0]->buffer_address) )[ i ] )
218 + ( incomingSMIsValid[BYTE_1] * ((int *)(ring_node_tab[NODE_1]->buffer_address) )[ i ] )
219 + ( incomingSMIsValid[BYTE_2] * ((int *)(ring_node_tab[NODE_2]->buffer_address) )[ i ] )
220 + ( incomingSMIsValid[BYTE_3] * ((int *)(ring_node_tab[NODE_3]->buffer_address) )[ i ] )
221 + ( incomingSMIsValid[BYTE_4] * ((int *)(ring_node_tab[NODE_4]->buffer_address) )[ i ] )
222 + ( incomingSMIsValid[BYTE_5] * ((int *)(ring_node_tab[NODE_5]->buffer_address) )[ i ] )
223 + ( incomingSMIsValid[BYTE_6] * ((int *)(ring_node_tab[NODE_6]->buffer_address) )[ i ] )
224 + ( incomingSMIsValid[BYTE_7] * ((int *)(ring_node_tab[NODE_7]->buffer_address) )[ i ] );
225
216
226 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
217 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
227 {
218 {
228 averaged_spec_mat_NORM[ i ] = sum;
219 averaged_spec_mat_NORM[ i ] = sum;
229 averaged_spec_mat_SBM[ i ] = sum;
220 averaged_spec_mat_SBM[ i ] = sum;
230 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
221 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
231 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
222 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
232 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
223 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
233 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
224 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
234 }
225 }
235 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
226 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
236 {
227 {
237 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
228 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
238 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
229 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
239 }
230 }
240 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
231 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
241 {
232 {
242 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
233 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
243 averaged_spec_mat_SBM[ i ] = sum;
234 averaged_spec_mat_SBM[ i ] = sum;
244 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
235 msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime;
245 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
236 msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime;
246 }
237 }
247 else
238 else
248 {
239 {
249 averaged_spec_mat_NORM[ i ] = sum;
240 averaged_spec_mat_NORM[ i ] = sum;
250 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
241 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
251 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
242 msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime;
252 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
243 msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime;
253 // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
244 // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
254 }
245 }
255 }
246 }
256
247
257 //*******************
248 //*******************
258 // UPDATE SM COUNTERS
249 // UPDATE SM COUNTERS
259 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
250 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
260 {
251 {
261 msgForMATR->numberOfSMInASMNORM = numberOfValidSM;
252 msgForMATR->numberOfSMInASMNORM = numberOfValidSM;
262 msgForMATR->numberOfSMInASMSBM = numberOfValidSM;
253 msgForMATR->numberOfSMInASMSBM = numberOfValidSM;
263 }
254 }
264 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
255 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
265 {
256 {
266 msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM;
257 msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM;
267 msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM;
258 msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM;
268 }
259 }
269 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
260 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
270 {
261 {
271 msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM;
262 msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM;
272 msgForMATR->numberOfSMInASMSBM = numberOfValidSM;
263 msgForMATR->numberOfSMInASMSBM = numberOfValidSM;
273 }
264 }
274 else
265 else
275 {
266 {
276 msgForMATR->numberOfSMInASMNORM = numberOfValidSM;
267 msgForMATR->numberOfSMInASMNORM = numberOfValidSM;
277 msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM;
268 msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM;
278 }
269 }
279 }
270 }
280
271
281 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
272 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
282 {
273 {
283 int frequencyBin;
274 int frequencyBin;
284 int asmComponent;
275 int asmComponent;
285 unsigned int offsetASM;
276 unsigned int offsetASM;
286 unsigned int offsetASMReorganized;
277 unsigned int offsetASMReorganized;
287
278
288 // BUILD DATA
279 // BUILD DATA
289 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
280 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
290 {
281 {
291 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
282 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
292 {
283 {
293 offsetASMReorganized =
284 offsetASMReorganized =
294 (frequencyBin * NB_VALUES_PER_SM)
285 (frequencyBin * NB_VALUES_PER_SM)
295 + asmComponent;
286 + asmComponent;
296 offsetASM =
287 offsetASM =
297 (asmComponent * NB_BINS_PER_SM)
288 (asmComponent * NB_BINS_PER_SM)
298 + frequencyBin;
289 + frequencyBin;
299 if ( divider != INIT_FLOAT )
290 if ( divider != INIT_FLOAT )
300 {
291 {
301 averaged_spec_mat_reorganized[offsetASMReorganized ] = averaged_spec_mat[ offsetASM ] / divider;
292 averaged_spec_mat_reorganized[offsetASMReorganized ] = averaged_spec_mat[ offsetASM ] / divider;
302 }
293 }
303 else
294 else
304 {
295 {
305 averaged_spec_mat_reorganized[offsetASMReorganized ] = INIT_FLOAT;
296 averaged_spec_mat_reorganized[offsetASMReorganized ] = INIT_FLOAT;
306 }
297 }
307 }
298 }
308 }
299 }
309 }
300 }
310
301
311 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
302 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
312 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
303 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
313 {
304 {
314 int frequencyBin;
305 int frequencyBin;
315 int asmComponent;
306 int asmComponent;
316 int offsetASM;
307 int offsetASM;
317 int offsetCompressed;
308 int offsetCompressed;
318 int k;
309 int k;
319
310
320 // BUILD DATA
311 // BUILD DATA
321 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
312 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
322 {
313 {
323 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
314 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
324 {
315 {
325 offsetCompressed = // NO TIME OFFSET
316 offsetCompressed = // NO TIME OFFSET
326 (frequencyBin * NB_VALUES_PER_SM)
317 (frequencyBin * NB_VALUES_PER_SM)
327 + asmComponent;
318 + asmComponent;
328 offsetASM = // NO TIME OFFSET
319 offsetASM = // NO TIME OFFSET
329 (asmComponent * NB_BINS_PER_SM)
320 (asmComponent * NB_BINS_PER_SM)
330 + ASMIndexStart
321 + ASMIndexStart
331 + (frequencyBin * nbBinsToAverage);
322 + (frequencyBin * nbBinsToAverage);
332 compressed_spec_mat[ offsetCompressed ] = 0;
323 compressed_spec_mat[ offsetCompressed ] = 0;
333 for ( k = 0; k < nbBinsToAverage; k++ )
324 for ( k = 0; k < nbBinsToAverage; k++ )
334 {
325 {
335 compressed_spec_mat[offsetCompressed ] =
326 compressed_spec_mat[offsetCompressed ] =
336 ( compressed_spec_mat[ offsetCompressed ]
327 ( compressed_spec_mat[ offsetCompressed ]
337 + averaged_spec_mat[ offsetASM + k ] );
328 + averaged_spec_mat[ offsetASM + k ] );
338 }
329 }
339 compressed_spec_mat[ offsetCompressed ] =
330 compressed_spec_mat[ offsetCompressed ] =
340 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
331 compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage);
341 }
332 }
342 }
333 }
343 }
334 }
344
335
345 void ASM_convert( volatile float *input_matrix, char *output_matrix)
336 void ASM_convert( volatile float *input_matrix, char *output_matrix)
346 {
337 {
347 unsigned int frequencyBin;
338 unsigned int frequencyBin;
348 unsigned int asmComponent;
339 unsigned int asmComponent;
349 char * pt_char_input;
340 char * pt_char_input;
350 char * pt_char_output;
341 char * pt_char_output;
351 unsigned int offsetInput;
342 unsigned int offsetInput;
352 unsigned int offsetOutput;
343 unsigned int offsetOutput;
353
344
354 pt_char_input = (char*) &input_matrix;
345 pt_char_input = (char*) &input_matrix;
355 pt_char_output = (char*) &output_matrix;
346 pt_char_output = (char*) &output_matrix;
356
347
357 // convert all other data
348 // convert all other data
358 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
349 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
359 {
350 {
360 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
351 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
361 {
352 {
362 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
353 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
363 offsetOutput = SM_BYTES_PER_VAL * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
354 offsetOutput = SM_BYTES_PER_VAL * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
364 pt_char_input = (char*) &input_matrix [ offsetInput ];
355 pt_char_input = (char*) &input_matrix [ offsetInput ];
365 pt_char_output = (char*) &output_matrix[ offsetOutput ];
356 pt_char_output = (char*) &output_matrix[ offsetOutput ];
366 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
357 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
367 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
358 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
368 }
359 }
369 }
360 }
370 }
361 }
371
362
372 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat,
363 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat,
373 float divider,
364 float divider,
374 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel);
365 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel);
375
366
376 int getFBinMask(int k, unsigned char channel);
367 int getFBinMask(int k, unsigned char channel);
377
368
378 void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm);
369 void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm);
379
370
380 #endif // FSW_PROCESSING_H_INCLUDED
371 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,108 +1,107
1 cmake_minimum_required (VERSION 2.6)
1 cmake_minimum_required (VERSION 2.6)
2 project (fsw)
2 project (fsw)
3
3
4 include(sparc-rtems)
4 include(sparc-rtems)
5 include(cppcheck)
5 include(cppcheck)
6
6
7 include_directories("../header"
7 include_directories("../header"
8 "../header/lfr_common_headers"
8 "../header/lfr_common_headers"
9 "../header/processing"
9 "../header/processing"
10 "../LFR_basic-parameters"
10 "../LFR_basic-parameters"
11 "../src")
11 "../src")
12
12
13 set(SOURCES wf_handler.c
13 set(SOURCES wf_handler.c
14 tc_handler.c
14 tc_handler.c
15 fsw_misc.c
15 fsw_misc.c
16 fsw_init.c
16 fsw_init.c
17 fsw_globals.c
17 fsw_globals.c
18 fsw_spacewire.c
18 fsw_spacewire.c
19 tc_load_dump_parameters.c
19 tc_load_dump_parameters.c
20 tm_lfr_tc_exe.c
20 tm_lfr_tc_exe.c
21 tc_acceptance.c
21 tc_acceptance.c
22 processing/fsw_processing.c
22 processing/fsw_processing.c
23 processing/avf0_prc0.c
23 processing/avf0_prc0.c
24 processing/avf1_prc1.c
24 processing/avf1_prc1.c
25 processing/avf2_prc2.c
25 processing/avf2_prc2.c
26 lfr_cpu_usage_report.c
26 lfr_cpu_usage_report.c
27 ${LFR_BP_SRC}
27 ${LFR_BP_SRC}
28 ../header/wf_handler.h
28 ../header/wf_handler.h
29 ../header/tc_handler.h
29 ../header/tc_handler.h
30 ../header/grlib_regs.h
30 ../header/grlib_regs.h
31 ../header/fsw_misc.h
31 ../header/fsw_misc.h
32 ../header/fsw_init.h
32 ../header/fsw_init.h
33 ../header/fsw_spacewire.h
33 ../header/fsw_spacewire.h
34 ../header/tc_load_dump_parameters.h
34 ../header/tc_load_dump_parameters.h
35 ../header/tm_lfr_tc_exe.h
35 ../header/tm_lfr_tc_exe.h
36 ../header/tc_acceptance.h
36 ../header/tc_acceptance.h
37 ../header/processing/fsw_processing.h
37 ../header/processing/fsw_processing.h
38 ../header/processing/avf0_prc0.h
38 ../header/processing/avf0_prc0.h
39 ../header/processing/avf1_prc1.h
39 ../header/processing/avf1_prc1.h
40 ../header/processing/avf2_prc2.h
40 ../header/processing/avf2_prc2.h
41 ../header/fsw_params_wf_handler.h
41 ../header/fsw_params_wf_handler.h
42 ../header/lfr_cpu_usage_report.h
42 ../header/lfr_cpu_usage_report.h
43 ../header/lfr_common_headers/ccsds_types.h
43 ../header/lfr_common_headers/ccsds_types.h
44 ../header/lfr_common_headers/fsw_params.h
44 ../header/lfr_common_headers/fsw_params.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 ../header/lfr_common_headers/fsw_params_processing.h
46 ../header/lfr_common_headers/fsw_params_processing.h
47 ../header/lfr_common_headers/tm_byte_positions.h
47 ../header/lfr_common_headers/tm_byte_positions.h
48 ../LFR_basic-parameters/basic_parameters.h
48 ../LFR_basic-parameters/basic_parameters.h
49 ../LFR_basic-parameters/basic_parameters_params.h
49 ../LFR_basic-parameters/basic_parameters_params.h
50 ../header/GscMemoryLPP.hpp
50 ../header/GscMemoryLPP.hpp
51 )
51 )
52
52
53
53
54 option(FSW_verbose "Enable verbose LFR" ON)
54 option(FSW_verbose "Enable verbose LFR" ON)
55 option(FSW_boot_messages "Enable LFR boot messages" ON)
55 option(FSW_boot_messages "Enable LFR boot messages" ON)
56 option(FSW_debug_messages "Enable LFR debug messages" ON)
56 option(FSW_debug_messages "Enable LFR debug messages" ON)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
59 option(FSW_vhdl_dev "?" OFF)
59 option(FSW_vhdl_dev "?" OFF)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
62 option(FSW_debug_tch "?" OFF)
62 option(FSW_debug_tch "?" OFF)
63
63
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
67 set(SW_VERSION_N4 "4" CACHE STRING "Choose N4 FSW Version." FORCE)
67 set(SW_VERSION_N4 "5" CACHE STRING "Choose N4 FSW Version." FORCE)
68
69
68
70 if(FSW_verbose)
69 if(FSW_verbose)
71 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
70 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
72 endif()
71 endif()
73 if(FSW_boot_messages)
72 if(FSW_boot_messages)
74 add_definitions(-DBOOT_MESSAGES)
73 add_definitions(-DBOOT_MESSAGES)
75 endif()
74 endif()
76 if(FSW_debug_messages)
75 if(FSW_debug_messages)
77 add_definitions(-DDEBUG_MESSAGES)
76 add_definitions(-DDEBUG_MESSAGES)
78 endif()
77 endif()
79 if(FSW_cpu_usage_report)
78 if(FSW_cpu_usage_report)
80 add_definitions(-DPRINT_TASK_STATISTICS)
79 add_definitions(-DPRINT_TASK_STATISTICS)
81 endif()
80 endif()
82 if(FSW_stack_report)
81 if(FSW_stack_report)
83 add_definitions(-DPRINT_STACK_REPORT)
82 add_definitions(-DPRINT_STACK_REPORT)
84 endif()
83 endif()
85 if(FSW_vhdl_dev)
84 if(FSW_vhdl_dev)
86 add_definitions(-DVHDL_DEV)
85 add_definitions(-DVHDL_DEV)
87 endif()
86 endif()
88 if(FSW_lpp_dpu_destid)
87 if(FSW_lpp_dpu_destid)
89 add_definitions(-DLPP_DPU_DESTID)
88 add_definitions(-DLPP_DPU_DESTID)
90 endif()
89 endif()
91 if(FSW_debug_watchdog)
90 if(FSW_debug_watchdog)
92 add_definitions(-DDEBUG_WATCHDOG)
91 add_definitions(-DDEBUG_WATCHDOG)
93 endif()
92 endif()
94 if(FSW_debug_tch)
93 if(FSW_debug_tch)
95 add_definitions(-DDEBUG_TCH)
94 add_definitions(-DDEBUG_TCH)
96 endif()
95 endif()
97
96
98 add_definitions(-DMSB_FIRST_TCH)
97 add_definitions(-DMSB_FIRST_TCH)
99
98
100 add_definitions(-DSWVERSION=-1-0)
99 add_definitions(-DSWVERSION=-1-0)
101 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
100 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
102 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
101 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
103 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
102 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
104 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
103 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
105
104
106 add_executable(fsw ${SOURCES})
105 add_executable(fsw ${SOURCES})
107 add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
106 add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
108
107
@@ -1,945 +1,945
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 // [spiq] [link] [spacewire_reset_link]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
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
50
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
53 #endif
53 #endif
54
54
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
57 #endif
57 #endif
58
58
59 #endif
59 #endif
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
61
61
62 #include <drvmgr/drvmgr_confdefs.h>
62 #include <drvmgr/drvmgr_confdefs.h>
63 #endif
63 #endif
64
64
65 #include "fsw_init.h"
65 #include "fsw_init.h"
66 #include "fsw_config.c"
66 #include "fsw_config.c"
67 #include "GscMemoryLPP.hpp"
67 #include "GscMemoryLPP.hpp"
68
68
69 void initCache()
69 void initCache()
70 {
70 {
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
72 // These should only be read and written using 32-bit LDA/STA instructions.
72 // These should only be read and written using 32-bit LDA/STA instructions.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
74 // The table below shows the register addresses:
74 // The table below shows the register addresses:
75 // 0x00 Cache control register
75 // 0x00 Cache control register
76 // 0x04 Reserved
76 // 0x04 Reserved
77 // 0x08 Instruction cache configuration register
77 // 0x08 Instruction cache configuration register
78 // 0x0C Data cache configuration register
78 // 0x0C Data cache configuration register
79
79
80 // Cache Control Register Leon3 / Leon3FT
80 // Cache Control Register Leon3 / Leon3FT
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
82 // RFT PS TB DS FD FI FT ST IB
82 // RFT PS TB DS FD FI FT ST IB
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
85
85
86 unsigned int cacheControlRegister;
86 unsigned int cacheControlRegister;
87
87
88 CCR_resetCacheControlRegister();
88 CCR_resetCacheControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
90
90
91 cacheControlRegister = CCR_getValue();
91 cacheControlRegister = CCR_getValue();
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
94
94
95 CCR_enableInstructionCache(); // ICS bits
95 CCR_enableInstructionCache(); // ICS bits
96 CCR_enableDataCache(); // DCS bits
96 CCR_enableDataCache(); // DCS bits
97 CCR_enableInstructionBurstFetch(); // IB bit
97 CCR_enableInstructionBurstFetch(); // IB bit
98
98
99 faultTolerantScheme();
99 faultTolerantScheme();
100
100
101 cacheControlRegister = CCR_getValue();
101 cacheControlRegister = CCR_getValue();
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
104
104
105 PRINTF("\n");
105 PRINTF("\n");
106 }
106 }
107
107
108 rtems_task Init( rtems_task_argument ignored )
108 rtems_task Init( rtems_task_argument ignored )
109 {
109 {
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
111 *
111 *
112 * @param unused is the starting argument of the RTEMS task
112 * @param unused is the starting argument of the RTEMS task
113 *
113 *
114 * The INIT task create and run all other RTEMS tasks.
114 * The INIT task create and run all other RTEMS tasks.
115 *
115 *
116 */
116 */
117
117
118 //***********
118 //***********
119 // INIT CACHE
119 // INIT CACHE
120
120
121 unsigned char *vhdlVersion;
121 unsigned char *vhdlVersion;
122
122
123 reset_lfr();
123 reset_lfr();
124
124
125 reset_local_time();
125 reset_local_time();
126
126
127 rtems_cpu_usage_reset();
127 rtems_cpu_usage_reset();
128
128
129 rtems_status_code status;
129 rtems_status_code status;
130 rtems_status_code status_spw;
130 rtems_status_code status_spw;
131 rtems_isr_entry old_isr_handler;
131 rtems_isr_entry old_isr_handler;
132
132
133 old_isr_handler = NULL;
133 old_isr_handler = NULL;
134
134
135 // UART settings
135 // UART settings
136 enable_apbuart_transmitter();
136 enable_apbuart_transmitter();
137 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
137 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
138
138
139 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
139 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
140
140
141
141
142 PRINTF("\n\n\n\n\n")
142 PRINTF("\n\n\n\n\n")
143
143
144 initCache();
144 initCache();
145
145
146 PRINTF("*************************\n")
146 PRINTF("*************************\n")
147 PRINTF("** LFR Flight Software **\n")
147 PRINTF("** LFR Flight Software **\n")
148
148
149 PRINTF1("** %d-", SW_VERSION_N1)
149 PRINTF1("** %d-", SW_VERSION_N1)
150 PRINTF1("%d-" , SW_VERSION_N2)
150 PRINTF1("%d-" , SW_VERSION_N2)
151 PRINTF1("%d-" , SW_VERSION_N3)
151 PRINTF1("%d-" , SW_VERSION_N3)
152 PRINTF1("%d **\n", SW_VERSION_N4)
152 PRINTF1("%d **\n", SW_VERSION_N4)
153
153
154 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
154 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
155 PRINTF("** VHDL **\n")
155 PRINTF("** VHDL **\n")
156 PRINTF1("** %d.", vhdlVersion[1])
156 PRINTF1("** %d-", vhdlVersion[1])
157 PRINTF1("%d." , vhdlVersion[2])
157 PRINTF1("%d-" , vhdlVersion[2])
158 PRINTF1("%d **\n", vhdlVersion[3])
158 PRINTF1("%d **\n", vhdlVersion[3])
159 PRINTF("*************************\n")
159 PRINTF("*************************\n")
160 PRINTF("\n\n")
160 PRINTF("\n\n")
161
161
162 init_parameter_dump();
162 init_parameter_dump();
163 init_kcoefficients_dump();
163 init_kcoefficients_dump();
164 init_local_mode_parameters();
164 init_local_mode_parameters();
165 init_housekeeping_parameters();
165 init_housekeeping_parameters();
166 init_k_coefficients_prc0();
166 init_k_coefficients_prc0();
167 init_k_coefficients_prc1();
167 init_k_coefficients_prc1();
168 init_k_coefficients_prc2();
168 init_k_coefficients_prc2();
169 pa_bia_status_info = INIT_CHAR;
169 pa_bia_status_info = INIT_CHAR;
170 cp_rpw_sc_rw_f_flags = INIT_CHAR;
170 cp_rpw_sc_rw_f_flags = INIT_CHAR;
171 cp_rpw_sc_rw1_f1 = INIT_FLOAT;
171 cp_rpw_sc_rw1_f1 = INIT_FLOAT;
172 cp_rpw_sc_rw1_f2 = INIT_FLOAT;
172 cp_rpw_sc_rw1_f2 = INIT_FLOAT;
173 cp_rpw_sc_rw2_f1 = INIT_FLOAT;
173 cp_rpw_sc_rw2_f1 = INIT_FLOAT;
174 cp_rpw_sc_rw2_f2 = INIT_FLOAT;
174 cp_rpw_sc_rw2_f2 = INIT_FLOAT;
175 cp_rpw_sc_rw3_f1 = INIT_FLOAT;
175 cp_rpw_sc_rw3_f1 = INIT_FLOAT;
176 cp_rpw_sc_rw3_f2 = INIT_FLOAT;
176 cp_rpw_sc_rw3_f2 = INIT_FLOAT;
177 cp_rpw_sc_rw4_f1 = INIT_FLOAT;
177 cp_rpw_sc_rw4_f1 = INIT_FLOAT;
178 cp_rpw_sc_rw4_f2 = INIT_FLOAT;
178 cp_rpw_sc_rw4_f2 = INIT_FLOAT;
179 // initialize filtering parameters
179 // initialize filtering parameters
180 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
180 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
181 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
181 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
182 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
182 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
183 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
183 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
184 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
184 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
185 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
185 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
186 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
186 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
187
187
188 // waveform picker initialization
188 // waveform picker initialization
189 WFP_init_rings();
189 WFP_init_rings();
190 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
190 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
191 WFP_reset_current_ring_nodes();
191 WFP_reset_current_ring_nodes();
192 reset_waveform_picker_regs();
192 reset_waveform_picker_regs();
193
193
194 // spectral matrices initialization
194 // spectral matrices initialization
195 SM_init_rings(); // initialize spectral matrices rings
195 SM_init_rings(); // initialize spectral matrices rings
196 SM_reset_current_ring_nodes();
196 SM_reset_current_ring_nodes();
197 reset_spectral_matrix_regs();
197 reset_spectral_matrix_regs();
198
198
199 // configure calibration
199 // configure calibration
200 configureCalibration( false ); // true means interleaved mode, false is for normal mode
200 configureCalibration( false ); // true means interleaved mode, false is for normal mode
201
201
202 updateLFRCurrentMode( LFR_MODE_STANDBY );
202 updateLFRCurrentMode( LFR_MODE_STANDBY );
203
203
204 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
204 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
205
205
206 create_names(); // create all names
206 create_names(); // create all names
207
207
208 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
208 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
209 if (status != RTEMS_SUCCESSFUL)
209 if (status != RTEMS_SUCCESSFUL)
210 {
210 {
211 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
211 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
212 }
212 }
213
213
214 status = create_message_queues(); // create message queues
214 status = create_message_queues(); // create message queues
215 if (status != RTEMS_SUCCESSFUL)
215 if (status != RTEMS_SUCCESSFUL)
216 {
216 {
217 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
217 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
218 }
218 }
219
219
220 status = create_all_tasks(); // create all tasks
220 status = create_all_tasks(); // create all tasks
221 if (status != RTEMS_SUCCESSFUL)
221 if (status != RTEMS_SUCCESSFUL)
222 {
222 {
223 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
223 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
224 }
224 }
225
225
226 // **************************
226 // **************************
227 // <SPACEWIRE INITIALIZATION>
227 // <SPACEWIRE INITIALIZATION>
228 status_spw = spacewire_open_link(); // (1) open the link
228 status_spw = spacewire_open_link(); // (1) open the link
229 if ( status_spw != RTEMS_SUCCESSFUL )
229 if ( status_spw != RTEMS_SUCCESSFUL )
230 {
230 {
231 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
231 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
232 }
232 }
233
233
234 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
234 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
235 {
235 {
236 status_spw = spacewire_configure_link( fdSPW );
236 status_spw = spacewire_configure_link( fdSPW );
237 if ( status_spw != RTEMS_SUCCESSFUL )
237 if ( status_spw != RTEMS_SUCCESSFUL )
238 {
238 {
239 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
239 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
240 }
240 }
241 }
241 }
242
242
243 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
243 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
244 {
244 {
245 status_spw = spacewire_start_link( fdSPW );
245 status_spw = spacewire_start_link( fdSPW );
246 if ( status_spw != RTEMS_SUCCESSFUL )
246 if ( status_spw != RTEMS_SUCCESSFUL )
247 {
247 {
248 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
248 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
249 }
249 }
250 }
250 }
251 // </SPACEWIRE INITIALIZATION>
251 // </SPACEWIRE INITIALIZATION>
252 // ***************************
252 // ***************************
253
253
254 status = start_all_tasks(); // start all tasks
254 status = start_all_tasks(); // start all tasks
255 if (status != RTEMS_SUCCESSFUL)
255 if (status != RTEMS_SUCCESSFUL)
256 {
256 {
257 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
257 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
258 }
258 }
259
259
260 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
260 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
261 status = start_recv_send_tasks();
261 status = start_recv_send_tasks();
262 if ( status != RTEMS_SUCCESSFUL )
262 if ( status != RTEMS_SUCCESSFUL )
263 {
263 {
264 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
264 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
265 }
265 }
266
266
267 // suspend science tasks, they will be restarted later depending on the mode
267 // suspend science tasks, they will be restarted later depending on the mode
268 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
268 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
269 if (status != RTEMS_SUCCESSFUL)
269 if (status != RTEMS_SUCCESSFUL)
270 {
270 {
271 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
271 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
272 }
272 }
273
273
274 // configure IRQ handling for the waveform picker unit
274 // configure IRQ handling for the waveform picker unit
275 status = rtems_interrupt_catch( waveforms_isr,
275 status = rtems_interrupt_catch( waveforms_isr,
276 IRQ_SPARC_WAVEFORM_PICKER,
276 IRQ_SPARC_WAVEFORM_PICKER,
277 &old_isr_handler) ;
277 &old_isr_handler) ;
278 // configure IRQ handling for the spectral matrices unit
278 // configure IRQ handling for the spectral matrices unit
279 status = rtems_interrupt_catch( spectral_matrices_isr,
279 status = rtems_interrupt_catch( spectral_matrices_isr,
280 IRQ_SPARC_SPECTRAL_MATRIX,
280 IRQ_SPARC_SPECTRAL_MATRIX,
281 &old_isr_handler) ;
281 &old_isr_handler) ;
282
282
283 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
283 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
284 if ( status_spw != RTEMS_SUCCESSFUL )
284 if ( status_spw != RTEMS_SUCCESSFUL )
285 {
285 {
286 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
286 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
287 if ( status != RTEMS_SUCCESSFUL ) {
287 if ( status != RTEMS_SUCCESSFUL ) {
288 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
288 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
289 }
289 }
290 }
290 }
291
291
292 BOOT_PRINTF("delete INIT\n")
292 BOOT_PRINTF("delete INIT\n")
293
293
294 set_hk_lfr_sc_potential_flag( true );
294 set_hk_lfr_sc_potential_flag( true );
295
295
296 // start the timer to detect a missing spacewire timecode
296 // start the timer to detect a missing spacewire timecode
297 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
297 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
298 // if a tickout is generated, the timer is restarted
298 // if a tickout is generated, the timer is restarted
299 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
299 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
300
300
301 grspw_timecode_callback = &timecode_irq_handler;
301 grspw_timecode_callback = &timecode_irq_handler;
302
302
303 status = rtems_task_delete(RTEMS_SELF);
303 status = rtems_task_delete(RTEMS_SELF);
304
304
305 }
305 }
306
306
307 void init_local_mode_parameters( void )
307 void init_local_mode_parameters( void )
308 {
308 {
309 /** This function initialize the param_local global variable with default values.
309 /** This function initialize the param_local global variable with default values.
310 *
310 *
311 */
311 */
312
312
313 unsigned int i;
313 unsigned int i;
314
314
315 // LOCAL PARAMETERS
315 // LOCAL PARAMETERS
316
316
317 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
317 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
318 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
318 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
319
319
320 // init sequence counters
320 // init sequence counters
321
321
322 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
322 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
323 {
323 {
324 sequenceCounters_TC_EXE[i] = INIT_CHAR;
324 sequenceCounters_TC_EXE[i] = INIT_CHAR;
325 sequenceCounters_TM_DUMP[i] = INIT_CHAR;
325 sequenceCounters_TM_DUMP[i] = INIT_CHAR;
326 }
326 }
327 sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR;
327 sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR;
328 sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR;
328 sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR;
329 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT;
329 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT;
330 }
330 }
331
331
332 void reset_local_time( void )
332 void reset_local_time( void )
333 {
333 {
334 time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000
334 time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000
335 }
335 }
336
336
337 void create_names( void ) // create all names for tasks and queues
337 void create_names( void ) // create all names for tasks and queues
338 {
338 {
339 /** This function creates all RTEMS names used in the software for tasks and queues.
339 /** This function creates all RTEMS names used in the software for tasks and queues.
340 *
340 *
341 * @return RTEMS directive status codes:
341 * @return RTEMS directive status codes:
342 * - RTEMS_SUCCESSFUL - successful completion
342 * - RTEMS_SUCCESSFUL - successful completion
343 *
343 *
344 */
344 */
345
345
346 // task names
346 // task names
347 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
347 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
348 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
348 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
349 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
349 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
350 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
350 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
351 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
351 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
352 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
352 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
353 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
353 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
354 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
354 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
355 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
355 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
356 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
356 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
357 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
357 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
358 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
358 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
359 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
359 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
360 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
360 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
361 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
361 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
362 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
362 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
363 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
363 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
364 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
364 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
365 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
365 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
366
366
367 // rate monotonic period names
367 // rate monotonic period names
368 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
368 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
369
369
370 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
370 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
371 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
371 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
372 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
372 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
373 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
373 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
374 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
374 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
375
375
376 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
376 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
377 }
377 }
378
378
379 int create_all_tasks( void ) // create all tasks which run in the software
379 int create_all_tasks( void ) // create all tasks which run in the software
380 {
380 {
381 /** This function creates all RTEMS tasks used in the software.
381 /** This function creates all RTEMS tasks used in the software.
382 *
382 *
383 * @return RTEMS directive status codes:
383 * @return RTEMS directive status codes:
384 * - RTEMS_SUCCESSFUL - task created successfully
384 * - RTEMS_SUCCESSFUL - task created successfully
385 * - RTEMS_INVALID_ADDRESS - id is NULL
385 * - RTEMS_INVALID_ADDRESS - id is NULL
386 * - RTEMS_INVALID_NAME - invalid task name
386 * - RTEMS_INVALID_NAME - invalid task name
387 * - RTEMS_INVALID_PRIORITY - invalid task priority
387 * - RTEMS_INVALID_PRIORITY - invalid task priority
388 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
388 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
389 * - RTEMS_TOO_MANY - too many tasks created
389 * - RTEMS_TOO_MANY - too many tasks created
390 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
390 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
391 * - RTEMS_TOO_MANY - too many global objects
391 * - RTEMS_TOO_MANY - too many global objects
392 *
392 *
393 */
393 */
394
394
395 rtems_status_code status;
395 rtems_status_code status;
396
396
397 //**********
397 //**********
398 // SPACEWIRE
398 // SPACEWIRE
399 // RECV
399 // RECV
400 status = rtems_task_create(
400 status = rtems_task_create(
401 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
401 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
402 RTEMS_DEFAULT_MODES,
402 RTEMS_DEFAULT_MODES,
403 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
403 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
404 );
404 );
405 if (status == RTEMS_SUCCESSFUL) // SEND
405 if (status == RTEMS_SUCCESSFUL) // SEND
406 {
406 {
407 status = rtems_task_create(
407 status = rtems_task_create(
408 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
408 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
409 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_MODES,
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
411 );
411 );
412 }
412 }
413 if (status == RTEMS_SUCCESSFUL) // LINK
413 if (status == RTEMS_SUCCESSFUL) // LINK
414 {
414 {
415 status = rtems_task_create(
415 status = rtems_task_create(
416 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
416 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
417 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_MODES,
418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
419 );
419 );
420 }
420 }
421 if (status == RTEMS_SUCCESSFUL) // ACTN
421 if (status == RTEMS_SUCCESSFUL) // ACTN
422 {
422 {
423 status = rtems_task_create(
423 status = rtems_task_create(
424 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
424 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
427 );
427 );
428 }
428 }
429 if (status == RTEMS_SUCCESSFUL) // SPIQ
429 if (status == RTEMS_SUCCESSFUL) // SPIQ
430 {
430 {
431 status = rtems_task_create(
431 status = rtems_task_create(
432 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
432 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
433 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
433 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
434 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
434 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
435 );
435 );
436 }
436 }
437
437
438 //******************
438 //******************
439 // SPECTRAL MATRICES
439 // SPECTRAL MATRICES
440 if (status == RTEMS_SUCCESSFUL) // AVF0
440 if (status == RTEMS_SUCCESSFUL) // AVF0
441 {
441 {
442 status = rtems_task_create(
442 status = rtems_task_create(
443 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
443 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
444 RTEMS_DEFAULT_MODES,
444 RTEMS_DEFAULT_MODES,
445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
446 );
446 );
447 }
447 }
448 if (status == RTEMS_SUCCESSFUL) // PRC0
448 if (status == RTEMS_SUCCESSFUL) // PRC0
449 {
449 {
450 status = rtems_task_create(
450 status = rtems_task_create(
451 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
451 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
453 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
453 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
454 );
454 );
455 }
455 }
456 if (status == RTEMS_SUCCESSFUL) // AVF1
456 if (status == RTEMS_SUCCESSFUL) // AVF1
457 {
457 {
458 status = rtems_task_create(
458 status = rtems_task_create(
459 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
459 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
460 RTEMS_DEFAULT_MODES,
460 RTEMS_DEFAULT_MODES,
461 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
461 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
462 );
462 );
463 }
463 }
464 if (status == RTEMS_SUCCESSFUL) // PRC1
464 if (status == RTEMS_SUCCESSFUL) // PRC1
465 {
465 {
466 status = rtems_task_create(
466 status = rtems_task_create(
467 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
467 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
470 );
470 );
471 }
471 }
472 if (status == RTEMS_SUCCESSFUL) // AVF2
472 if (status == RTEMS_SUCCESSFUL) // AVF2
473 {
473 {
474 status = rtems_task_create(
474 status = rtems_task_create(
475 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
475 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
476 RTEMS_DEFAULT_MODES,
476 RTEMS_DEFAULT_MODES,
477 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
477 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
478 );
478 );
479 }
479 }
480 if (status == RTEMS_SUCCESSFUL) // PRC2
480 if (status == RTEMS_SUCCESSFUL) // PRC2
481 {
481 {
482 status = rtems_task_create(
482 status = rtems_task_create(
483 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
483 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
484 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
484 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
485 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
485 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
486 );
486 );
487 }
487 }
488
488
489 //****************
489 //****************
490 // WAVEFORM PICKER
490 // WAVEFORM PICKER
491 if (status == RTEMS_SUCCESSFUL) // WFRM
491 if (status == RTEMS_SUCCESSFUL) // WFRM
492 {
492 {
493 status = rtems_task_create(
493 status = rtems_task_create(
494 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
494 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
495 RTEMS_DEFAULT_MODES,
495 RTEMS_DEFAULT_MODES,
496 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
496 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
497 );
497 );
498 }
498 }
499 if (status == RTEMS_SUCCESSFUL) // CWF3
499 if (status == RTEMS_SUCCESSFUL) // CWF3
500 {
500 {
501 status = rtems_task_create(
501 status = rtems_task_create(
502 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
502 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
503 RTEMS_DEFAULT_MODES,
503 RTEMS_DEFAULT_MODES,
504 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
504 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
505 );
505 );
506 }
506 }
507 if (status == RTEMS_SUCCESSFUL) // CWF2
507 if (status == RTEMS_SUCCESSFUL) // CWF2
508 {
508 {
509 status = rtems_task_create(
509 status = rtems_task_create(
510 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
510 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
511 RTEMS_DEFAULT_MODES,
511 RTEMS_DEFAULT_MODES,
512 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
512 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
513 );
513 );
514 }
514 }
515 if (status == RTEMS_SUCCESSFUL) // CWF1
515 if (status == RTEMS_SUCCESSFUL) // CWF1
516 {
516 {
517 status = rtems_task_create(
517 status = rtems_task_create(
518 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
518 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
519 RTEMS_DEFAULT_MODES,
519 RTEMS_DEFAULT_MODES,
520 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
520 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
521 );
521 );
522 }
522 }
523 if (status == RTEMS_SUCCESSFUL) // SWBD
523 if (status == RTEMS_SUCCESSFUL) // SWBD
524 {
524 {
525 status = rtems_task_create(
525 status = rtems_task_create(
526 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
526 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
527 RTEMS_DEFAULT_MODES,
527 RTEMS_DEFAULT_MODES,
528 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
528 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
529 );
529 );
530 }
530 }
531
531
532 //*****
532 //*****
533 // MISC
533 // MISC
534 if (status == RTEMS_SUCCESSFUL) // LOAD
534 if (status == RTEMS_SUCCESSFUL) // LOAD
535 {
535 {
536 status = rtems_task_create(
536 status = rtems_task_create(
537 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
537 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
538 RTEMS_DEFAULT_MODES,
538 RTEMS_DEFAULT_MODES,
539 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
539 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
540 );
540 );
541 }
541 }
542 if (status == RTEMS_SUCCESSFUL) // DUMB
542 if (status == RTEMS_SUCCESSFUL) // DUMB
543 {
543 {
544 status = rtems_task_create(
544 status = rtems_task_create(
545 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
545 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
546 RTEMS_DEFAULT_MODES,
546 RTEMS_DEFAULT_MODES,
547 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
547 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
548 );
548 );
549 }
549 }
550 if (status == RTEMS_SUCCESSFUL) // HOUS
550 if (status == RTEMS_SUCCESSFUL) // HOUS
551 {
551 {
552 status = rtems_task_create(
552 status = rtems_task_create(
553 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
553 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
554 RTEMS_DEFAULT_MODES,
554 RTEMS_DEFAULT_MODES,
555 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
555 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
556 );
556 );
557 }
557 }
558
558
559 return status;
559 return status;
560 }
560 }
561
561
562 int start_recv_send_tasks( void )
562 int start_recv_send_tasks( void )
563 {
563 {
564 rtems_status_code status;
564 rtems_status_code status;
565
565
566 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
566 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
567 if (status!=RTEMS_SUCCESSFUL) {
567 if (status!=RTEMS_SUCCESSFUL) {
568 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
568 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
569 }
569 }
570
570
571 if (status == RTEMS_SUCCESSFUL) // SEND
571 if (status == RTEMS_SUCCESSFUL) // SEND
572 {
572 {
573 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
573 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
574 if (status!=RTEMS_SUCCESSFUL) {
574 if (status!=RTEMS_SUCCESSFUL) {
575 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
575 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
576 }
576 }
577 }
577 }
578
578
579 return status;
579 return status;
580 }
580 }
581
581
582 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
582 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
583 {
583 {
584 /** This function starts all RTEMS tasks used in the software.
584 /** This function starts all RTEMS tasks used in the software.
585 *
585 *
586 * @return RTEMS directive status codes:
586 * @return RTEMS directive status codes:
587 * - RTEMS_SUCCESSFUL - ask started successfully
587 * - RTEMS_SUCCESSFUL - ask started successfully
588 * - RTEMS_INVALID_ADDRESS - invalid task entry point
588 * - RTEMS_INVALID_ADDRESS - invalid task entry point
589 * - RTEMS_INVALID_ID - invalid task id
589 * - RTEMS_INVALID_ID - invalid task id
590 * - RTEMS_INCORRECT_STATE - task not in the dormant state
590 * - RTEMS_INCORRECT_STATE - task not in the dormant state
591 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
591 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
592 *
592 *
593 */
593 */
594 // starts all the tasks fot eh flight software
594 // starts all the tasks fot eh flight software
595
595
596 rtems_status_code status;
596 rtems_status_code status;
597
597
598 //**********
598 //**********
599 // SPACEWIRE
599 // SPACEWIRE
600 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
600 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
601 if (status!=RTEMS_SUCCESSFUL) {
601 if (status!=RTEMS_SUCCESSFUL) {
602 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
602 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
603 }
603 }
604
604
605 if (status == RTEMS_SUCCESSFUL) // LINK
605 if (status == RTEMS_SUCCESSFUL) // LINK
606 {
606 {
607 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
607 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
608 if (status!=RTEMS_SUCCESSFUL) {
608 if (status!=RTEMS_SUCCESSFUL) {
609 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
609 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
610 }
610 }
611 }
611 }
612
612
613 if (status == RTEMS_SUCCESSFUL) // ACTN
613 if (status == RTEMS_SUCCESSFUL) // ACTN
614 {
614 {
615 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
615 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
616 if (status!=RTEMS_SUCCESSFUL) {
616 if (status!=RTEMS_SUCCESSFUL) {
617 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
617 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
618 }
618 }
619 }
619 }
620
620
621 //******************
621 //******************
622 // SPECTRAL MATRICES
622 // SPECTRAL MATRICES
623 if (status == RTEMS_SUCCESSFUL) // AVF0
623 if (status == RTEMS_SUCCESSFUL) // AVF0
624 {
624 {
625 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
625 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
626 if (status!=RTEMS_SUCCESSFUL) {
626 if (status!=RTEMS_SUCCESSFUL) {
627 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
627 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
628 }
628 }
629 }
629 }
630 if (status == RTEMS_SUCCESSFUL) // PRC0
630 if (status == RTEMS_SUCCESSFUL) // PRC0
631 {
631 {
632 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
632 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
633 if (status!=RTEMS_SUCCESSFUL) {
633 if (status!=RTEMS_SUCCESSFUL) {
634 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
634 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
635 }
635 }
636 }
636 }
637 if (status == RTEMS_SUCCESSFUL) // AVF1
637 if (status == RTEMS_SUCCESSFUL) // AVF1
638 {
638 {
639 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
639 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
640 if (status!=RTEMS_SUCCESSFUL) {
640 if (status!=RTEMS_SUCCESSFUL) {
641 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
641 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
642 }
642 }
643 }
643 }
644 if (status == RTEMS_SUCCESSFUL) // PRC1
644 if (status == RTEMS_SUCCESSFUL) // PRC1
645 {
645 {
646 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
646 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
647 if (status!=RTEMS_SUCCESSFUL) {
647 if (status!=RTEMS_SUCCESSFUL) {
648 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
648 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
649 }
649 }
650 }
650 }
651 if (status == RTEMS_SUCCESSFUL) // AVF2
651 if (status == RTEMS_SUCCESSFUL) // AVF2
652 {
652 {
653 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
653 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
654 if (status!=RTEMS_SUCCESSFUL) {
654 if (status!=RTEMS_SUCCESSFUL) {
655 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
655 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
656 }
656 }
657 }
657 }
658 if (status == RTEMS_SUCCESSFUL) // PRC2
658 if (status == RTEMS_SUCCESSFUL) // PRC2
659 {
659 {
660 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
660 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
661 if (status!=RTEMS_SUCCESSFUL) {
661 if (status!=RTEMS_SUCCESSFUL) {
662 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
662 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
663 }
663 }
664 }
664 }
665
665
666 //****************
666 //****************
667 // WAVEFORM PICKER
667 // WAVEFORM PICKER
668 if (status == RTEMS_SUCCESSFUL) // WFRM
668 if (status == RTEMS_SUCCESSFUL) // WFRM
669 {
669 {
670 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
670 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
671 if (status!=RTEMS_SUCCESSFUL) {
671 if (status!=RTEMS_SUCCESSFUL) {
672 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
672 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
673 }
673 }
674 }
674 }
675 if (status == RTEMS_SUCCESSFUL) // CWF3
675 if (status == RTEMS_SUCCESSFUL) // CWF3
676 {
676 {
677 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
677 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
678 if (status!=RTEMS_SUCCESSFUL) {
678 if (status!=RTEMS_SUCCESSFUL) {
679 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
679 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
680 }
680 }
681 }
681 }
682 if (status == RTEMS_SUCCESSFUL) // CWF2
682 if (status == RTEMS_SUCCESSFUL) // CWF2
683 {
683 {
684 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
684 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
685 if (status!=RTEMS_SUCCESSFUL) {
685 if (status!=RTEMS_SUCCESSFUL) {
686 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
686 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
687 }
687 }
688 }
688 }
689 if (status == RTEMS_SUCCESSFUL) // CWF1
689 if (status == RTEMS_SUCCESSFUL) // CWF1
690 {
690 {
691 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
691 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
692 if (status!=RTEMS_SUCCESSFUL) {
692 if (status!=RTEMS_SUCCESSFUL) {
693 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
693 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
694 }
694 }
695 }
695 }
696 if (status == RTEMS_SUCCESSFUL) // SWBD
696 if (status == RTEMS_SUCCESSFUL) // SWBD
697 {
697 {
698 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
698 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
699 if (status!=RTEMS_SUCCESSFUL) {
699 if (status!=RTEMS_SUCCESSFUL) {
700 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
700 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
701 }
701 }
702 }
702 }
703
703
704 //*****
704 //*****
705 // MISC
705 // MISC
706 if (status == RTEMS_SUCCESSFUL) // HOUS
706 if (status == RTEMS_SUCCESSFUL) // HOUS
707 {
707 {
708 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
708 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
709 if (status!=RTEMS_SUCCESSFUL) {
709 if (status!=RTEMS_SUCCESSFUL) {
710 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
710 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
711 }
711 }
712 }
712 }
713 if (status == RTEMS_SUCCESSFUL) // DUMB
713 if (status == RTEMS_SUCCESSFUL) // DUMB
714 {
714 {
715 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
715 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
716 if (status!=RTEMS_SUCCESSFUL) {
716 if (status!=RTEMS_SUCCESSFUL) {
717 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
717 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
718 }
718 }
719 }
719 }
720 if (status == RTEMS_SUCCESSFUL) // LOAD
720 if (status == RTEMS_SUCCESSFUL) // LOAD
721 {
721 {
722 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
722 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
723 if (status!=RTEMS_SUCCESSFUL) {
723 if (status!=RTEMS_SUCCESSFUL) {
724 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
724 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
725 }
725 }
726 }
726 }
727
727
728 return status;
728 return status;
729 }
729 }
730
730
731 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
731 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
732 {
732 {
733 rtems_status_code status_recv;
733 rtems_status_code status_recv;
734 rtems_status_code status_send;
734 rtems_status_code status_send;
735 rtems_status_code status_q_p0;
735 rtems_status_code status_q_p0;
736 rtems_status_code status_q_p1;
736 rtems_status_code status_q_p1;
737 rtems_status_code status_q_p2;
737 rtems_status_code status_q_p2;
738 rtems_status_code ret;
738 rtems_status_code ret;
739 rtems_id queue_id;
739 rtems_id queue_id;
740
740
741 ret = RTEMS_SUCCESSFUL;
741 ret = RTEMS_SUCCESSFUL;
742 queue_id = RTEMS_ID_NONE;
742 queue_id = RTEMS_ID_NONE;
743
743
744 //****************************************
744 //****************************************
745 // create the queue for handling valid TCs
745 // create the queue for handling valid TCs
746 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
746 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
747 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
747 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
748 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
748 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
749 if ( status_recv != RTEMS_SUCCESSFUL ) {
749 if ( status_recv != RTEMS_SUCCESSFUL ) {
750 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
750 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
751 }
751 }
752
752
753 //************************************************
753 //************************************************
754 // create the queue for handling TM packet sending
754 // create the queue for handling TM packet sending
755 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
755 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
756 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
756 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
757 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
757 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
758 if ( status_send != RTEMS_SUCCESSFUL ) {
758 if ( status_send != RTEMS_SUCCESSFUL ) {
759 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
759 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
760 }
760 }
761
761
762 //*****************************************************************************
762 //*****************************************************************************
763 // create the queue for handling averaged spectral matrices for processing @ f0
763 // create the queue for handling averaged spectral matrices for processing @ f0
764 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
764 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
765 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
765 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
766 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
766 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
767 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
767 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
768 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
768 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
769 }
769 }
770
770
771 //*****************************************************************************
771 //*****************************************************************************
772 // create the queue for handling averaged spectral matrices for processing @ f1
772 // create the queue for handling averaged spectral matrices for processing @ f1
773 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
773 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
774 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
774 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
775 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
775 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
776 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
776 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
777 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
777 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
778 }
778 }
779
779
780 //*****************************************************************************
780 //*****************************************************************************
781 // create the queue for handling averaged spectral matrices for processing @ f2
781 // create the queue for handling averaged spectral matrices for processing @ f2
782 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
782 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
783 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
783 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
784 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
784 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
785 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
785 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
786 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
786 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
787 }
787 }
788
788
789 if ( status_recv != RTEMS_SUCCESSFUL )
789 if ( status_recv != RTEMS_SUCCESSFUL )
790 {
790 {
791 ret = status_recv;
791 ret = status_recv;
792 }
792 }
793 else if( status_send != RTEMS_SUCCESSFUL )
793 else if( status_send != RTEMS_SUCCESSFUL )
794 {
794 {
795 ret = status_send;
795 ret = status_send;
796 }
796 }
797 else if( status_q_p0 != RTEMS_SUCCESSFUL )
797 else if( status_q_p0 != RTEMS_SUCCESSFUL )
798 {
798 {
799 ret = status_q_p0;
799 ret = status_q_p0;
800 }
800 }
801 else if( status_q_p1 != RTEMS_SUCCESSFUL )
801 else if( status_q_p1 != RTEMS_SUCCESSFUL )
802 {
802 {
803 ret = status_q_p1;
803 ret = status_q_p1;
804 }
804 }
805 else
805 else
806 {
806 {
807 ret = status_q_p2;
807 ret = status_q_p2;
808 }
808 }
809
809
810 return ret;
810 return ret;
811 }
811 }
812
812
813 rtems_status_code create_timecode_timer( void )
813 rtems_status_code create_timecode_timer( void )
814 {
814 {
815 rtems_status_code status;
815 rtems_status_code status;
816
816
817 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
817 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
818
818
819 if ( status != RTEMS_SUCCESSFUL )
819 if ( status != RTEMS_SUCCESSFUL )
820 {
820 {
821 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
821 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
822 }
822 }
823 else
823 else
824 {
824 {
825 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
825 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
826 }
826 }
827
827
828 return status;
828 return status;
829 }
829 }
830
830
831 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
831 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
832 {
832 {
833 rtems_status_code status;
833 rtems_status_code status;
834 rtems_name queue_name;
834 rtems_name queue_name;
835
835
836 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
836 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
837
837
838 status = rtems_message_queue_ident( queue_name, 0, queue_id );
838 status = rtems_message_queue_ident( queue_name, 0, queue_id );
839
839
840 return status;
840 return status;
841 }
841 }
842
842
843 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
843 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
844 {
844 {
845 rtems_status_code status;
845 rtems_status_code status;
846 rtems_name queue_name;
846 rtems_name queue_name;
847
847
848 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
848 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
849
849
850 status = rtems_message_queue_ident( queue_name, 0, queue_id );
850 status = rtems_message_queue_ident( queue_name, 0, queue_id );
851
851
852 return status;
852 return status;
853 }
853 }
854
854
855 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
855 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
856 {
856 {
857 rtems_status_code status;
857 rtems_status_code status;
858 rtems_name queue_name;
858 rtems_name queue_name;
859
859
860 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
860 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
861
861
862 status = rtems_message_queue_ident( queue_name, 0, queue_id );
862 status = rtems_message_queue_ident( queue_name, 0, queue_id );
863
863
864 return status;
864 return status;
865 }
865 }
866
866
867 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
867 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
868 {
868 {
869 rtems_status_code status;
869 rtems_status_code status;
870 rtems_name queue_name;
870 rtems_name queue_name;
871
871
872 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
872 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
873
873
874 status = rtems_message_queue_ident( queue_name, 0, queue_id );
874 status = rtems_message_queue_ident( queue_name, 0, queue_id );
875
875
876 return status;
876 return status;
877 }
877 }
878
878
879 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
879 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
880 {
880 {
881 rtems_status_code status;
881 rtems_status_code status;
882 rtems_name queue_name;
882 rtems_name queue_name;
883
883
884 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
884 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
885
885
886 status = rtems_message_queue_ident( queue_name, 0, queue_id );
886 status = rtems_message_queue_ident( queue_name, 0, queue_id );
887
887
888 return status;
888 return status;
889 }
889 }
890
890
891 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
891 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
892 {
892 {
893 u_int32_t count;
893 u_int32_t count;
894 rtems_status_code status;
894 rtems_status_code status;
895
895
896 count = 0;
896 count = 0;
897
897
898 status = rtems_message_queue_get_number_pending( queue_id, &count );
898 status = rtems_message_queue_get_number_pending( queue_id, &count );
899
899
900 count = count + 1;
900 count = count + 1;
901
901
902 if (status != RTEMS_SUCCESSFUL)
902 if (status != RTEMS_SUCCESSFUL)
903 {
903 {
904 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
904 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
905 }
905 }
906 else
906 else
907 {
907 {
908 if (count > *fifo_size_max)
908 if (count > *fifo_size_max)
909 {
909 {
910 *fifo_size_max = count;
910 *fifo_size_max = count;
911 }
911 }
912 }
912 }
913 }
913 }
914
914
915 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
915 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
916 {
916 {
917 unsigned char i;
917 unsigned char i;
918
918
919 //***************
919 //***************
920 // BUFFER ADDRESS
920 // BUFFER ADDRESS
921 for(i=0; i<nbNodes; i++)
921 for(i=0; i<nbNodes; i++)
922 {
922 {
923 ring[i].coarseTime = INT32_ALL_F;
923 ring[i].coarseTime = INT32_ALL_F;
924 ring[i].fineTime = INT32_ALL_F;
924 ring[i].fineTime = INT32_ALL_F;
925 ring[i].sid = INIT_CHAR;
925 ring[i].sid = INIT_CHAR;
926 ring[i].status = INIT_CHAR;
926 ring[i].status = INIT_CHAR;
927 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
927 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
928 }
928 }
929
929
930 //*****
930 //*****
931 // NEXT
931 // NEXT
932 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
932 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
933 for(i=0; i<nbNodes-1; i++)
933 for(i=0; i<nbNodes-1; i++)
934 {
934 {
935 ring[i].next = (ring_node*) &ring[ i + 1 ];
935 ring[i].next = (ring_node*) &ring[ i + 1 ];
936 }
936 }
937
937
938 //*********
938 //*********
939 // PREVIOUS
939 // PREVIOUS
940 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
940 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
941 for(i=1; i<nbNodes; i++)
941 for(i=1; i<nbNodes; i++)
942 {
942 {
943 ring[i].previous = (ring_node*) &ring[ i - 1 ];
943 ring[i].previous = (ring_node*) &ring[ i - 1 ];
944 }
944 }
945 }
945 }
General Comments 0
You need to be logged in to leave comments. Login now