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