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