##// END OF EJS Templates
snapshot resynchro changed...
paul -
r257:132f1c3627d7 R3a
parent child
Show More
@@ -1,2 +1,2
1 1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 80d727bb9d808ae67c801c4c6101811d68b94af6 header/lfr_common_headers
2 4ffa7549495b4d1e5ddbda520569468a5e3b8779 header/lfr_common_headers
@@ -1,87 +1,89
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8 #include <fsw_params.h>
9 9
10 10 #include "fsw_init.h"
11 11 #include "fsw_params_wf_handler.h"
12 12
13 13 #define pi 3.14159265359
14 14
15 15 extern int fdSPW;
16 16
17 17 //*****************
18 18 // waveform buffers
19 19 extern volatile int wf_buffer_f0[ ];
20 20 extern volatile int wf_buffer_f1[ ];
21 21 extern volatile int wf_buffer_f2[ ];
22 22 extern volatile int wf_buffer_f3[ ];
23 23
24 24 extern waveform_picker_regs_0_1_18_t *waveform_picker_regs;
25 25 extern time_management_regs_t *time_management_regs;
26 26 extern Packet_TM_LFR_HK_t housekeeping_packet;
27 27 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
28 28 extern struct param_local_str param_local;
29 29
30 30 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
31 31 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
32 32
33 33 extern rtems_id Task_id[20]; /* array of task ids */
34 34
35 35 extern unsigned char lfrCurrentMode;
36 36
37 37 //**********
38 38 // RTEMS_ISR
39 39 void reset_extractSWF( void );
40 40 rtems_isr waveforms_isr( rtems_vector_number vector );
41 41
42 42 //***********
43 43 // RTEMS_TASK
44 44 rtems_task wfrm_task( rtems_task_argument argument );
45 45 rtems_task cwf3_task( rtems_task_argument argument );
46 46 rtems_task cwf2_task( rtems_task_argument argument );
47 47 rtems_task cwf1_task( rtems_task_argument argument );
48 48 rtems_task swbd_task( rtems_task_argument argument );
49 49
50 50 //******************
51 51 // general functions
52 52 void WFP_init_rings( void );
53 53 void init_ring( ring_node ring[], unsigned char nbNodes, volatile int buffer[] , unsigned int bufferSize );
54 54 void WFP_reset_current_ring_nodes( void );
55 55 //
56 56 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
57 57 //
58 58 int send_waveform_CWF3_light(ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id );
59 59 //
60 60 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
61 61 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
62 62 void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel ,
63 63 unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted);
64 double computeCorrection( unsigned char *timePtr );
65 void applyCorrection( double correction );
64 66 void snapshot_resynchronization( unsigned char *timePtr );
65 67 //
66 68 rtems_id get_pkts_queue_id( void );
67 69
68 70 //**************
69 71 // wfp registers
70 72 // RESET
71 73 void reset_wfp_burst_enable( void );
72 74 void reset_wfp_status( void );
73 75 void reset_wfp_buffer_addresses( void );
74 76 void reset_waveform_picker_regs( void );
75 77 // SET
76 78 void set_wfp_data_shaping(void);
77 79 void set_wfp_burst_enable_register( unsigned char mode );
78 80 void set_wfp_delta_snapshot( void );
79 81 void set_wfp_delta_f0_f0_2( void );
80 82 void set_wfp_delta_f1( void );
81 83 void set_wfp_delta_f2( void );
82 84
83 85 //*****************
84 86 // local parameters
85 87 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
86 88
87 89 #endif // WF_HANDLER_H_INCLUDED
@@ -1,909 +1,912
1 1 /** This is the RTEMS initialization module.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * This module contains two very different information:
7 7 * - specific instructions to configure the compilation of the RTEMS executive
8 8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 9 *
10 10 */
11 11
12 12 //*************************
13 13 // GPL reminder to be added
14 14 //*************************
15 15
16 16 #include <rtems.h>
17 17
18 18 /* configuration information */
19 19
20 20 #define CONFIGURE_INIT
21 21
22 22 #include <bsp.h> /* for device driver prototypes */
23 23
24 24 /* configuration information */
25 25
26 26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28 28
29 29 #define CONFIGURE_MAXIMUM_TASKS 20
30 30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
39 39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 40 #ifdef PRINT_STACK_REPORT
41 41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 42 #endif
43 43
44 44 #include <rtems/confdefs.h>
45 45
46 46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 47 #ifdef RTEMS_DRVMGR_STARTUP
48 48 #ifdef LEON3
49 49 /* Add Timer and UART Driver */
50 50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 52 #endif
53 53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 55 #endif
56 56 #endif
57 57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 58 #include <drvmgr/drvmgr_confdefs.h>
59 59 #endif
60 60
61 61 #include "fsw_init.h"
62 62 #include "fsw_config.c"
63 63 #include "GscMemoryLPP.hpp"
64 64
65 65 void initCache()
66 66 {
67 67 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
68 68 // These should only be read and written using 32-bit LDA/STA instructions.
69 69 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
70 70 // The table below shows the register addresses:
71 71 // 0x00 Cache control register
72 72 // 0x04 Reserved
73 73 // 0x08 Instruction cache configuration register
74 74 // 0x0C Data cache configuration register
75 75
76 76 // Cache Control Register Leon3 / Leon3FT
77 77 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
78 78 // RFT PS TB DS FD FI FT ST IB
79 79 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
80 80 // IP DP ITE IDE DTE DDE DF IF DCS ICS
81 81
82 82 unsigned int cacheControlRegister;
83 83
84 84 cacheControlRegister = CCR_getValue();
85 85 PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister);
86 86
87 87 CCR_resetCacheControlRegister();
88 88
89 89 CCR_enableInstructionCache(); // ICS bits
90 90 CCR_enableDataCache(); // DCS bits
91 91 CCR_enableInstructionBurstFetch(); // IB bit
92 92
93 93 cacheControlRegister = CCR_getValue();
94 94 PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister);
95 95
96 96 CCR_faultTolerantScheme();
97 97
98 98 PRINTF("\n");
99 99 }
100 100
101 101 rtems_task Init( rtems_task_argument ignored )
102 102 {
103 103 /** This is the RTEMS INIT taks, it is the first task launched by the system.
104 104 *
105 105 * @param unused is the starting argument of the RTEMS task
106 106 *
107 107 * The INIT task create and run all other RTEMS tasks.
108 108 *
109 109 */
110 110
111 111 //***********
112 112 // INIT CACHE
113 113
114 114 unsigned char *vhdlVersion;
115 115
116 116 reset_lfr();
117 117
118 118 reset_local_time();
119 119
120 120 rtems_cpu_usage_reset();
121 121
122 122 rtems_status_code status;
123 123 rtems_status_code status_spw;
124 124 rtems_isr_entry old_isr_handler;
125 125
126 126 // UART settings
127 127 enable_apbuart_transmitter();
128 128 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
129 129
130 130 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
131 131
132 132
133 133 PRINTF("\n\n\n\n\n")
134 134
135 135 initCache();
136 136
137 137 PRINTF("*************************\n")
138 138 PRINTF("** LFR Flight Software **\n")
139 139 PRINTF1("** %d.", SW_VERSION_N1)
140 140 PRINTF1("%d." , SW_VERSION_N2)
141 141 PRINTF1("%d." , SW_VERSION_N3)
142 142 PRINTF1("%d **\n", SW_VERSION_N4)
143 143
144 144 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
145 145 PRINTF("** VHDL **\n")
146 146 PRINTF1("** %d.", vhdlVersion[1])
147 147 PRINTF1("%d." , vhdlVersion[2])
148 148 PRINTF1("%d **\n", vhdlVersion[3])
149 149 PRINTF("*************************\n")
150 150 PRINTF("\n\n")
151 151
152 152 init_parameter_dump();
153 153 init_kcoefficients_dump();
154 154 init_local_mode_parameters();
155 155 init_housekeeping_parameters();
156 156 init_k_coefficients_prc0();
157 157 init_k_coefficients_prc1();
158 158 init_k_coefficients_prc2();
159 159 pa_bia_status_info = 0x00;
160 160 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
161 161
162 162 // waveform picker initialization
163 163 WFP_init_rings(); LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
164 164 WFP_reset_current_ring_nodes();
165 165 reset_waveform_picker_regs();
166 166
167 167 // spectral matrices initialization
168 168 SM_init_rings(); // initialize spectral matrices rings
169 169 SM_reset_current_ring_nodes();
170 170 reset_spectral_matrix_regs();
171 171
172 172 // configure calibration
173 173 configureCalibration( false ); // true means interleaved mode, false is for normal mode
174 174
175 175 updateLFRCurrentMode( LFR_MODE_STANDBY );
176 176
177 177 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
178 178
179 179 create_names(); // create all names
180 180
181 181 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
182 182 if (status != RTEMS_SUCCESSFUL)
183 183 {
184 184 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
185 185 }
186 186
187 187 status = create_message_queues(); // create message queues
188 188 if (status != RTEMS_SUCCESSFUL)
189 189 {
190 190 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
191 191 }
192 192
193 193 status = create_all_tasks(); // create all tasks
194 194 if (status != RTEMS_SUCCESSFUL)
195 195 {
196 196 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
197 197 }
198 198
199 199 // **************************
200 200 // <SPACEWIRE INITIALIZATION>
201 201 grspw_timecode_callback = &timecode_irq_handler;
202 202
203 203 status_spw = spacewire_open_link(); // (1) open the link
204 204 if ( status_spw != RTEMS_SUCCESSFUL )
205 205 {
206 206 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
207 207 }
208 208
209 209 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
210 210 {
211 211 status_spw = spacewire_configure_link( fdSPW );
212 212 if ( status_spw != RTEMS_SUCCESSFUL )
213 213 {
214 214 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
215 215 }
216 216 }
217 217
218 218 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
219 219 {
220 220 status_spw = spacewire_start_link( fdSPW );
221 221 if ( status_spw != RTEMS_SUCCESSFUL )
222 222 {
223 223 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
224 224 }
225 225 }
226 226 // </SPACEWIRE INITIALIZATION>
227 227 // ***************************
228 228
229 229 status = start_all_tasks(); // start all tasks
230 230 if (status != RTEMS_SUCCESSFUL)
231 231 {
232 232 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
233 233 }
234 234
235 235 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
236 236 status = start_recv_send_tasks();
237 237 if ( status != RTEMS_SUCCESSFUL )
238 238 {
239 239 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
240 240 }
241 241
242 242 // suspend science tasks, they will be restarted later depending on the mode
243 243 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
244 244 if (status != RTEMS_SUCCESSFUL)
245 245 {
246 246 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
247 247 }
248 248
249 249 // configure IRQ handling for the waveform picker unit
250 250 status = rtems_interrupt_catch( waveforms_isr,
251 251 IRQ_SPARC_WAVEFORM_PICKER,
252 252 &old_isr_handler) ;
253 253 // configure IRQ handling for the spectral matrices unit
254 254 status = rtems_interrupt_catch( spectral_matrices_isr,
255 255 IRQ_SPARC_SPECTRAL_MATRIX,
256 256 &old_isr_handler) ;
257 257
258 258 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
259 259 if ( status_spw != RTEMS_SUCCESSFUL )
260 260 {
261 261 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
262 262 if ( status != RTEMS_SUCCESSFUL ) {
263 263 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
264 264 }
265 265 }
266 266
267 267 BOOT_PRINTF("delete INIT\n")
268 268
269 269 set_hk_lfr_sc_potential_flag( true );
270 270
271 // start the timer used for the detection of missing parameters (started also by the timecode_irq_handler ISR)
272 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT, timecode_timer_routine, NULL );
273
271 274 status = rtems_task_delete(RTEMS_SELF);
272 275
273 276 }
274 277
275 278 void init_local_mode_parameters( void )
276 279 {
277 280 /** This function initialize the param_local global variable with default values.
278 281 *
279 282 */
280 283
281 284 unsigned int i;
282 285
283 286 // LOCAL PARAMETERS
284 287
285 288 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
286 289 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
287 290 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
288 291
289 292 // init sequence counters
290 293
291 294 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
292 295 {
293 296 sequenceCounters_TC_EXE[i] = 0x00;
294 297 sequenceCounters_TM_DUMP[i] = 0x00;
295 298 }
296 299 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
297 300 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
298 301 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
299 302 }
300 303
301 304 void reset_local_time( void )
302 305 {
303 306 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
304 307 }
305 308
306 309 void create_names( void ) // create all names for tasks and queues
307 310 {
308 311 /** This function creates all RTEMS names used in the software for tasks and queues.
309 312 *
310 313 * @return RTEMS directive status codes:
311 314 * - RTEMS_SUCCESSFUL - successful completion
312 315 *
313 316 */
314 317
315 318 // task names
316 319 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
317 320 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
318 321 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
319 322 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
320 323 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
321 324 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
322 325 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
323 326 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
324 327 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
325 328 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
326 329 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
327 330 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
328 331 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
329 332 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
330 333 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
331 334 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
332 335 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
333 336 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
334 337 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
335 338
336 339 // rate monotonic period names
337 340 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
338 341
339 342 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
340 343 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
341 344 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
342 345 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
343 346 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
344 347
345 348 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
346 349 }
347 350
348 351 int create_all_tasks( void ) // create all tasks which run in the software
349 352 {
350 353 /** This function creates all RTEMS tasks used in the software.
351 354 *
352 355 * @return RTEMS directive status codes:
353 356 * - RTEMS_SUCCESSFUL - task created successfully
354 357 * - RTEMS_INVALID_ADDRESS - id is NULL
355 358 * - RTEMS_INVALID_NAME - invalid task name
356 359 * - RTEMS_INVALID_PRIORITY - invalid task priority
357 360 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
358 361 * - RTEMS_TOO_MANY - too many tasks created
359 362 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
360 363 * - RTEMS_TOO_MANY - too many global objects
361 364 *
362 365 */
363 366
364 367 rtems_status_code status;
365 368
366 369 //**********
367 370 // SPACEWIRE
368 371 // RECV
369 372 status = rtems_task_create(
370 373 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
371 374 RTEMS_DEFAULT_MODES,
372 375 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
373 376 );
374 377 if (status == RTEMS_SUCCESSFUL) // SEND
375 378 {
376 379 status = rtems_task_create(
377 380 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
378 381 RTEMS_DEFAULT_MODES,
379 382 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
380 383 );
381 384 }
382 385 if (status == RTEMS_SUCCESSFUL) // LINK
383 386 {
384 387 status = rtems_task_create(
385 388 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
386 389 RTEMS_DEFAULT_MODES,
387 390 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
388 391 );
389 392 }
390 393 if (status == RTEMS_SUCCESSFUL) // ACTN
391 394 {
392 395 status = rtems_task_create(
393 396 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
394 397 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
395 398 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
396 399 );
397 400 }
398 401 if (status == RTEMS_SUCCESSFUL) // SPIQ
399 402 {
400 403 status = rtems_task_create(
401 404 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
402 405 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
403 406 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
404 407 );
405 408 }
406 409
407 410 //******************
408 411 // SPECTRAL MATRICES
409 412 if (status == RTEMS_SUCCESSFUL) // AVF0
410 413 {
411 414 status = rtems_task_create(
412 415 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
413 416 RTEMS_DEFAULT_MODES,
414 417 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
415 418 );
416 419 }
417 420 if (status == RTEMS_SUCCESSFUL) // PRC0
418 421 {
419 422 status = rtems_task_create(
420 423 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
421 424 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
422 425 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
423 426 );
424 427 }
425 428 if (status == RTEMS_SUCCESSFUL) // AVF1
426 429 {
427 430 status = rtems_task_create(
428 431 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
429 432 RTEMS_DEFAULT_MODES,
430 433 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
431 434 );
432 435 }
433 436 if (status == RTEMS_SUCCESSFUL) // PRC1
434 437 {
435 438 status = rtems_task_create(
436 439 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
437 440 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
438 441 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
439 442 );
440 443 }
441 444 if (status == RTEMS_SUCCESSFUL) // AVF2
442 445 {
443 446 status = rtems_task_create(
444 447 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
445 448 RTEMS_DEFAULT_MODES,
446 449 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
447 450 );
448 451 }
449 452 if (status == RTEMS_SUCCESSFUL) // PRC2
450 453 {
451 454 status = rtems_task_create(
452 455 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
453 456 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
454 457 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
455 458 );
456 459 }
457 460
458 461 //****************
459 462 // WAVEFORM PICKER
460 463 if (status == RTEMS_SUCCESSFUL) // WFRM
461 464 {
462 465 status = rtems_task_create(
463 466 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
464 467 RTEMS_DEFAULT_MODES,
465 468 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
466 469 );
467 470 }
468 471 if (status == RTEMS_SUCCESSFUL) // CWF3
469 472 {
470 473 status = rtems_task_create(
471 474 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
472 475 RTEMS_DEFAULT_MODES,
473 476 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
474 477 );
475 478 }
476 479 if (status == RTEMS_SUCCESSFUL) // CWF2
477 480 {
478 481 status = rtems_task_create(
479 482 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
480 483 RTEMS_DEFAULT_MODES,
481 484 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
482 485 );
483 486 }
484 487 if (status == RTEMS_SUCCESSFUL) // CWF1
485 488 {
486 489 status = rtems_task_create(
487 490 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
488 491 RTEMS_DEFAULT_MODES,
489 492 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
490 493 );
491 494 }
492 495 if (status == RTEMS_SUCCESSFUL) // SWBD
493 496 {
494 497 status = rtems_task_create(
495 498 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
496 499 RTEMS_DEFAULT_MODES,
497 500 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
498 501 );
499 502 }
500 503
501 504 //*****
502 505 // MISC
503 506 if (status == RTEMS_SUCCESSFUL) // LOAD
504 507 {
505 508 status = rtems_task_create(
506 509 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
507 510 RTEMS_DEFAULT_MODES,
508 511 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
509 512 );
510 513 }
511 514 if (status == RTEMS_SUCCESSFUL) // DUMB
512 515 {
513 516 status = rtems_task_create(
514 517 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
515 518 RTEMS_DEFAULT_MODES,
516 519 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
517 520 );
518 521 }
519 522 if (status == RTEMS_SUCCESSFUL) // HOUS
520 523 {
521 524 status = rtems_task_create(
522 525 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
523 526 RTEMS_DEFAULT_MODES,
524 527 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
525 528 );
526 529 }
527 530
528 531 return status;
529 532 }
530 533
531 534 int start_recv_send_tasks( void )
532 535 {
533 536 rtems_status_code status;
534 537
535 538 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
536 539 if (status!=RTEMS_SUCCESSFUL) {
537 540 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
538 541 }
539 542
540 543 if (status == RTEMS_SUCCESSFUL) // SEND
541 544 {
542 545 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
543 546 if (status!=RTEMS_SUCCESSFUL) {
544 547 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
545 548 }
546 549 }
547 550
548 551 return status;
549 552 }
550 553
551 554 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
552 555 {
553 556 /** This function starts all RTEMS tasks used in the software.
554 557 *
555 558 * @return RTEMS directive status codes:
556 559 * - RTEMS_SUCCESSFUL - ask started successfully
557 560 * - RTEMS_INVALID_ADDRESS - invalid task entry point
558 561 * - RTEMS_INVALID_ID - invalid task id
559 562 * - RTEMS_INCORRECT_STATE - task not in the dormant state
560 563 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
561 564 *
562 565 */
563 566 // starts all the tasks fot eh flight software
564 567
565 568 rtems_status_code status;
566 569
567 570 //**********
568 571 // SPACEWIRE
569 572 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
570 573 if (status!=RTEMS_SUCCESSFUL) {
571 574 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
572 575 }
573 576
574 577 if (status == RTEMS_SUCCESSFUL) // LINK
575 578 {
576 579 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
577 580 if (status!=RTEMS_SUCCESSFUL) {
578 581 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
579 582 }
580 583 }
581 584
582 585 if (status == RTEMS_SUCCESSFUL) // ACTN
583 586 {
584 587 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
585 588 if (status!=RTEMS_SUCCESSFUL) {
586 589 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
587 590 }
588 591 }
589 592
590 593 //******************
591 594 // SPECTRAL MATRICES
592 595 if (status == RTEMS_SUCCESSFUL) // AVF0
593 596 {
594 597 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
595 598 if (status!=RTEMS_SUCCESSFUL) {
596 599 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
597 600 }
598 601 }
599 602 if (status == RTEMS_SUCCESSFUL) // PRC0
600 603 {
601 604 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
602 605 if (status!=RTEMS_SUCCESSFUL) {
603 606 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
604 607 }
605 608 }
606 609 if (status == RTEMS_SUCCESSFUL) // AVF1
607 610 {
608 611 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
609 612 if (status!=RTEMS_SUCCESSFUL) {
610 613 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
611 614 }
612 615 }
613 616 if (status == RTEMS_SUCCESSFUL) // PRC1
614 617 {
615 618 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
616 619 if (status!=RTEMS_SUCCESSFUL) {
617 620 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
618 621 }
619 622 }
620 623 if (status == RTEMS_SUCCESSFUL) // AVF2
621 624 {
622 625 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
623 626 if (status!=RTEMS_SUCCESSFUL) {
624 627 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
625 628 }
626 629 }
627 630 if (status == RTEMS_SUCCESSFUL) // PRC2
628 631 {
629 632 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
630 633 if (status!=RTEMS_SUCCESSFUL) {
631 634 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
632 635 }
633 636 }
634 637
635 638 //****************
636 639 // WAVEFORM PICKER
637 640 if (status == RTEMS_SUCCESSFUL) // WFRM
638 641 {
639 642 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
640 643 if (status!=RTEMS_SUCCESSFUL) {
641 644 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
642 645 }
643 646 }
644 647 if (status == RTEMS_SUCCESSFUL) // CWF3
645 648 {
646 649 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
647 650 if (status!=RTEMS_SUCCESSFUL) {
648 651 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
649 652 }
650 653 }
651 654 if (status == RTEMS_SUCCESSFUL) // CWF2
652 655 {
653 656 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
654 657 if (status!=RTEMS_SUCCESSFUL) {
655 658 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
656 659 }
657 660 }
658 661 if (status == RTEMS_SUCCESSFUL) // CWF1
659 662 {
660 663 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
661 664 if (status!=RTEMS_SUCCESSFUL) {
662 665 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
663 666 }
664 667 }
665 668 if (status == RTEMS_SUCCESSFUL) // SWBD
666 669 {
667 670 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
668 671 if (status!=RTEMS_SUCCESSFUL) {
669 672 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
670 673 }
671 674 }
672 675
673 676 //*****
674 677 // MISC
675 678 if (status == RTEMS_SUCCESSFUL) // HOUS
676 679 {
677 680 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
678 681 if (status!=RTEMS_SUCCESSFUL) {
679 682 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
680 683 }
681 684 }
682 685 if (status == RTEMS_SUCCESSFUL) // DUMB
683 686 {
684 687 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
685 688 if (status!=RTEMS_SUCCESSFUL) {
686 689 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
687 690 }
688 691 }
689 692 if (status == RTEMS_SUCCESSFUL) // LOAD
690 693 {
691 694 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
692 695 if (status!=RTEMS_SUCCESSFUL) {
693 696 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
694 697 }
695 698 }
696 699
697 700 return status;
698 701 }
699 702
700 703 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
701 704 {
702 705 rtems_status_code status_recv;
703 706 rtems_status_code status_send;
704 707 rtems_status_code status_q_p0;
705 708 rtems_status_code status_q_p1;
706 709 rtems_status_code status_q_p2;
707 710 rtems_status_code ret;
708 711 rtems_id queue_id;
709 712
710 713 //****************************************
711 714 // create the queue for handling valid TCs
712 715 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
713 716 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
714 717 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
715 718 if ( status_recv != RTEMS_SUCCESSFUL ) {
716 719 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
717 720 }
718 721
719 722 //************************************************
720 723 // create the queue for handling TM packet sending
721 724 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
722 725 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
723 726 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
724 727 if ( status_send != RTEMS_SUCCESSFUL ) {
725 728 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
726 729 }
727 730
728 731 //*****************************************************************************
729 732 // create the queue for handling averaged spectral matrices for processing @ f0
730 733 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
731 734 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
732 735 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
733 736 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
734 737 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
735 738 }
736 739
737 740 //*****************************************************************************
738 741 // create the queue for handling averaged spectral matrices for processing @ f1
739 742 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
740 743 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
741 744 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
742 745 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
743 746 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
744 747 }
745 748
746 749 //*****************************************************************************
747 750 // create the queue for handling averaged spectral matrices for processing @ f2
748 751 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
749 752 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
750 753 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
751 754 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
752 755 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
753 756 }
754 757
755 758 if ( status_recv != RTEMS_SUCCESSFUL )
756 759 {
757 760 ret = status_recv;
758 761 }
759 762 else if( status_send != RTEMS_SUCCESSFUL )
760 763 {
761 764 ret = status_send;
762 765 }
763 766 else if( status_q_p0 != RTEMS_SUCCESSFUL )
764 767 {
765 768 ret = status_q_p0;
766 769 }
767 770 else if( status_q_p1 != RTEMS_SUCCESSFUL )
768 771 {
769 772 ret = status_q_p1;
770 773 }
771 774 else
772 775 {
773 776 ret = status_q_p2;
774 777 }
775 778
776 779 return ret;
777 780 }
778 781
779 782 rtems_status_code create_timecode_timer( void )
780 783 {
781 784 rtems_status_code status;
782 785
783 786 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
784 787
785 788 if ( status != RTEMS_SUCCESSFUL )
786 789 {
787 790 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
788 791 }
789 792 else
790 793 {
791 794 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
792 795 }
793 796
794 797 return status;
795 798 }
796 799
797 800 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
798 801 {
799 802 rtems_status_code status;
800 803 rtems_name queue_name;
801 804
802 805 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
803 806
804 807 status = rtems_message_queue_ident( queue_name, 0, queue_id );
805 808
806 809 return status;
807 810 }
808 811
809 812 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
810 813 {
811 814 rtems_status_code status;
812 815