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