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