##// END OF EJS Templates
debug fonction bp1 de tch
paul -
r217:7bf0cf7f80b9 R3
parent child
Show More
@@ -1,2 +1,2
1 aa66459dff7b46d030e3263cfd9291b1d550c428 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 2 bb9afa759d57093f7646d3be18f4a9923a4cbf84 header/lfr_common_headers
@@ -1,112 +1,113
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 4 # lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid debug_tch
6 6 CONFIG -= qt
7 7
8 8 include(./sparc.pri)
9 9
10 10 # flight software version
11 11 SWVERSION=-1-0
12 12 DEFINES += SW_VERSION_N1=3 # major
13 13 DEFINES += SW_VERSION_N2=0 # minor
14 14 DEFINES += SW_VERSION_N3=0 # patch
15 DEFINES += SW_VERSION_N4=7 # internal
15 DEFINES += SW_VERSION_N4=8 # internal
16 16
17 17 # <GCOV>
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
18 QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
20 LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc
20 21 # </GCOV>
21 22
22 23 # <CHANGE BEFORE FLIGHT>
23 24 contains( CONFIG, lpp_dpu_destid ) {
24 25 DEFINES += LPP_DPU_DESTID
25 26 }
26 27 # </CHANGE BEFORE FLIGHT>
27 28
28 29 contains( CONFIG, debug_tch ) {
29 30 DEFINES += DEBUG_TCH
30 31 }
31 32 DEFINES += MSB_FIRST_TCH
32 33
33 34 contains( CONFIG, vhdl_dev ) {
34 35 DEFINES += VHDL_DEV
35 36 }
36 37
37 38 contains( CONFIG, verbose ) {
38 39 DEFINES += PRINT_MESSAGES_ON_CONSOLE
39 40 }
40 41
41 42 contains( CONFIG, debug_messages ) {
42 43 DEFINES += DEBUG_MESSAGES
43 44 }
44 45
45 46 contains( CONFIG, cpu_usage_report ) {
46 47 DEFINES += PRINT_TASK_STATISTICS
47 48 }
48 49
49 50 contains( CONFIG, stack_report ) {
50 51 DEFINES += PRINT_STACK_REPORT
51 52 }
52 53
53 54 contains( CONFIG, boot_messages ) {
54 55 DEFINES += BOOT_MESSAGES
55 56 }
56 57
57 58 #doxygen.target = doxygen
58 59 #doxygen.commands = doxygen ../doc/Doxyfile
59 60 #QMAKE_EXTRA_TARGETS += doxygen
60 61
61 62 TARGET = fsw
62 63
63 64 INCLUDEPATH += \
64 65 $${PWD}/../src \
65 66 $${PWD}/../header \
66 67 $${PWD}/../header/lfr_common_headers \
67 68 $${PWD}/../header/processing \
68 69 $${PWD}/../LFR_basic-parameters
69 70
70 71 SOURCES += \
71 72 ../src/wf_handler.c \
72 73 ../src/tc_handler.c \
73 74 ../src/fsw_misc.c \
74 75 ../src/fsw_init.c \
75 76 ../src/fsw_globals.c \
76 77 ../src/fsw_spacewire.c \
77 78 ../src/tc_load_dump_parameters.c \
78 79 ../src/tm_lfr_tc_exe.c \
79 80 ../src/tc_acceptance.c \
80 81 ../src/processing/fsw_processing.c \
81 82 ../src/processing/avf0_prc0.c \
82 83 ../src/processing/avf1_prc1.c \
83 84 ../src/processing/avf2_prc2.c \
84 85 ../src/lfr_cpu_usage_report.c \
85 86 ../LFR_basic-parameters/basic_parameters.c
86 87
87 88 HEADERS += \
88 89 ../header/wf_handler.h \
89 90 ../header/tc_handler.h \
90 91 ../header/grlib_regs.h \
91 92 ../header/fsw_misc.h \
92 93 ../header/fsw_init.h \
93 94 ../header/fsw_spacewire.h \
94 95 ../header/tc_load_dump_parameters.h \
95 96 ../header/tm_lfr_tc_exe.h \
96 97 ../header/tc_acceptance.h \
97 98 ../header/processing/fsw_processing.h \
98 99 ../header/processing/avf0_prc0.h \
99 100 ../header/processing/avf1_prc1.h \
100 101 ../header/processing/avf2_prc2.h \
101 102 ../header/fsw_params_wf_handler.h \
102 103 ../header/lfr_cpu_usage_report.h \
103 104 ../header/lfr_common_headers/ccsds_types.h \
104 105 ../header/lfr_common_headers/fsw_params.h \
105 106 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
106 107 ../header/lfr_common_headers/fsw_params_processing.h \
107 108 ../header/lfr_common_headers/TC_types.h \
108 109 ../header/lfr_common_headers/tm_byte_positions.h \
109 110 ../LFR_basic-parameters/basic_parameters.h \
110 111 ../LFR_basic-parameters/basic_parameters_params.h \
111 112 ../header/GscMemoryLPP.hpp
112 113
@@ -1,869 +1,906
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 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
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 void test_bp1()
66 {
67 float test_matrix[25] = {
68 4.00109575e+06,
69 -2.19891187e+03,
70 1.73193325e+06,
71 1.88106079e+03,
72 -1.00001638e+06,
73 6.23724854e+02,
74 2.00016860e+07,
75 -3.46422920e+07,
76 -1.44333826e+03,
77 7.54424812e+05,
78 -4.36785375e+05,
79 2.34538879e+02,
80 8.65882200e+06,
81 -3.31611108e+03,
82 2.71719702e+03,
83 1.50027590e+07,
84 2.53229094e+05,
85 -4.99895450e+06,
86 2.90329712e+03,
87 -2.17048022e+03,
88 -8.66275100e+06,
89 1.00002952e+08,
90 -2.94739111e+03,
91 1.73206224e+08,
92 3.00003392e+08
93 };
94
95 uint8_t lfr_bp1[11];
96
97 BP1_set(test_matrix, k_coeff_intercalib_f0_norm, 1, lfr_bp1);
98 }
99
65 100 void initCache()
66 101 {
67 102 unsigned int cacheControlRegister;
68 103
69 104 cacheControlRegister = getCacheControlRegister();
70 105 printf("(0) cacheControlRegister = %x\n", cacheControlRegister);
71 106
72 107 resetCacheControlRegister();
73 108
74 109 enableInstructionCache();
75 110 enableDataCache();
76 111 enableInstructionBurstFetch();
77 112
78 113 cacheControlRegister = getCacheControlRegister();
79 114 printf("(1) cacheControlRegister = %x\n", cacheControlRegister);
80 115 }
81 116
82 117 rtems_task Init( rtems_task_argument ignored )
83 118 {
84 119 /** This is the RTEMS INIT taks, it is the first task launched by the system.
85 120 *
86 121 * @param unused is the starting argument of the RTEMS task
87 122 *
88 123 * The INIT task create and run all other RTEMS tasks.
89 124 *
90 125 */
91 126
92 127 //***********
93 128 // INIT CACHE
94 129
95 130 unsigned char *vhdlVersion;
96 131
97 132 reset_lfr();
98 133
99 134 reset_local_time();
100 135
101 136 rtems_cpu_usage_reset();
102 137
103 138 rtems_status_code status;
104 139 rtems_status_code status_spw;
105 140 rtems_isr_entry old_isr_handler;
106 141
107 142 // UART settings
108 143 send_console_outputs_on_apbuart_port();
109 144 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
110 145 enable_apbuart_transmitter();
111 146
112 147 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
113 148
114 149
115 150 PRINTF("\n\n\n\n\n")
116 151
117 152 initCache();
118 153
119 154 PRINTF("*************************\n")
120 155 PRINTF("** LFR Flight Software **\n")
121 156 PRINTF1("** %d.", SW_VERSION_N1)
122 157 PRINTF1("%d." , SW_VERSION_N2)
123 158 PRINTF1("%d." , SW_VERSION_N3)
124 159 PRINTF1("%d **\n", SW_VERSION_N4)
125 160
126 161 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
127 162 PRINTF("** VHDL **\n")
128 163 PRINTF1("** %d.", vhdlVersion[1])
129 164 PRINTF1("%d." , vhdlVersion[2])
130 165 PRINTF1("%d **\n", vhdlVersion[3])
131 166 PRINTF("*************************\n")
132 167 PRINTF("\n\n")
133 168
134 169 init_parameter_dump();
135 170 init_kcoefficients_dump();
136 171 init_local_mode_parameters();
137 172 init_housekeeping_parameters();
138 173 init_k_coefficients_prc0();
139 174 init_k_coefficients_prc1();
140 175 init_k_coefficients_prc2();
141 176
142 177 // waveform picker initialization
143 178 WFP_init_rings(); // initialize the waveform rings
144 179 WFP_reset_current_ring_nodes();
145 180 reset_waveform_picker_regs();
146 181
147 182 // spectral matrices initialization
148 183 SM_init_rings(); // initialize spectral matrices rings
149 184 SM_reset_current_ring_nodes();
150 185 reset_spectral_matrix_regs();
151 186
152 187 // configure calibration
153 188 configureCalibration( false ); // true means interleaved mode, false is for normal mode
154 189
155 190 updateLFRCurrentMode();
156 191
157 192 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
158 193
159 194 create_names(); // create all names
160 195
161 196 status = create_message_queues(); // create message queues
162 197 if (status != RTEMS_SUCCESSFUL)
163 198 {
164 199 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
165 200 }
166 201
167 202 status = create_all_tasks(); // create all tasks
168 203 if (status != RTEMS_SUCCESSFUL)
169 204 {
170 205 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
171 206 }
172 207
173 208 // **************************
174 209 // <SPACEWIRE INITIALIZATION>
175 210 grspw_timecode_callback = &timecode_irq_handler;
176 211
177 212 status_spw = spacewire_open_link(); // (1) open the link
178 213 if ( status_spw != RTEMS_SUCCESSFUL )
179 214 {
180 215 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
181 216 }
182 217
183 218 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
184 219 {
185 220 status_spw = spacewire_configure_link( fdSPW );
186 221 if ( status_spw != RTEMS_SUCCESSFUL )
187 222 {
188 223 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
189 224 }
190 225 }
191 226
192 227 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
193 228 {
194 229 status_spw = spacewire_start_link( fdSPW );
195 230 if ( status_spw != RTEMS_SUCCESSFUL )
196 231 {
197 232 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
198 233 }
199 234 }
200 235 // </SPACEWIRE INITIALIZATION>
201 236 // ***************************
202 237
203 238 status = start_all_tasks(); // start all tasks
204 239 if (status != RTEMS_SUCCESSFUL)
205 240 {
206 241 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
207 242 }
208 243
209 244 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
210 245 status = start_recv_send_tasks();
211 246 if ( status != RTEMS_SUCCESSFUL )
212 247 {
213 248 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
214 249 }
215 250
216 251 // suspend science tasks, they will be restarted later depending on the mode
217 252 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
218 253 if (status != RTEMS_SUCCESSFUL)
219 254 {
220 255 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
221 256 }
222 257
223 258 //******************************
224 259 // <SPECTRAL MATRICES SIMULATOR>
225 260 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
226 261 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
227 262 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
228 263 // </SPECTRAL MATRICES SIMULATOR>
229 264 //*******************************
230 265
231 266 // configure IRQ handling for the waveform picker unit
232 267 status = rtems_interrupt_catch( waveforms_isr,
233 268 IRQ_SPARC_WAVEFORM_PICKER,
234 269 &old_isr_handler) ;
235 270 // configure IRQ handling for the spectral matrices unit
236 271 status = rtems_interrupt_catch( spectral_matrices_isr,
237 272 IRQ_SPARC_SPECTRAL_MATRIX,
238 273 &old_isr_handler) ;
239 274
240 275 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
241 276 if ( status_spw != RTEMS_SUCCESSFUL )
242 277 {
243 278 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
244 279 if ( status != RTEMS_SUCCESSFUL ) {
245 280 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
246 281 }
247 282 }
248 283
249 284 BOOT_PRINTF("delete INIT\n")
250 285
286 test_bp1();
287
251 288 status = rtems_task_delete(RTEMS_SELF);
252 289
253 290 }
254 291
255 292 void init_local_mode_parameters( void )
256 293 {
257 294 /** This function initialize the param_local global variable with default values.
258 295 *
259 296 */
260 297
261 298 unsigned int i;
262 299
263 300 // LOCAL PARAMETERS
264 301
265 302 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
266 303 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
267 304 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
268 305
269 306 // init sequence counters
270 307
271 308 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
272 309 {
273 310 sequenceCounters_TC_EXE[i] = 0x00;
274 311 }
275 312 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
276 313 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
277 314 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
278 315 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
279 316 }
280 317
281 318 void reset_local_time( void )
282 319 {
283 320 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
284 321 }
285 322
286 323 void create_names( void ) // create all names for tasks and queues
287 324 {
288 325 /** This function creates all RTEMS names used in the software for tasks and queues.
289 326 *
290 327 * @return RTEMS directive status codes:
291 328 * - RTEMS_SUCCESSFUL - successful completion
292 329 *
293 330 */
294 331
295 332 // task names
296 333 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
297 334 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
298 335 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
299 336 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
300 337 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
301 338 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
302 339 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
303 340 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
304 341 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
305 342 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
306 343 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
307 344 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
308 345 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
309 346 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
310 347 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
311 348 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
312 349 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
313 350 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
314 351 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
315 352
316 353 // rate monotonic period names
317 354 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
318 355
319 356 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
320 357 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
321 358 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
322 359 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
323 360 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
324 361 }
325 362
326 363 int create_all_tasks( void ) // create all tasks which run in the software
327 364 {
328 365 /** This function creates all RTEMS tasks used in the software.
329 366 *
330 367 * @return RTEMS directive status codes:
331 368 * - RTEMS_SUCCESSFUL - task created successfully
332 369 * - RTEMS_INVALID_ADDRESS - id is NULL
333 370 * - RTEMS_INVALID_NAME - invalid task name
334 371 * - RTEMS_INVALID_PRIORITY - invalid task priority
335 372 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
336 373 * - RTEMS_TOO_MANY - too many tasks created
337 374 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
338 375 * - RTEMS_TOO_MANY - too many global objects
339 376 *
340 377 */
341 378
342 379 rtems_status_code status;
343 380
344 381 //**********
345 382 // SPACEWIRE
346 383 // RECV
347 384 status = rtems_task_create(
348 385 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
349 386 RTEMS_DEFAULT_MODES,
350 387 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
351 388 );
352 389 if (status == RTEMS_SUCCESSFUL) // SEND
353 390 {
354 391 status = rtems_task_create(
355 392 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
356 393 RTEMS_DEFAULT_MODES,
357 394 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
358 395 );
359 396 }
360 397 if (status == RTEMS_SUCCESSFUL) // WTDG
361 398 {
362 399 status = rtems_task_create(
363 400 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
364 401 RTEMS_DEFAULT_MODES,
365 402 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
366 403 );
367 404 }
368 405 if (status == RTEMS_SUCCESSFUL) // ACTN
369 406 {
370 407 status = rtems_task_create(
371 408 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
372 409 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
373 410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
374 411 );
375 412 }
376 413 if (status == RTEMS_SUCCESSFUL) // SPIQ
377 414 {
378 415 status = rtems_task_create(
379 416 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
380 417 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
381 418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
382 419 );
383 420 }
384 421
385 422 //******************
386 423 // SPECTRAL MATRICES
387 424 if (status == RTEMS_SUCCESSFUL) // AVF0
388 425 {
389 426 status = rtems_task_create(
390 427 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
391 428 RTEMS_DEFAULT_MODES,
392 429 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
393 430 );
394 431 }
395 432 if (status == RTEMS_SUCCESSFUL) // PRC0
396 433 {
397 434 status = rtems_task_create(
398 435 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
399 436 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
400 437 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
401 438 );
402 439 }
403 440 if (status == RTEMS_SUCCESSFUL) // AVF1
404 441 {
405 442 status = rtems_task_create(
406 443 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
407 444 RTEMS_DEFAULT_MODES,
408 445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
409 446 );
410 447 }
411 448 if (status == RTEMS_SUCCESSFUL) // PRC1
412 449 {
413 450 status = rtems_task_create(
414 451 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
415 452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
416 453 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
417 454 );
418 455 }
419 456 if (status == RTEMS_SUCCESSFUL) // AVF2
420 457 {
421 458 status = rtems_task_create(
422 459 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
423 460 RTEMS_DEFAULT_MODES,
424 461 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
425 462 );
426 463 }
427 464 if (status == RTEMS_SUCCESSFUL) // PRC2
428 465 {
429 466 status = rtems_task_create(
430 467 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
431 468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
432 469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
433 470 );
434 471 }
435 472
436 473 //****************
437 474 // WAVEFORM PICKER
438 475 if (status == RTEMS_SUCCESSFUL) // WFRM
439 476 {
440 477 status = rtems_task_create(
441 478 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
442 479 RTEMS_DEFAULT_MODES,
443 480 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
444 481 );
445 482 }
446 483 if (status == RTEMS_SUCCESSFUL) // CWF3
447 484 {
448 485 status = rtems_task_create(
449 486 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
450 487 RTEMS_DEFAULT_MODES,
451 488 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
452 489 );
453 490 }
454 491 if (status == RTEMS_SUCCESSFUL) // CWF2
455 492 {
456 493 status = rtems_task_create(
457 494 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
458 495 RTEMS_DEFAULT_MODES,
459 496 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
460 497 );
461 498 }
462 499 if (status == RTEMS_SUCCESSFUL) // CWF1
463 500 {
464 501 status = rtems_task_create(
465 502 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
466 503 RTEMS_DEFAULT_MODES,
467 504 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
468 505 );
469 506 }
470 507 if (status == RTEMS_SUCCESSFUL) // SWBD
471 508 {
472 509 status = rtems_task_create(
473 510 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
474 511 RTEMS_DEFAULT_MODES,
475 512 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
476 513 );
477 514 }
478 515
479 516 //*****
480 517 // MISC
481 518 if (status == RTEMS_SUCCESSFUL) // STAT
482 519 {
483 520 status = rtems_task_create(
484 521 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
485 522 RTEMS_DEFAULT_MODES,
486 523 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
487 524 );
488 525 }
489 526 if (status == RTEMS_SUCCESSFUL) // DUMB
490 527 {
491 528 status = rtems_task_create(
492 529 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
493 530 RTEMS_DEFAULT_MODES,
494 531 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
495 532 );
496 533 }
497 534 if (status == RTEMS_SUCCESSFUL) // HOUS
498 535 {
499 536 status = rtems_task_create(
500 537 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
501 538 RTEMS_DEFAULT_MODES,
502 539 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
503 540 );
504 541 }
505 542
506 543 return status;
507 544 }
508 545
509 546 int start_recv_send_tasks( void )
510 547 {
511 548 rtems_status_code status;
512 549
513 550 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
514 551 if (status!=RTEMS_SUCCESSFUL) {
515 552 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
516 553 }
517 554
518 555 if (status == RTEMS_SUCCESSFUL) // SEND
519 556 {
520 557 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
521 558 if (status!=RTEMS_SUCCESSFUL) {
522 559 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
523 560 }
524 561 }
525 562
526 563 return status;
527 564 }
528 565
529 566 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
530 567 {
531 568 /** This function starts all RTEMS tasks used in the software.
532 569 *
533 570 * @return RTEMS directive status codes:
534 571 * - RTEMS_SUCCESSFUL - ask started successfully
535 572 * - RTEMS_INVALID_ADDRESS - invalid task entry point
536 573 * - RTEMS_INVALID_ID - invalid task id
537 574 * - RTEMS_INCORRECT_STATE - task not in the dormant state
538 575 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
539 576 *
540 577 */
541 578 // starts all the tasks fot eh flight software
542 579
543 580 rtems_status_code status;
544 581
545 582 //**********
546 583 // SPACEWIRE
547 584 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
548 585 if (status!=RTEMS_SUCCESSFUL) {
549 586 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
550 587 }
551 588
552 589 if (status == RTEMS_SUCCESSFUL) // WTDG
553 590 {
554 591 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
555 592 if (status!=RTEMS_SUCCESSFUL) {
556 593 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
557 594 }
558 595 }
559 596
560 597 if (status == RTEMS_SUCCESSFUL) // ACTN
561 598 {
562 599 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
563 600 if (status!=RTEMS_SUCCESSFUL) {
564 601 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
565 602 }
566 603 }
567 604
568 605 //******************
569 606 // SPECTRAL MATRICES
570 607 if (status == RTEMS_SUCCESSFUL) // AVF0
571 608 {
572 609 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
573 610 if (status!=RTEMS_SUCCESSFUL) {
574 611 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
575 612 }
576 613 }
577 614 if (status == RTEMS_SUCCESSFUL) // PRC0
578 615 {
579 616 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
580 617 if (status!=RTEMS_SUCCESSFUL) {
581 618 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
582 619 }
583 620 }
584 621 if (status == RTEMS_SUCCESSFUL) // AVF1
585 622 {
586 623 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
587 624 if (status!=RTEMS_SUCCESSFUL) {
588 625 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
589 626 }
590 627 }
591 628 if (status == RTEMS_SUCCESSFUL) // PRC1
592 629 {
593 630 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
594 631 if (status!=RTEMS_SUCCESSFUL) {
595 632 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
596 633 }
597 634 }
598 635 if (status == RTEMS_SUCCESSFUL) // AVF2
599 636 {
600 637 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
601 638 if (status!=RTEMS_SUCCESSFUL) {
602 639 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
603 640 }
604 641 }
605 642 if (status == RTEMS_SUCCESSFUL) // PRC2
606 643 {
607 644 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
608 645 if (status!=RTEMS_SUCCESSFUL) {
609 646 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
610 647 }
611 648 }
612 649
613 650 //****************
614 651 // WAVEFORM PICKER
615 652 if (status == RTEMS_SUCCESSFUL) // WFRM
616 653 {
617 654 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
618 655 if (status!=RTEMS_SUCCESSFUL) {
619 656 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
620 657 }
621 658 }
622 659 if (status == RTEMS_SUCCESSFUL) // CWF3
623 660 {
624 661 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
625 662 if (status!=RTEMS_SUCCESSFUL) {
626 663 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
627 664 }
628 665 }
629 666 if (status == RTEMS_SUCCESSFUL) // CWF2
630 667 {
631 668 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
632 669 if (status!=RTEMS_SUCCESSFUL) {
633 670 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
634 671 }
635 672 }
636 673 if (status == RTEMS_SUCCESSFUL) // CWF1
637 674 {
638 675 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
639 676 if (status!=RTEMS_SUCCESSFUL) {
640 677 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
641 678 }
642 679 }
643 680 if (status == RTEMS_SUCCESSFUL) // SWBD
644 681 {
645 682 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
646 683 if (status!=RTEMS_SUCCESSFUL) {
647 684 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
648 685 }
649 686 }
650 687
651 688 //*****
652 689 // MISC
653 690 if (status == RTEMS_SUCCESSFUL) // HOUS
654 691 {
655 692 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
656 693 if (status!=RTEMS_SUCCESSFUL) {
657 694 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
658 695 }
659 696 }
660 697 if (status == RTEMS_SUCCESSFUL) // DUMB
661 698 {
662 699 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
663 700 if (status!=RTEMS_SUCCESSFUL) {
664 701 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
665 702 }
666 703 }
667 704 if (status == RTEMS_SUCCESSFUL) // STAT
668 705 {
669 706 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
670 707 if (status!=RTEMS_SUCCESSFUL) {
671 708 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
672 709 }
673 710 }
674 711
675 712 return status;
676 713 }
677 714
678 715 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
679 716 {
680 717 rtems_status_code status_recv;
681 718 rtems_status_code status_send;
682 719 rtems_status_code status_q_p0;
683 720 rtems_status_code status_q_p1;
684 721 rtems_status_code status_q_p2;
685 722 rtems_status_code ret;
686 723 rtems_id queue_id;
687 724
688 725 //****************************************
689 726 // create the queue for handling valid TCs
690 727 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
691 728 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
692 729 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
693 730 if ( status_recv != RTEMS_SUCCESSFUL ) {
694 731 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
695 732 }
696 733
697 734 //************************************************
698 735 // create the queue for handling TM packet sending
699 736 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
700 737 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
701 738 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
702 739 if ( status_send != RTEMS_SUCCESSFUL ) {
703 740 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
704 741 }
705 742
706 743 //*****************************************************************************
707 744 // create the queue for handling averaged spectral matrices for processing @ f0
708 745 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
709 746 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
710 747 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
711 748 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
712 749 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
713 750 }
714 751
715 752 //*****************************************************************************
716 753 // create the queue for handling averaged spectral matrices for processing @ f1
717 754 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
718 755 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
719 756 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
720 757 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
721 758 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
722 759 }
723 760
724 761 //*****************************************************************************
725 762 // create the queue for handling averaged spectral matrices for processing @ f2
726 763 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
727 764 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
728 765 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
729 766 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
730 767 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
731 768 }
732 769
733 770 if ( status_recv != RTEMS_SUCCESSFUL )
734 771 {
735 772 ret = status_recv;
736 773 }
737 774 else if( status_send != RTEMS_SUCCESSFUL )
738 775 {
739 776 ret = status_send;
740 777 }
741 778 else if( status_q_p0 != RTEMS_SUCCESSFUL )
742 779 {
743 780 ret = status_q_p0;
744 781 }
745 782 else if( status_q_p1 != RTEMS_SUCCESSFUL )
746 783 {
747 784 ret = status_q_p1;
748 785 }
749 786 else
750 787 {
751 788 ret = status_q_p2;
752 789 }
753 790
754 791 return ret;
755 792 }
756 793
757 794 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
758 795 {
759 796 rtems_status_code status;
760 797 rtems_name queue_name;
761 798
762 799 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
763 800
764 801 status = rtems_message_queue_ident( queue_name, 0, queue_id );
765 802
766 803 return status;
767 804 }
768 805
769 806 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
770 807 {
771 808 rtems_status_code status;
772 809 rtems_name queue_name;
773 810
774 811 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
775 812
776 813 status = rtems_message_queue_ident( queue_name, 0, queue_id );
777 814
778 815 return status;
779 816 }
780 817
781 818 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
782 819 {
783 820 rtems_status_code status;
784 821 rtems_name queue_name;
785 822
786 823 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
787 824
788 825 status = rtems_message_queue_ident( queue_name, 0, queue_id );
789 826
790 827 return status;
791 828 }
792 829
793 830 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
794 831 {
795 832 rtems_status_code status;
796 833 rtems_name queue_name;
797 834
798 835 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
799 836
800 837 status = rtems_message_queue_ident( queue_name, 0, queue_id );
801 838
802 839 return status;
803 840 }
804 841
805 842 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
806 843 {
807 844 rtems_status_code status;
808 845 rtems_name queue_name;
809 846
810 847 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
811 848
812 849 status = rtems_message_queue_ident( queue_name, 0, queue_id );
813 850
814 851 return status;
815 852 }
816 853
817 854 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
818 855 {
819 856 u_int32_t count;
820 857 rtems_status_code status;
821 858
822 859 status = rtems_message_queue_get_number_pending( queue_id, &count );
823 860
824 861 count = count + 1;
825 862
826 863 if (status != RTEMS_SUCCESSFUL)
827 864 {
828 865 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
829 866 }
830 867 else
831 868 {
832 869 if (count > *fifo_size_max)
833 870 {
834 871 *fifo_size_max = count;
835 872 }
836 873 }
837 874 }
838 875
839 876 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
840 877 {
841 878 unsigned char i;
842 879
843 880 //***************
844 881 // BUFFER ADDRESS
845 882 for(i=0; i<nbNodes; i++)
846 883 {
847 884 ring[i].coarseTime = 0xffffffff;
848 885 ring[i].fineTime = 0xffffffff;
849 886 ring[i].sid = 0x00;
850 887 ring[i].status = 0x00;
851 888 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
852 889 }
853 890
854 891 //*****
855 892 // NEXT
856 893 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
857 894 for(i=0; i<nbNodes-1; i++)
858 895 {
859 896 ring[i].next = (ring_node*) &ring[ i + 1 ];
860 897 }
861 898
862 899 //*********
863 900 // PREVIOUS
864 901 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
865 902 for(i=1; i<nbNodes; i++)
866 903 {
867 904 ring[i].previous = (ring_node*) &ring[ i - 1 ];
868 905 }
869 906 }
General Comments 0
You need to be logged in to leave comments. Login now