##// END OF EJS Templates
3.0.0.14
paul -
r255:8000c9c61c45 R3a
parent child
Show More
@@ -1,124 +1,124
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options =
4 4 # verbose
5 5 # boot_messages
6 6 # debug_messages
7 7 # cpu_usage_report
8 8 # stack_report
9 9 # vhdl_dev
10 10 # debug_tch
11 # lpp_dpu_destid REMOVE BEFORE DELIVERY TO LESIA
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 12 # debug_watchdog
13 13 CONFIG += console verbose lpp_dpu_destid
14 14 CONFIG -= qt
15 15
16 16 include(./sparc.pri)
17 17
18 18 # flight software version
19 19 SWVERSION=-1-0
20 20 DEFINES += SW_VERSION_N1=3 # major
21 21 DEFINES += SW_VERSION_N2=0 # minor
22 22 DEFINES += SW_VERSION_N3=0 # patch
23 23 DEFINES += SW_VERSION_N4=14 # internal
24 24
25 25 # <GCOV>
26 26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
27 27 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
28 28 # </GCOV>
29 29
30 30 # <CHANGE BEFORE FLIGHT>
31 31 contains( CONFIG, lpp_dpu_destid ) {
32 32 DEFINES += LPP_DPU_DESTID
33 33 }
34 34 # </CHANGE BEFORE FLIGHT>
35 35
36 36 contains( CONFIG, debug_tch ) {
37 37 DEFINES += DEBUG_TCH
38 38 }
39 39 DEFINES += MSB_FIRST_TCH
40 40
41 41 contains( CONFIG, vhdl_dev ) {
42 42 DEFINES += VHDL_DEV
43 43 }
44 44
45 45 contains( CONFIG, verbose ) {
46 46 DEFINES += PRINT_MESSAGES_ON_CONSOLE
47 47 }
48 48
49 49 contains( CONFIG, debug_messages ) {
50 50 DEFINES += DEBUG_MESSAGES
51 51 }
52 52
53 53 contains( CONFIG, cpu_usage_report ) {
54 54 DEFINES += PRINT_TASK_STATISTICS
55 55 }
56 56
57 57 contains( CONFIG, stack_report ) {
58 58 DEFINES += PRINT_STACK_REPORT
59 59 }
60 60
61 61 contains( CONFIG, boot_messages ) {
62 62 DEFINES += BOOT_MESSAGES
63 63 }
64 64
65 65 contains( CONFIG, debug_watchdog ) {
66 66 DEFINES += DEBUG_WATCHDOG
67 67 }
68 68
69 69 #doxygen.target = doxygen
70 70 #doxygen.commands = doxygen ../doc/Doxyfile
71 71 #QMAKE_EXTRA_TARGETS += doxygen
72 72
73 73 TARGET = fsw
74 74
75 75 INCLUDEPATH += \
76 76 $${PWD}/../src \
77 77 $${PWD}/../header \
78 78 $${PWD}/../header/lfr_common_headers \
79 79 $${PWD}/../header/processing \
80 80 $${PWD}/../LFR_basic-parameters
81 81
82 82 SOURCES += \
83 83 ../src/wf_handler.c \
84 84 ../src/tc_handler.c \
85 85 ../src/fsw_misc.c \
86 86 ../src/fsw_init.c \
87 87 ../src/fsw_globals.c \
88 88 ../src/fsw_spacewire.c \
89 89 ../src/tc_load_dump_parameters.c \
90 90 ../src/tm_lfr_tc_exe.c \
91 91 ../src/tc_acceptance.c \
92 92 ../src/processing/fsw_processing.c \
93 93 ../src/processing/avf0_prc0.c \
94 94 ../src/processing/avf1_prc1.c \
95 95 ../src/processing/avf2_prc2.c \
96 96 ../src/lfr_cpu_usage_report.c \
97 97 ../LFR_basic-parameters/basic_parameters.c
98 98
99 99 HEADERS += \
100 100 ../header/wf_handler.h \
101 101 ../header/tc_handler.h \
102 102 ../header/grlib_regs.h \
103 103 ../header/fsw_misc.h \
104 104 ../header/fsw_init.h \
105 105 ../header/fsw_spacewire.h \
106 106 ../header/tc_load_dump_parameters.h \
107 107 ../header/tm_lfr_tc_exe.h \
108 108 ../header/tc_acceptance.h \
109 109 ../header/processing/fsw_processing.h \
110 110 ../header/processing/avf0_prc0.h \
111 111 ../header/processing/avf1_prc1.h \
112 112 ../header/processing/avf2_prc2.h \
113 113 ../header/fsw_params_wf_handler.h \
114 114 ../header/lfr_cpu_usage_report.h \
115 115 ../header/lfr_common_headers/ccsds_types.h \
116 116 ../header/lfr_common_headers/fsw_params.h \
117 117 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
118 118 ../header/lfr_common_headers/fsw_params_processing.h \
119 119 ../header/lfr_common_headers/TC_types.h \
120 120 ../header/lfr_common_headers/tm_byte_positions.h \
121 121 ../LFR_basic-parameters/basic_parameters.h \
122 122 ../LFR_basic-parameters/basic_parameters_params.h \
123 123 ../header/GscMemoryLPP.hpp
124 124
@@ -1,1606 +1,1606
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14 #include "math.h"
15 15
16 16 //***********
17 17 // RTEMS TASK
18 18
19 19 rtems_task actn_task( rtems_task_argument unused )
20 20 {
21 21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
22 22 *
23 23 * @param unused is the starting argument of the RTEMS task
24 24 *
25 25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
26 26 * on the incoming TeleCommand.
27 27 *
28 28 */
29 29
30 30 int result;
31 31 rtems_status_code status; // RTEMS status code
32 32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
33 33 size_t size; // size of the incoming TC packet
34 34 unsigned char subtype; // subtype of the current TC packet
35 35 unsigned char time[6];
36 36 rtems_id queue_rcv_id;
37 37 rtems_id queue_snd_id;
38 38
39 39 status = get_message_queue_id_recv( &queue_rcv_id );
40 40 if (status != RTEMS_SUCCESSFUL)
41 41 {
42 42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
43 43 }
44 44
45 45 status = get_message_queue_id_send( &queue_snd_id );
46 46 if (status != RTEMS_SUCCESSFUL)
47 47 {
48 48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
49 49 }
50 50
51 51 result = LFR_SUCCESSFUL;
52 52 subtype = 0; // subtype of the current TC packet
53 53
54 54 BOOT_PRINTF("in ACTN *** \n")
55 55
56 56 while(1)
57 57 {
58 58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
59 59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
60 60 getTime( time ); // set time to the current time
61 61 if (status!=RTEMS_SUCCESSFUL)
62 62 {
63 63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
64 64 }
65 65 else
66 66 {
67 67 subtype = TC.serviceSubType;
68 68 switch(subtype)
69 69 {
70 70 case TC_SUBTYPE_RESET:
71 71 result = action_reset( &TC, queue_snd_id, time );
72 72 close_action( &TC, result, queue_snd_id );
73 73 break;
74 74 case TC_SUBTYPE_LOAD_COMM:
75 75 result = action_load_common_par( &TC );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 case TC_SUBTYPE_LOAD_NORM:
79 79 result = action_load_normal_par( &TC, queue_snd_id, time );
80 80 close_action( &TC, result, queue_snd_id );
81 81 break;
82 82 case TC_SUBTYPE_LOAD_BURST:
83 83 result = action_load_burst_par( &TC, queue_snd_id, time );
84 84 close_action( &TC, result, queue_snd_id );
85 85 break;
86 86 case TC_SUBTYPE_LOAD_SBM1:
87 87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 88 close_action( &TC, result, queue_snd_id );
89 89 break;
90 90 case TC_SUBTYPE_LOAD_SBM2:
91 91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
92 92 close_action( &TC, result, queue_snd_id );
93 93 break;
94 94 case TC_SUBTYPE_DUMP:
95 95 result = action_dump_par( &TC, queue_snd_id );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 case TC_SUBTYPE_ENTER:
99 99 result = action_enter_mode( &TC, queue_snd_id );
100 100 close_action( &TC, result, queue_snd_id );
101 101 break;
102 102 case TC_SUBTYPE_UPDT_INFO:
103 103 result = action_update_info( &TC, queue_snd_id );
104 104 close_action( &TC, result, queue_snd_id );
105 105 break;
106 106 case TC_SUBTYPE_EN_CAL:
107 107 result = action_enable_calibration( &TC, queue_snd_id, time );
108 108 close_action( &TC, result, queue_snd_id );
109 109 break;
110 110 case TC_SUBTYPE_DIS_CAL:
111 111 result = action_disable_calibration( &TC, queue_snd_id, time );
112 112 close_action( &TC, result, queue_snd_id );
113 113 break;
114 114 case TC_SUBTYPE_LOAD_K:
115 115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 case TC_SUBTYPE_DUMP_K:
119 119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
120 120 close_action( &TC, result, queue_snd_id );
121 121 break;
122 122 case TC_SUBTYPE_LOAD_FBINS:
123 123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
124 124 close_action( &TC, result, queue_snd_id );
125 125 break;
126 126 case TC_SUBTYPE_UPDT_TIME:
127 127 result = action_update_time( &TC );
128 128 close_action( &TC, result, queue_snd_id );
129 129 break;
130 130 default:
131 131 break;
132 132 }
133 133 }
134 134 }
135 135 }
136 136
137 137 //***********
138 138 // TC ACTIONS
139 139
140 140 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
141 141 {
142 142 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
143 143 *
144 144 * @param TC points to the TeleCommand packet that is being processed
145 145 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
146 146 *
147 147 */
148 148
149 149 PRINTF("this is the end!!!\n")
150 150 exit(0);
151 151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
152 152 return LFR_DEFAULT;
153 153 }
154 154
155 155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
156 156 {
157 157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
158 158 *
159 159 * @param TC points to the TeleCommand packet that is being processed
160 160 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
161 161 *
162 162 */
163 163
164 164 rtems_status_code status;
165 165 unsigned char requestedMode;
166 166 unsigned int *transitionCoarseTime_ptr;
167 167 unsigned int transitionCoarseTime;
168 168 unsigned char * bytePosPtr;
169 169
170 170 bytePosPtr = (unsigned char *) &TC->packetID;
171 171
172 172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
173 173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
174 174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
175 175
176 176 status = check_mode_value( requestedMode );
177 177
178 178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
179 179 {
180 180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
181 181 }
182 182
183 183 else // the mode value is valid, check the transition
184 184 {
185 185 status = check_mode_transition(requestedMode);
186 186 if (status != LFR_SUCCESSFUL)
187 187 {
188 188 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
189 189 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 190 }
191 191 }
192 192
193 193 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
194 194 {
195 195 status = check_transition_date( transitionCoarseTime );
196 196 if (status != LFR_SUCCESSFUL)
197 197 {
198 198 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
199 199 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
200 200 }
201 201 }
202 202
203 203 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
204 204 {
205 205 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
206 206
207 207 update_last_valid_transition_date( transitionCoarseTime );
208 208
209 209 switch(requestedMode)
210 210 {
211 211 case LFR_MODE_STANDBY:
212 212 status = enter_mode_standby();
213 213 break;
214 214 case LFR_MODE_NORMAL:
215 215 status = enter_mode_normal( transitionCoarseTime );
216 216 break;
217 217 case LFR_MODE_BURST:
218 218 status = enter_mode_burst( transitionCoarseTime );
219 219 break;
220 220 case LFR_MODE_SBM1:
221 221 status = enter_mode_sbm1( transitionCoarseTime );
222 222 break;
223 223 case LFR_MODE_SBM2:
224 224 status = enter_mode_sbm2( transitionCoarseTime );
225 225 break;
226 226 default:
227 227 break;
228 228 }
229 229 }
230 230
231 231 return status;
232 232 }
233 233
234 234 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
235 235 {
236 236 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
237 237 *
238 238 * @param TC points to the TeleCommand packet that is being processed
239 239 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
240 240 *
241 241 * @return LFR directive status code:
242 242 * - LFR_DEFAULT
243 243 * - LFR_SUCCESSFUL
244 244 *
245 245 */
246 246
247 247 unsigned int val;
248 248 int result;
249 249 unsigned int status;
250 250 unsigned char mode;
251 251 unsigned char * bytePosPtr;
252 252
253 253 bytePosPtr = (unsigned char *) &TC->packetID;
254 254
255 255 // check LFR mode
256 256 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
257 257 status = check_update_info_hk_lfr_mode( mode );
258 258 if (status == LFR_SUCCESSFUL) // check TDS mode
259 259 {
260 260 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
261 261 status = check_update_info_hk_tds_mode( mode );
262 262 }
263 263 if (status == LFR_SUCCESSFUL) // check THR mode
264 264 {
265 265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
266 266 status = check_update_info_hk_thr_mode( mode );
267 267 }
268 268 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
269 269 {
270 270 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
271 271 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
272 272 val++;
273 273 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
274 274 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
275 275 }
276 276
277 277 // pa_bia_status_info
278 278 // => pa_bia_mode_mux_set 3 bits
279 279 // => pa_bia_mode_hv_enabled 1 bit
280 280 // => pa_bia_mode_bias1_enabled 1 bit
281 281 // => pa_bia_mode_bias2_enabled 1 bit
282 282 // => pa_bia_mode_bias3_enabled 1 bit
283 283 // => pa_bia_on_off (cp_dpu_bias_on_off)
284 284 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
285 285 pa_bia_status_info = pa_bia_status_info
286 286 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
287 287
288 288 result = status;
289 289
290 290 return result;
291 291 }
292 292
293 293 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
294 294 {
295 295 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
296 296 *
297 297 * @param TC points to the TeleCommand packet that is being processed
298 298 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
299 299 *
300 300 */
301 301
302 302 int result;
303 303
304 304 result = LFR_DEFAULT;
305 305
306 306 setCalibration( true );
307 307
308 308 result = LFR_SUCCESSFUL;
309 309
310 310 return result;
311 311 }
312 312
313 313 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 314 {
315 315 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
316 316 *
317 317 * @param TC points to the TeleCommand packet that is being processed
318 318 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
319 319 *
320 320 */
321 321
322 322 int result;
323 323
324 324 result = LFR_DEFAULT;
325 325
326 326 setCalibration( false );
327 327
328 328 result = LFR_SUCCESSFUL;
329 329
330 330 return result;
331 331 }
332 332
333 333 int action_update_time(ccsdsTelecommandPacket_t *TC)
334 334 {
335 335 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
336 336 *
337 337 * @param TC points to the TeleCommand packet that is being processed
338 338 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
339 339 *
340 340 * @return LFR_SUCCESSFUL
341 341 *
342 342 */
343 343
344 344 unsigned int val;
345 345
346 346 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
347 347 + (TC->dataAndCRC[1] << 16)
348 348 + (TC->dataAndCRC[2] << 8)
349 349 + TC->dataAndCRC[3];
350 350
351 351 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
352 352 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
353 353 val++;
354 354 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
355 355 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
356 356
357 357 return LFR_SUCCESSFUL;
358 358 }
359 359
360 360 //*******************
361 361 // ENTERING THE MODES
362 362 int check_mode_value( unsigned char requestedMode )
363 363 {
364 364 int status;
365 365
366 366 if ( (requestedMode != LFR_MODE_STANDBY)
367 367 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
368 368 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
369 369 {
370 370 status = LFR_DEFAULT;
371 371 }
372 372 else
373 373 {
374 374 status = LFR_SUCCESSFUL;
375 375 }
376 376
377 377 return status;
378 378 }
379 379
380 380 int check_mode_transition( unsigned char requestedMode )
381 381 {
382 382 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
383 383 *
384 384 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
385 385 *
386 386 * @return LFR directive status codes:
387 387 * - LFR_SUCCESSFUL - the transition is authorized
388 388 * - LFR_DEFAULT - the transition is not authorized
389 389 *
390 390 */
391 391
392 392 int status;
393 393
394 394 switch (requestedMode)
395 395 {
396 396 case LFR_MODE_STANDBY:
397 397 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
398 398 status = LFR_DEFAULT;
399 399 }
400 400 else
401 401 {
402 402 status = LFR_SUCCESSFUL;
403 403 }
404 404 break;
405 405 case LFR_MODE_NORMAL:
406 406 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
407 407 status = LFR_DEFAULT;
408 408 }
409 409 else {
410 410 status = LFR_SUCCESSFUL;
411 411 }
412 412 break;
413 413 case LFR_MODE_BURST:
414 414 if ( lfrCurrentMode == LFR_MODE_BURST ) {
415 415 status = LFR_DEFAULT;
416 416 }
417 417 else {
418 418 status = LFR_SUCCESSFUL;
419 419 }
420 420 break;
421 421 case LFR_MODE_SBM1:
422 422 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
423 423 status = LFR_DEFAULT;
424 424 }
425 425 else {
426 426 status = LFR_SUCCESSFUL;
427 427 }
428 428 break;
429 429 case LFR_MODE_SBM2:
430 430 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
431 431 status = LFR_DEFAULT;
432 432 }
433 433 else {
434 434 status = LFR_SUCCESSFUL;
435 435 }
436 436 break;
437 437 default:
438 438 status = LFR_DEFAULT;
439 439 break;
440 440 }
441 441
442 442 return status;
443 443 }
444 444
445 445 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
446 446 {
447 447 lastValidEnterModeTime = transitionCoarseTime;
448 PRINTF1("lastValidEnterModeTime = %x\n", transitionCoarseTime);
448 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
449 449 }
450 450
451 451 int check_transition_date( unsigned int transitionCoarseTime )
452 452 {
453 453 int status;
454 454 unsigned int localCoarseTime;
455 455 unsigned int deltaCoarseTime;
456 456
457 457 status = LFR_SUCCESSFUL;
458 458
459 459 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
460 460 {
461 461 status = LFR_SUCCESSFUL;
462 462 }
463 463 else
464 464 {
465 465 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
466 466
467 467 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
468 468
469 469 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
470 470 {
471 471 status = LFR_DEFAULT;
472 472 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
473 473 }
474 474
475 475 if (status == LFR_SUCCESSFUL)
476 476 {
477 477 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
478 478 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
479 479 {
480 480 status = LFR_DEFAULT;
481 481 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
482 482 }
483 483 }
484 484 }
485 485
486 486 return status;
487 487 }
488 488
489 489 int restart_asm_activities( unsigned char lfrRequestedMode )
490 490 {
491 491 rtems_status_code status;
492 492
493 493 status = stop_spectral_matrices();
494 494
495 495 status = restart_asm_tasks( lfrRequestedMode );
496 496
497 497 launch_spectral_matrix();
498 498
499 499 return status;
500 500 }
501 501
502 502 int stop_spectral_matrices( void )
503 503 {
504 504 /** This function stops and restarts the current mode average spectral matrices activities.
505 505 *
506 506 * @return RTEMS directive status codes:
507 507 * - RTEMS_SUCCESSFUL - task restarted successfully
508 508 * - RTEMS_INVALID_ID - task id invalid
509 509 * - RTEMS_ALREADY_SUSPENDED - task already suspended
510 510 *
511 511 */
512 512
513 513 rtems_status_code status;
514 514
515 515 status = RTEMS_SUCCESSFUL;
516 516
517 517 // (1) mask interruptions
518 518 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
519 519
520 520 // (2) reset spectral matrices registers
521 521 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
522 522 reset_sm_status();
523 523
524 524 // (3) clear interruptions
525 525 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
526 526
527 527 // suspend several tasks
528 528 if (lfrCurrentMode != LFR_MODE_STANDBY) {
529 529 status = suspend_asm_tasks();
530 530 }
531 531
532 532 if (status != RTEMS_SUCCESSFUL)
533 533 {
534 534 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
535 535 }
536 536
537 537 return status;
538 538 }
539 539
540 540 int stop_current_mode( void )
541 541 {
542 542 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
543 543 *
544 544 * @return RTEMS directive status codes:
545 545 * - RTEMS_SUCCESSFUL - task restarted successfully
546 546 * - RTEMS_INVALID_ID - task id invalid
547 547 * - RTEMS_ALREADY_SUSPENDED - task already suspended
548 548 *
549 549 */
550 550
551 551 rtems_status_code status;
552 552
553 553 status = RTEMS_SUCCESSFUL;
554 554
555 555 // (1) mask interruptions
556 556 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
557 557 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
558 558
559 559 // (2) reset waveform picker registers
560 560 reset_wfp_burst_enable(); // reset burst and enable bits
561 561 reset_wfp_status(); // reset all the status bits
562 562
563 563 // (3) reset spectral matrices registers
564 564 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
565 565 reset_sm_status();
566 566
567 567 // reset lfr VHDL module
568 568 reset_lfr();
569 569
570 570 reset_extractSWF(); // reset the extractSWF flag to false
571 571
572 572 // (4) clear interruptions
573 573 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
574 574 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
575 575
576 576 // suspend several tasks
577 577 if (lfrCurrentMode != LFR_MODE_STANDBY) {
578 578 status = suspend_science_tasks();
579 579 }
580 580
581 581 if (status != RTEMS_SUCCESSFUL)
582 582 {
583 583 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
584 584 }
585 585
586 586 return status;
587 587 }
588 588
589 589 int enter_mode_standby( void )
590 590 {
591 591 /** This function is used to put LFR in the STANDBY mode.
592 592 *
593 593 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
594 594 *
595 595 * @return RTEMS directive status codes:
596 596 * - RTEMS_SUCCESSFUL - task restarted successfully
597 597 * - RTEMS_INVALID_ID - task id invalid
598 598 * - RTEMS_INCORRECT_STATE - task never started
599 599 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
600 600 *
601 601 * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE
602 602 * is immediate.
603 603 *
604 604 */
605 605
606 606 int status;
607 607
608 608 status = stop_current_mode(); // STOP THE CURRENT MODE
609 609
610 610 #ifdef PRINT_TASK_STATISTICS
611 611 rtems_cpu_usage_report();
612 612 #endif
613 613
614 614 #ifdef PRINT_STACK_REPORT
615 615 PRINTF("stack report selected\n")
616 616 rtems_stack_checker_report_usage();
617 617 #endif
618 618
619 619 return status;
620 620 }
621 621
622 622 int enter_mode_normal( unsigned int transitionCoarseTime )
623 623 {
624 624 /** This function is used to start the NORMAL mode.
625 625 *
626 626 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
627 627 *
628 628 * @return RTEMS directive status codes:
629 629 * - RTEMS_SUCCESSFUL - task restarted successfully
630 630 * - RTEMS_INVALID_ID - task id invalid
631 631 * - RTEMS_INCORRECT_STATE - task never started
632 632 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
633 633 *
634 634 * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2,
635 635 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected.
636 636 *
637 637 */
638 638
639 639 int status;
640 640
641 641 #ifdef PRINT_TASK_STATISTICS
642 642 rtems_cpu_usage_reset();
643 643 #endif
644 644
645 645 status = RTEMS_UNSATISFIED;
646 646
647 647 switch( lfrCurrentMode )
648 648 {
649 649 case LFR_MODE_STANDBY:
650 650 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
651 651 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
652 652 {
653 653 launch_spectral_matrix( );
654 654 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
655 655 }
656 656 break;
657 657 case LFR_MODE_BURST:
658 658 status = stop_current_mode(); // stop the current mode
659 659 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
660 660 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
661 661 {
662 662 launch_spectral_matrix( );
663 663 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
664 664 }
665 665 break;
666 666 case LFR_MODE_SBM1:
667 667 restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
668 668 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
669 669 break;
670 670 case LFR_MODE_SBM2:
671 671 restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
672 672 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
673 673 break;
674 674 default:
675 675 break;
676 676 }
677 677
678 678 if (status != RTEMS_SUCCESSFUL)
679 679 {
680 680 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
681 681 status = RTEMS_UNSATISFIED;
682 682 }
683 683
684 684 return status;
685 685 }
686 686
687 687 int enter_mode_burst( unsigned int transitionCoarseTime )
688 688 {
689 689 /** This function is used to start the BURST mode.
690 690 *
691 691 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
692 692 *
693 693 * @return RTEMS directive status codes:
694 694 * - RTEMS_SUCCESSFUL - task restarted successfully
695 695 * - RTEMS_INVALID_ID - task id invalid
696 696 * - RTEMS_INCORRECT_STATE - task never started
697 697 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
698 698 *
699 699 * The way the BURST mode is started does not depend on the LFR current mode.
700 700 *
701 701 */
702 702
703 703
704 704 int status;
705 705
706 706 #ifdef PRINT_TASK_STATISTICS
707 707 rtems_cpu_usage_reset();
708 708 #endif
709 709
710 710 status = stop_current_mode(); // stop the current mode
711 711 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
712 712 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
713 713 {
714 714 launch_spectral_matrix( );
715 715 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
716 716 }
717 717
718 718 if (status != RTEMS_SUCCESSFUL)
719 719 {
720 720 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
721 721 status = RTEMS_UNSATISFIED;
722 722 }
723 723
724 724 return status;
725 725 }
726 726
727 727 int enter_mode_sbm1( unsigned int transitionCoarseTime )
728 728 {
729 729 /** This function is used to start the SBM1 mode.
730 730 *
731 731 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
732 732 *
733 733 * @return RTEMS directive status codes:
734 734 * - RTEMS_SUCCESSFUL - task restarted successfully
735 735 * - RTEMS_INVALID_ID - task id invalid
736 736 * - RTEMS_INCORRECT_STATE - task never started
737 737 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
738 738 *
739 739 * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2,
740 740 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
741 741 * cases, the acquisition is completely restarted.
742 742 *
743 743 */
744 744
745 745 int status;
746 746
747 747 #ifdef PRINT_TASK_STATISTICS
748 748 rtems_cpu_usage_reset();
749 749 #endif
750 750
751 751 status = RTEMS_UNSATISFIED;
752 752
753 753 switch( lfrCurrentMode )
754 754 {
755 755 case LFR_MODE_STANDBY:
756 756 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
757 757 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
758 758 {
759 759 launch_spectral_matrix( );
760 760 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
761 761 }
762 762 break;
763 763 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
764 764 restart_asm_activities( LFR_MODE_SBM1 );
765 765 status = LFR_SUCCESSFUL;
766 766 break;
767 767 case LFR_MODE_BURST:
768 768 status = stop_current_mode(); // stop the current mode
769 769 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
770 770 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
771 771 {
772 772 launch_spectral_matrix( );
773 773 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
774 774 }
775 775 break;
776 776 case LFR_MODE_SBM2:
777 777 restart_asm_activities( LFR_MODE_SBM1 );
778 778 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
779 779 break;
780 780 default:
781 781 break;
782 782 }
783 783
784 784 if (status != RTEMS_SUCCESSFUL)
785 785 {
786 786 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status)
787 787 status = RTEMS_UNSATISFIED;
788 788 }
789 789
790 790 return status;
791 791 }
792 792
793 793 int enter_mode_sbm2( unsigned int transitionCoarseTime )
794 794 {
795 795 /** This function is used to start the SBM2 mode.
796 796 *
797 797 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
798 798 *
799 799 * @return RTEMS directive status codes:
800 800 * - RTEMS_SUCCESSFUL - task restarted successfully
801 801 * - RTEMS_INVALID_ID - task id invalid
802 802 * - RTEMS_INCORRECT_STATE - task never started
803 803 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
804 804 *
805 805 * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1,
806 806 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
807 807 * cases, the acquisition is completely restarted.
808 808 *
809 809 */
810 810
811 811 int status;
812 812
813 813 #ifdef PRINT_TASK_STATISTICS
814 814 rtems_cpu_usage_reset();
815 815 #endif
816 816
817 817 status = RTEMS_UNSATISFIED;
818 818
819 819 switch( lfrCurrentMode )
820 820 {
821 821 case LFR_MODE_STANDBY:
822 822 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
823 823 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
824 824 {
825 825 launch_spectral_matrix( );
826 826 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
827 827 }
828 828 break;
829 829 case LFR_MODE_NORMAL:
830 830 restart_asm_activities( LFR_MODE_SBM2 );
831 831 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
832 832 break;
833 833 case LFR_MODE_BURST:
834 834 status = stop_current_mode(); // stop the current mode
835 835 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
836 836 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
837 837 {
838 838 launch_spectral_matrix( );
839 839 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
840 840 }
841 841 break;
842 842 case LFR_MODE_SBM1:
843 843 restart_asm_activities( LFR_MODE_SBM2 );
844 844 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
845 845 break;
846 846 default:
847 847 break;
848 848 }
849 849
850 850 if (status != RTEMS_SUCCESSFUL)
851 851 {
852 852 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
853 853 status = RTEMS_UNSATISFIED;
854 854 }
855 855
856 856 return status;
857 857 }
858 858
859 859 int restart_science_tasks( unsigned char lfrRequestedMode )
860 860 {
861 861 /** This function is used to restart all science tasks.
862 862 *
863 863 * @return RTEMS directive status codes:
864 864 * - RTEMS_SUCCESSFUL - task restarted successfully
865 865 * - RTEMS_INVALID_ID - task id invalid
866 866 * - RTEMS_INCORRECT_STATE - task never started
867 867 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
868 868 *
869 869 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
870 870 *
871 871 */
872 872
873 873 rtems_status_code status[10];
874 874 rtems_status_code ret;
875 875
876 876 ret = RTEMS_SUCCESSFUL;
877 877
878 878 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
879 879 if (status[0] != RTEMS_SUCCESSFUL)
880 880 {
881 881 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
882 882 }
883 883
884 884 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
885 885 if (status[1] != RTEMS_SUCCESSFUL)
886 886 {
887 887 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
888 888 }
889 889
890 890 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
891 891 if (status[2] != RTEMS_SUCCESSFUL)
892 892 {
893 893 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
894 894 }
895 895
896 896 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
897 897 if (status[3] != RTEMS_SUCCESSFUL)
898 898 {
899 899 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
900 900 }
901 901
902 902 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
903 903 if (status[4] != RTEMS_SUCCESSFUL)
904 904 {
905 905 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
906 906 }
907 907
908 908 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
909 909 if (status[5] != RTEMS_SUCCESSFUL)
910 910 {
911 911 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
912 912 }
913 913
914 914 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
915 915 if (status[6] != RTEMS_SUCCESSFUL)
916 916 {
917 917 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
918 918 }
919 919
920 920 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
921 921 if (status[7] != RTEMS_SUCCESSFUL)
922 922 {
923 923 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
924 924 }
925 925
926 926 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
927 927 if (status[8] != RTEMS_SUCCESSFUL)
928 928 {
929 929 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
930 930 }
931 931
932 932 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
933 933 if (status[9] != RTEMS_SUCCESSFUL)
934 934 {
935 935 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
936 936 }
937 937
938 938 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
939 939 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
940 940 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
941 941 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
942 942 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
943 943 {
944 944 ret = RTEMS_UNSATISFIED;
945 945 }
946 946
947 947 return ret;
948 948 }
949 949
950 950 int restart_asm_tasks( unsigned char lfrRequestedMode )
951 951 {
952 952 /** This function is used to restart average spectral matrices tasks.
953 953 *
954 954 * @return RTEMS directive status codes:
955 955 * - RTEMS_SUCCESSFUL - task restarted successfully
956 956 * - RTEMS_INVALID_ID - task id invalid
957 957 * - RTEMS_INCORRECT_STATE - task never started
958 958 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
959 959 *
960 960 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
961 961 *
962 962 */
963 963
964 964 rtems_status_code status[6];
965 965 rtems_status_code ret;
966 966
967 967 ret = RTEMS_SUCCESSFUL;
968 968
969 969 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
970 970 if (status[0] != RTEMS_SUCCESSFUL)
971 971 {
972 972 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
973 973 }
974 974
975 975 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
976 976 if (status[1] != RTEMS_SUCCESSFUL)
977 977 {
978 978 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
979 979 }
980 980
981 981 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
982 982 if (status[2] != RTEMS_SUCCESSFUL)
983 983 {
984 984 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
985 985 }
986 986
987 987 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
988 988 if (status[3] != RTEMS_SUCCESSFUL)
989 989 {
990 990 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
991 991 }
992 992
993 993 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
994 994 if (status[4] != RTEMS_SUCCESSFUL)
995 995 {
996 996 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
997 997 }
998 998
999 999 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1000 1000 if (status[5] != RTEMS_SUCCESSFUL)
1001 1001 {
1002 1002 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
1003 1003 }
1004 1004
1005 1005 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
1006 1006 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
1007 1007 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1008 1008 {
1009 1009 ret = RTEMS_UNSATISFIED;
1010 1010 }
1011 1011
1012 1012 return ret;
1013 1013 }
1014 1014
1015 1015 int suspend_science_tasks( void )
1016 1016 {
1017 1017 /** This function suspends the science tasks.
1018 1018 *
1019 1019 * @return RTEMS directive status codes:
1020 1020 * - RTEMS_SUCCESSFUL - task restarted successfully
1021 1021 * - RTEMS_INVALID_ID - task id invalid
1022 1022 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1023 1023 *
1024 1024 */
1025 1025
1026 1026 rtems_status_code status;
1027 1027
1028 1028 PRINTF("in suspend_science_tasks\n")
1029 1029
1030 1030 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1031 1031 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1032 1032 {
1033 1033 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1034 1034 }
1035 1035 else
1036 1036 {
1037 1037 status = RTEMS_SUCCESSFUL;
1038 1038 }
1039 1039 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1040 1040 {
1041 1041 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1042 1042 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1043 1043 {
1044 1044 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1045 1045 }
1046 1046 else
1047 1047 {
1048 1048 status = RTEMS_SUCCESSFUL;
1049 1049 }
1050 1050 }
1051 1051 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1052 1052 {
1053 1053 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1054 1054 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1055 1055 {
1056 1056 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1057 1057 }
1058 1058 else
1059 1059 {
1060 1060 status = RTEMS_SUCCESSFUL;
1061 1061 }
1062 1062 }
1063 1063 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1064 1064 {
1065 1065 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1066 1066 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1067 1067 {
1068 1068 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1069 1069 }
1070 1070 else
1071 1071 {
1072 1072 status = RTEMS_SUCCESSFUL;
1073 1073 }
1074 1074 }
1075 1075 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1076 1076 {
1077 1077 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1078 1078 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1079 1079 {
1080 1080 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1081 1081 }
1082 1082 else
1083 1083 {
1084 1084 status = RTEMS_SUCCESSFUL;
1085 1085 }
1086 1086 }
1087 1087 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1088 1088 {
1089 1089 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1090 1090 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1091 1091 {
1092 1092 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1093 1093 }
1094 1094 else
1095 1095 {
1096 1096 status = RTEMS_SUCCESSFUL;
1097 1097 }
1098 1098 }
1099 1099 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1100 1100 {
1101 1101 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1102 1102 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1103 1103 {
1104 1104 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1105 1105 }
1106 1106 else
1107 1107 {
1108 1108 status = RTEMS_SUCCESSFUL;
1109 1109 }
1110 1110 }
1111 1111 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1112 1112 {
1113 1113 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1114 1114 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1115 1115 {
1116 1116 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1117 1117 }
1118 1118 else
1119 1119 {
1120 1120 status = RTEMS_SUCCESSFUL;
1121 1121 }
1122 1122 }
1123 1123 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1124 1124 {
1125 1125 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1126 1126 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1127 1127 {
1128 1128 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1129 1129 }
1130 1130 else
1131 1131 {
1132 1132 status = RTEMS_SUCCESSFUL;
1133 1133 }
1134 1134 }
1135 1135 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1136 1136 {
1137 1137 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1138 1138 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1139 1139 {
1140 1140 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1141 1141 }
1142 1142 else
1143 1143 {
1144 1144 status = RTEMS_SUCCESSFUL;
1145 1145 }
1146 1146 }
1147 1147
1148 1148 return status;
1149 1149 }
1150 1150
1151 1151 int suspend_asm_tasks( void )
1152 1152 {
1153 1153 /** This function suspends the science tasks.
1154 1154 *
1155 1155 * @return RTEMS directive status codes:
1156 1156 * - RTEMS_SUCCESSFUL - task restarted successfully
1157 1157 * - RTEMS_INVALID_ID - task id invalid
1158 1158 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1159 1159 *
1160 1160 */
1161 1161
1162 1162 rtems_status_code status;
1163 1163
1164 1164 PRINTF("in suspend_science_tasks\n")
1165 1165
1166 1166 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1167 1167 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1168 1168 {
1169 1169 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1170 1170 }
1171 1171 else
1172 1172 {
1173 1173 status = RTEMS_SUCCESSFUL;
1174 1174 }
1175 1175
1176 1176 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1177 1177 {
1178 1178 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1179 1179 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1180 1180 {
1181 1181 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1182 1182 }
1183 1183 else
1184 1184 {
1185 1185 status = RTEMS_SUCCESSFUL;
1186 1186 }
1187 1187 }
1188 1188
1189 1189 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1190 1190 {
1191 1191 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1192 1192 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1193 1193 {
1194 1194 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1195 1195 }
1196 1196 else
1197 1197 {
1198 1198 status = RTEMS_SUCCESSFUL;
1199 1199 }
1200 1200 }
1201 1201
1202 1202 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1203 1203 {
1204 1204 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1205 1205 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1206 1206 {
1207 1207 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1208 1208 }
1209 1209 else
1210 1210 {
1211 1211 status = RTEMS_SUCCESSFUL;
1212 1212 }
1213 1213 }
1214 1214
1215 1215 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1216 1216 {
1217 1217 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1218 1218 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1219 1219 {
1220 1220 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1221 1221 }
1222 1222 else
1223 1223 {
1224 1224 status = RTEMS_SUCCESSFUL;
1225 1225 }
1226 1226 }
1227 1227
1228 1228 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1229 1229 {
1230 1230 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1231 1231 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1232 1232 {
1233 1233 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1234 1234 }
1235 1235 else
1236 1236 {
1237 1237 status = RTEMS_SUCCESSFUL;
1238 1238 }
1239 1239 }
1240 1240
1241 1241 return status;
1242 1242 }
1243 1243
1244 1244 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1245 1245 {
1246 1246 WFP_reset_current_ring_nodes();
1247 1247
1248 1248 reset_waveform_picker_regs();
1249 1249
1250 1250 set_wfp_burst_enable_register( mode );
1251 1251
1252 1252 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1253 1253 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1254 1254
1255 1255 if (transitionCoarseTime == 0)
1256 1256 {
1257 1257 // instant transition means transition on the next valid date
1258 1258 // this is mandatory to have a good snapshot period a a good correction of the snapshot period
1259 1259 waveform_picker_regs->start_date = time_management_regs->coarse_time + 1;
1260 1260 }
1261 1261 else
1262 1262 {
1263 1263 waveform_picker_regs->start_date = transitionCoarseTime;
1264 1264 }
1265 1265
1266 1266 }
1267 1267
1268 1268 void launch_spectral_matrix( void )
1269 1269 {
1270 1270 SM_reset_current_ring_nodes();
1271 1271
1272 1272 reset_spectral_matrix_regs();
1273 1273
1274 1274 reset_nb_sm();
1275 1275
1276 1276 set_sm_irq_onNewMatrix( 1 );
1277 1277
1278 1278 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1279 1279 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1280 1280
1281 1281 }
1282 1282
1283 1283 void set_sm_irq_onNewMatrix( unsigned char value )
1284 1284 {
1285 1285 if (value == 1)
1286 1286 {
1287 1287 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1288 1288 }
1289 1289 else
1290 1290 {
1291 1291 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1292 1292 }
1293 1293 }
1294 1294
1295 1295 void set_sm_irq_onError( unsigned char value )
1296 1296 {
1297 1297 if (value == 1)
1298 1298 {
1299 1299 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1300 1300 }
1301 1301 else
1302 1302 {
1303 1303 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1304 1304 }
1305 1305 }
1306 1306
1307 1307 //*****************************
1308 1308 // CONFIGURE CALIBRATION SIGNAL
1309 1309 void setCalibrationPrescaler( unsigned int prescaler )
1310 1310 {
1311 1311 // prescaling of the master clock (25 MHz)
1312 1312 // master clock is divided by 2^prescaler
1313 1313 time_management_regs->calPrescaler = prescaler;
1314 1314 }
1315 1315
1316 1316 void setCalibrationDivisor( unsigned int divisionFactor )
1317 1317 {
1318 1318 // division of the prescaled clock by the division factor
1319 1319 time_management_regs->calDivisor = divisionFactor;
1320 1320 }
1321 1321
1322 1322 void setCalibrationData( void ){
1323 1323 unsigned int k;
1324 1324 unsigned short data;
1325 1325 float val;
1326 1326 float f0;
1327 1327 float f1;
1328 1328 float fs;
1329 1329 float Ts;
1330 1330 float scaleFactor;
1331 1331
1332 1332 f0 = 625;
1333 1333 f1 = 10000;
1334 1334 fs = 160256.410;
1335 1335 Ts = 1. / fs;
1336 1336 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1337 1337
1338 1338 time_management_regs->calDataPtr = 0x00;
1339 1339
1340 1340 // build the signal for the SCM calibration
1341 1341 for (k=0; k<256; k++)
1342 1342 {
1343 1343 val = sin( 2 * pi * f0 * k * Ts )
1344 1344 + sin( 2 * pi * f1 * k * Ts );
1345 1345 data = (unsigned short) ((val * scaleFactor) + 2048);
1346 1346 time_management_regs->calData = data & 0xfff;
1347 1347 }
1348 1348 }
1349 1349
1350 1350 void setCalibrationDataInterleaved( void ){
1351 1351 unsigned int k;
1352 1352 float val;
1353 1353 float f0;
1354 1354 float f1;
1355 1355 float fs;
1356 1356 float Ts;
1357 1357 unsigned short data[384];
1358 1358 unsigned char *dataPtr;
1359 1359
1360 1360 f0 = 625;
1361 1361 f1 = 10000;
1362 1362 fs = 240384.615;
1363 1363 Ts = 1. / fs;
1364 1364
1365 1365 time_management_regs->calDataPtr = 0x00;
1366 1366
1367 1367 // build the signal for the SCM calibration
1368 1368 for (k=0; k<384; k++)
1369 1369 {
1370 1370 val = sin( 2 * pi * f0 * k * Ts )
1371 1371 + sin( 2 * pi * f1 * k * Ts );
1372 1372 data[k] = (unsigned short) (val * 512 + 2048);
1373 1373 }
1374 1374
1375 1375 // write the signal in interleaved mode
1376 1376 for (k=0; k<128; k++)
1377 1377 {
1378 1378 dataPtr = (unsigned char*) &data[k*3 + 2];
1379 1379 time_management_regs->calData = (data[k*3] & 0xfff)
1380 1380 + ( (dataPtr[0] & 0x3f) << 12);
1381 1381 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1382 1382 + ( (dataPtr[1] & 0x3f) << 12);
1383 1383 }
1384 1384 }
1385 1385
1386 1386 void setCalibrationReload( bool state)
1387 1387 {
1388 1388 if (state == true)
1389 1389 {
1390 1390 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1391 1391 }
1392 1392 else
1393 1393 {
1394 1394 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1395 1395 }
1396 1396 }
1397 1397
1398 1398 void setCalibrationEnable( bool state )
1399 1399 {
1400 1400 // this bit drives the multiplexer
1401 1401 if (state == true)
1402 1402 {
1403 1403 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1404 1404 }
1405 1405 else
1406 1406 {
1407 1407 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1408 1408 }
1409 1409 }
1410 1410
1411 1411 void setCalibrationInterleaved( bool state )
1412 1412 {
1413 1413 // this bit drives the multiplexer
1414 1414 if (state == true)
1415 1415 {
1416 1416 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1417 1417 }
1418 1418 else
1419 1419 {
1420 1420 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1421 1421 }
1422 1422 }
1423 1423
1424 1424 void setCalibration( bool state )
1425 1425 {
1426 1426 if (state == true)
1427 1427 {
1428 1428 setCalibrationEnable( true );
1429 1429 setCalibrationReload( false );
1430 1430 set_hk_lfr_calib_enable( true );
1431 1431 }
1432 1432 else
1433 1433 {
1434 1434 setCalibrationEnable( false );
1435 1435 setCalibrationReload( true );
1436 1436 set_hk_lfr_calib_enable( false );
1437 1437 }
1438 1438 }
1439 1439
1440 1440 void configureCalibration( bool interleaved )
1441 1441 {
1442 1442 setCalibration( false );
1443 1443 if ( interleaved == true )
1444 1444 {
1445 1445 setCalibrationInterleaved( true );
1446 1446 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1447 1447 setCalibrationDivisor( 26 ); // => 240 384
1448 1448 setCalibrationDataInterleaved();
1449 1449 }
1450 1450 else
1451 1451 {
1452 1452 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1453 1453 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1454 1454 setCalibrationData();
1455 1455 }
1456 1456 }
1457 1457
1458 1458 //****************
1459 1459 // CLOSING ACTIONS
1460 1460 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1461 1461 {
1462 1462 /** This function is used to update the HK packets statistics after a successful TC execution.
1463 1463 *
1464 1464 * @param TC points to the TC being processed
1465 1465 * @param time is the time used to date the TC execution
1466 1466 *
1467 1467 */
1468 1468
1469 1469 unsigned int val;
1470 1470
1471 1471 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1472 1472 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1473 1473 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1474 1474 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1475 1475 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1476 1476 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1477 1477 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1478 1478 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1479 1479 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1480 1480 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1481 1481 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1482 1482 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1483 1483
1484 1484 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1485 1485 val++;
1486 1486 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1487 1487 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1488 1488 }
1489 1489
1490 1490 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1491 1491 {
1492 1492 /** This function is used to update the HK packets statistics after a TC rejection.
1493 1493 *
1494 1494 * @param TC points to the TC being processed
1495 1495 * @param time is the time used to date the TC rejection
1496 1496 *
1497 1497 */
1498 1498
1499 1499 unsigned int val;
1500 1500
1501 1501 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1502 1502 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1503 1503 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1504 1504 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1505 1505 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1506 1506 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1507 1507 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1508 1508 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1509 1509 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1510 1510 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1511 1511 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1512 1512 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1513 1513
1514 1514 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1515 1515 val++;
1516 1516 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1517 1517 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1518 1518 }
1519 1519
1520 1520 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1521 1521 {
1522 1522 /** This function is the last step of the TC execution workflow.
1523 1523 *
1524 1524 * @param TC points to the TC being processed
1525 1525 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1526 1526 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1527 1527 * @param time is the time used to date the TC execution
1528 1528 *
1529 1529 */
1530 1530
1531 1531 unsigned char requestedMode;
1532 1532
1533 1533 if (result == LFR_SUCCESSFUL)
1534 1534 {
1535 1535 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1536 1536 &
1537 1537 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1538 1538 )
1539 1539 {
1540 1540 send_tm_lfr_tc_exe_success( TC, queue_id );
1541 1541 }
1542 1542 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1543 1543 {
1544 1544 //**********************************
1545 1545 // UPDATE THE LFRMODE LOCAL VARIABLE
1546 1546 requestedMode = TC->dataAndCRC[1];
1547 1547 updateLFRCurrentMode( requestedMode );
1548 1548 }
1549 1549 }
1550 1550 else if (result == LFR_EXE_ERROR)
1551 1551 {
1552 1552 send_tm_lfr_tc_exe_error( TC, queue_id );
1553 1553 }
1554 1554 }
1555 1555
1556 1556 //***************************
1557 1557 // Interrupt Service Routines
1558 1558 rtems_isr commutation_isr1( rtems_vector_number vector )
1559 1559 {
1560 1560 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1561 1561 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1562 1562 }
1563 1563 }
1564 1564
1565 1565 rtems_isr commutation_isr2( rtems_vector_number vector )
1566 1566 {
1567 1567 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1568 1568 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1569 1569 }
1570 1570 }
1571 1571
1572 1572 //****************
1573 1573 // OTHER FUNCTIONS
1574 1574 void updateLFRCurrentMode( unsigned char requestedMode )
1575 1575 {
1576 1576 /** This function updates the value of the global variable lfrCurrentMode.
1577 1577 *
1578 1578 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1579 1579 *
1580 1580 */
1581 1581
1582 1582 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1583 1583 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1584 1584 lfrCurrentMode = requestedMode;
1585 1585 }
1586 1586
1587 1587 void set_lfr_soft_reset( unsigned char value )
1588 1588 {
1589 1589 if (value == 1)
1590 1590 {
1591 1591 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1592 1592 }
1593 1593 else
1594 1594 {
1595 1595 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1596 1596 }
1597 1597 }
1598 1598
1599 1599 void reset_lfr( void )
1600 1600 {
1601 1601 set_lfr_soft_reset( 1 );
1602 1602
1603 1603 set_lfr_soft_reset( 0 );
1604 1604
1605 1605 set_hk_lfr_sc_potential_flag( true );
1606 1606 }
General Comments 0
You need to be logged in to leave comments. Login now