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