##// END OF EJS Templates
Many corrections done after Logiscope analysis
paul -
r166:b9d810e81e1d patch rev 2
parent child
Show More
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue Jul 15 15:57:23 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Sep 24 11:10:53 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,7 +10,7
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=0 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
@@ -11,7 +11,7 SWVERSION=-1-0
11 DEFINES += SW_VERSION_N1=2 # major
11 DEFINES += SW_VERSION_N1=2 # major
12 DEFINES += SW_VERSION_N2=0 # minor
12 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N3=1 # patch
13 DEFINES += SW_VERSION_N3=1 # patch
14 DEFINES += SW_VERSION_N4=0 # internal
14 DEFINES += SW_VERSION_N4=1 # internal
15
15
16 contains( CONFIG, debug_tch ) {
16 contains( CONFIG, debug_tch ) {
17 DEFINES += DEBUG_TCH
17 DEFINES += DEBUG_TCH
@@ -1,8 +1,12
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-07-15T16:01:49. -->
3 <!-- Written by QtCreator 3.2.0, 2014-09-23T16:34:13. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>EnvironmentId</variable>
7 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
8 </data>
9 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
10 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">0</value>
11 <value type="int">0</value>
8 </data>
12 </data>
@@ -29,9 +33,12
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
33 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
34 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
35 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36 <value type="int" key="EditorConfiguration.MarginColumn">80</value>
37 <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
38 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
39 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
40 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41 <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
42 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
43 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
44 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
@@ -191,11 +198,11
191 <value type="int">1</value>
198 <value type="int">1</value>
192 </data>
199 </data>
193 <data>
200 <data>
194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
201 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
202 <value type="int">16</value>
196 </data>
203 </data>
197 <data>
204 <data>
198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
205 <variable>Version</variable>
199 <value type="int">15</value>
206 <value type="int">16</value>
200 </data>
207 </data>
201 </qtcreator>
208 </qtcreator>
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/timegen
2 # Makefile for building: bin/timegen
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Mar 21 09:10:01 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Sep 24 10:50:53 2014
4 # Project: timegen.pro
4 # Project: timegen.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile timegen.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile timegen.pro
@@ -6,7 +6,6
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
10 #include "wf_handler.h"
9 #include "wf_handler.h"
11
10
12 #include "timegen_spacewire.h"
11 #include "timegen_spacewire.h"
@@ -14,6 +13,7
14
13
15 extern rtems_name Task_name[20]; /* array of task names */
14 extern rtems_name Task_name[20]; /* array of task names */
16 extern rtems_id Task_id[20]; /* array of task ids */
15 extern rtems_id Task_id[20]; /* array of task ids */
16 extern rtems_name misc_name[5];
17
17
18 // RTEMS TASKS
18 // RTEMS TASKS
19 rtems_task Init( rtems_task_argument argument);
19 rtems_task Init( rtems_task_argument argument);
@@ -32,8 +32,6 int start_recv_send_tasks( void );
32 void init_local_mode_parameters( void );
32 void init_local_mode_parameters( void );
33 void reset_local_time( void );
33 void reset_local_time( void );
34
34
35 extern int rtems_cpu_usage_report( void );
36 extern int rtems_cpu_usage_reset( void );
37 extern void rtems_stack_checker_report_usage( void );
35 extern void rtems_stack_checker_report_usage( void );
38
36
39 extern int sched_yield( void );
37 extern int sched_yield( void );
@@ -24,6 +24,8 unsigned int coarseTime;
24
24
25 rtems_name rtems_name_updt;
25 rtems_name rtems_name_updt;
26 rtems_id rtems_id_updt;
26 rtems_id rtems_id_updt;
27 rtems_name rtems_name_act_;
28 rtems_id rtems_id_act_;
27
29
28 void timegen_timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
30 void timegen_timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
29
31
@@ -18,34 +18,12 rtems_isr commutation_isr2( rtems_vector
18
18
19 //***********
19 //***********
20 // RTEMS TASK
20 // RTEMS TASK
21 rtems_task actn_task( rtems_task_argument unused );
21 rtems_task act__task( rtems_task_argument unused );
22
22
23 //***********
23 //***********
24 // TC ACTIONS
24 // TC ACTIONS
25 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
25 int timegen_action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
26 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
26 int timegen_action_update_time(ccsdsTelecommandPacket_t *TC);
27 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
28 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
29 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
30 int action_update_time(ccsdsTelecommandPacket_t *TC);
31
32 // mode transition
33 int transition_validation(unsigned char requestedMode);
34 int stop_current_mode( void );
35 int enter_mode(unsigned char mode);
36 int restart_science_tasks();
37 int suspend_science_tasks();
38 void launch_waveform_picker( unsigned char mode );
39 void launch_spectral_matrix( unsigned char mode );
40 void set_irq_on_new_ready_matrix(unsigned char value );
41 void set_run_matrix_spectral( unsigned char value );
42 void launch_spectral_matrix_simu( unsigned char mode );
43
44 // other functions
45 void updateLFRCurrentMode();
46 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC );
47 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC );
48 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
49
27
50 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
28 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
51 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
29 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
@@ -155,13 +155,6 rtems_task Init( rtems_task_argument ign
155 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
155 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
156 }
156 }
157
157
158 // suspend science tasks. they will be restarted later depending on the mode
159 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
160 if (status != RTEMS_SUCCESSFUL)
161 {
162 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
163 }
164
165 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
158 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
166 if ( status_spw != RTEMS_SUCCESSFUL )
159 if ( status_spw != RTEMS_SUCCESSFUL )
167 {
160 {
@@ -177,31 +170,6 rtems_task Init( rtems_task_argument ign
177
170
178 }
171 }
179
172
180 void init_local_mode_parameters( void )
181 {
182 /** This function initialize the param_local global variable with default values.
183 *
184 */
185
186 unsigned int i;
187
188 // LOCAL PARAMETERS
189 // set_local_nb_interrupt_f0_MAX();
190
191 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
192 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
193 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
194
195 // init sequence counters
196
197 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
198 {
199 sequenceCounters_TC_EXE[i] = 0x00;
200 }
201 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
202 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
203 }
204
205 void create_names( void ) // create all names for tasks and queues
173 void create_names( void ) // create all names for tasks and queues
206 {
174 {
207 /** This function creates all RTEMS names used in the software for tasks and queues.
175 /** This function creates all RTEMS names used in the software for tasks and queues.
@@ -213,27 +181,15 void create_names( void ) // create all
213
181
214 // task names
182 // task names
215 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
183 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
216 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
217 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
184 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
218 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
219 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
185 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
220 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
221 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
222 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
223 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
186 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
224 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
225 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
226 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
227 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
228 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
229 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
187 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
230 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
188 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
231
189
232 // TIMEGEN
190 // TIMEGEN
233 rtems_name_updt = rtems_build_name( 'U', 'P', 'D', 'T' );
191 rtems_name_updt = rtems_build_name( 'U', 'P', 'D', 'T' );
234
192 rtems_name_act_ = rtems_build_name( 'A', 'C', 'T', '_' );
235 // rate monotonic period names
236 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
237
193
238 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
194 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
239 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
195 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
@@ -281,12 +237,12 int create_all_tasks( void ) // create a
281 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
237 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
282 );
238 );
283 }
239 }
284 if (status == RTEMS_SUCCESSFUL) // ACTN
240 if (status == RTEMS_SUCCESSFUL) // ACT_
285 {
241 {
286 status = rtems_task_create(
242 status = rtems_task_create(
287 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
243 rtems_id_act_, TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
288 RTEMS_DEFAULT_MODES,
244 RTEMS_DEFAULT_MODES,
289 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
245 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &rtems_id_act_
290 );
246 );
291 }
247 }
292 if (status == RTEMS_SUCCESSFUL) // SPIQ
248 if (status == RTEMS_SUCCESSFUL) // SPIQ
@@ -379,11 +335,11 int start_all_tasks( void ) // start all
379 }
335 }
380 }
336 }
381
337
382 if (status == RTEMS_SUCCESSFUL) // ACTN
338 if (status == RTEMS_SUCCESSFUL) // ACT_
383 {
339 {
384 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
340 status = rtems_task_start( rtems_id_act_, act__task, 1 );
385 if (status!=RTEMS_SUCCESSFUL) {
341 if (status!=RTEMS_SUCCESSFUL) {
386 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
342 BOOT_PRINTF("in INIT *** Error starting TASK_ACT_\n")
387 }
343 }
388 }
344 }
389
345
@@ -425,7 +381,7 rtems_status_code create_message_queues(
425
381
426 // create the queue for handling valid TCs
382 // create the queue for handling valid TCs
427 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
383 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
428 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
384 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
429 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
385 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
430 if ( status_recv != RTEMS_SUCCESSFUL ) {
386 if ( status_recv != RTEMS_SUCCESSFUL ) {
431 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
387 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
@@ -433,7 +389,7 rtems_status_code create_message_queues(
433
389
434 // create the queue for handling TM packet sending
390 // create the queue for handling TM packet sending
435 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
391 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
436 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
392 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
437 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
393 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
438 if ( status_send != RTEMS_SUCCESSFUL ) {
394 if ( status_send != RTEMS_SUCCESSFUL ) {
439 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
395 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
@@ -83,14 +83,6 rtems_task spiq_task(rtems_task_argument
83 }
83 }
84 else // [3.b] the link is not in run state, go in STANDBY mode
84 else // [3.b] the link is not in run state, go in STANDBY mode
85 {
85 {
86 status = stop_current_mode();
87 if ( status != RTEMS_SUCCESSFUL ) {
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 }
90 status = enter_mode( LFR_MODE_STANDBY );
91 if ( status != RTEMS_SUCCESSFUL ) {
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 }
94 // wake the WTDG task up to wait for the link recovery
86 // wake the WTDG task up to wait for the link recovery
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
87 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 status = rtems_task_suspend( RTEMS_SELF );
88 status = rtems_task_suspend( RTEMS_SELF );
@@ -98,476 +90,6 rtems_task spiq_task(rtems_task_argument
98 }
90 }
99 }
91 }
100
92
101 rtems_task recv_task( rtems_task_argument unused )
102 {
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 *
105 * @param unused is the starting argument of the RTEMS task
106 *
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
108 * 1. It reads the incoming data.
109 * 2. Launches the acceptance procedure.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 *
112 */
113
114 int len;
115 ccsdsTelecommandPacket_t currentTC;
116 unsigned char computed_CRC[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
118 unsigned char destinationID;
119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
120 unsigned int parserCode;
121 unsigned char time[6];
122 rtems_status_code status;
123 rtems_id queue_recv_id;
124 rtems_id queue_send_id;
125
126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
127
128 status = get_message_queue_id_recv( &queue_recv_id );
129 if (status != RTEMS_SUCCESSFUL)
130 {
131 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
132 }
133
134 status = get_message_queue_id_send( &queue_send_id );
135 if (status != RTEMS_SUCCESSFUL)
136 {
137 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
138 }
139
140 BOOT_PRINTF("in RECV *** \n")
141
142 while(1)
143 {
144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
145 if (len == -1){ // error during the read call
146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
147 }
148 else {
149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
150 PRINTF("in RECV *** packet lenght too short\n")
151 }
152 else {
153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
156 // CHECK THE TC
157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
161 || (parserCode == WRONG_SRC_ID) )
162 { // send TM_LFR_TC_EXE_CORRUPTED
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
167 {
168 if ( parserCode == WRONG_SRC_ID )
169 {
170 destinationID = SID_TC_GROUND;
171 }
172 else
173 {
174 destinationID = currentTC.sourceID;
175 }
176 getTime( time );
177 close_action( &currentTC, LFR_DEFAULT, queue_send_id );
178 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
179 computed_CRC, currentTC_LEN_RCV,
180 destinationID );
181 }
182 }
183 else
184 { // send valid TC to the action launcher
185 status = rtems_message_queue_send( queue_recv_id, &currentTC,
186 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
187 }
188 }
189 }
190 }
191 }
192
193 rtems_task send_task( rtems_task_argument argument)
194 {
195 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
196 *
197 * @param unused is the starting argument of the RTEMS task
198 *
199 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
200 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
201 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
202 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
203 * data it contains.
204 *
205 */
206
207 rtems_status_code status; // RTEMS status code
208 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
209 size_t size; // size of the incoming TC packet
210 u_int32_t count;
211 rtems_id queue_id;
212
213 status = get_message_queue_id_send( &queue_id );
214 if (status != RTEMS_SUCCESSFUL)
215 {
216 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
217 }
218
219 BOOT_PRINTF("in SEND *** \n")
220
221 while(1)
222 {
223 status = rtems_message_queue_receive( queue_id, incomingData, &size,
224 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
225
226 if (status!=RTEMS_SUCCESSFUL)
227 {
228 PRINTF1("in SEND *** (1) ERR = %d\n", status)
229 }
230 else
231 {
232 status = write( fdSPW, incomingData, size );
233 if (status == -1){
234 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
235 }
236 }
237
238 status = rtems_message_queue_get_number_pending( queue_id, &count );
239 if (status != RTEMS_SUCCESSFUL)
240 {
241 PRINTF1("in SEND *** (3) ERR = %d\n", status)
242 }
243 else
244 {
245 if (count > maxCount)
246 {
247 maxCount = count;
248 }
249 }
250 }
251 }
252
253 rtems_task wtdg_task( rtems_task_argument argument )
254 {
255 rtems_event_set event_out;
256 rtems_status_code status;
257 int linkStatus;
258
259 BOOT_PRINTF("in WTDG ***\n")
260
261 while(1)
262 {
263 // wait for an RTEMS_EVENT
264 rtems_event_receive( RTEMS_EVENT_0,
265 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
266 PRINTF("in WTDG *** wait for the link\n")
267 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
268 while( linkStatus != 5) // wait for the link
269 {
270 rtems_task_wake_after( 10 );
271 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
272 }
273
274 status = spacewire_stop_start_link( fdSPW );
275
276 if (status != RTEMS_SUCCESSFUL)
277 {
278 PRINTF1("in WTDG *** ERR link not started %d\n", status)
279 }
280 else
281 {
282 PRINTF("in WTDG *** OK link started\n")
283 }
284
285 // restart the SPIQ task
286 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
287 if ( status != RTEMS_SUCCESSFUL ) {
288 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
289 }
290
291 // restart RECV and SEND
292 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
293 if ( status != RTEMS_SUCCESSFUL ) {
294 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
295 }
296 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
297 if ( status != RTEMS_SUCCESSFUL ) {
298 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
299 }
300 }
301 }
302
303 //****************
304 // OTHER FUNCTIONS
305 int spacewire_open_link( void )
306 {
307 /** This function opens the SpaceWire link.
308 *
309 * @return a valid file descriptor in case of success, -1 in case of a failure
310 *
311 */
312 rtems_status_code status;
313
314 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
315 if ( fdSPW < 0 ) {
316 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
317 }
318 else
319 {
320 status = RTEMS_SUCCESSFUL;
321 }
322
323 return status;
324 }
325
326 int spacewire_start_link( int fd )
327 {
328 rtems_status_code status;
329
330 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
331 // -1 default hardcoded driver timeout
332
333 return status;
334 }
335
336 int spacewire_stop_start_link( int fd )
337 {
338 rtems_status_code status;
339
340 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
341 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
342 // -1 default hardcoded driver timeout
343
344 return status;
345 }
346
347 int spacewire_configure_link( int fd )
348 {
349 /** This function configures the SpaceWire link.
350 *
351 * @return GR-RTEMS-DRIVER directive status codes:
352 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
353 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
354 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
355 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
356 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
357 * - 5 EIO - Error when writing to grswp hardware registers.
358 * - 2 ENOENT - No such file or directory
359 */
360
361 rtems_status_code status;
362
363 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
364 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
365
366 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
367 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
368 //
369 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
370 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
371 //
372 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
373 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
374 //
375 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
376 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
377 //
378 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
379 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
380 //
381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
382 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
383 //
384 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
385 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL\n")
386
387 return status;
388 }
389
390 int spacewire_reset_link( void )
391 {
392 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
393 *
394 * @return RTEMS directive status code:
395 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
396 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
397 *
398 */
399
400 rtems_status_code status_spw;
401 int i;
402
403 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
404 {
405 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
406
407 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
408
409 status_spw = spacewire_stop_start_link( fdSPW );
410 if ( status_spw != RTEMS_SUCCESSFUL )
411 {
412 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
413 }
414
415 if ( status_spw == RTEMS_SUCCESSFUL)
416 {
417 break;
418 }
419 }
420
421 return status_spw;
422 }
423
424 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
425 {
426 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
427 *
428 * @param val is the value, 0 or 1, used to set the value of the NP bit.
429 * @param regAddr is the address of the GRSPW control register.
430 *
431 * NP is the bit 20 of the GRSPW control register.
432 *
433 */
434
435 unsigned int *spwptr = (unsigned int*) regAddr;
436
437 if (val == 1) {
438 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
439 }
440 if (val== 0) {
441 *spwptr = *spwptr & 0xffdfffff;
442 }
443 }
444
445 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
446 {
447 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
448 *
449 * @param val is the value, 0 or 1, used to set the value of the RE bit.
450 * @param regAddr is the address of the GRSPW control register.
451 *
452 * RE is the bit 16 of the GRSPW control register.
453 *
454 */
455
456 unsigned int *spwptr = (unsigned int*) regAddr;
457
458 if (val == 1)
459 {
460 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
461 }
462 if (val== 0)
463 {
464 *spwptr = *spwptr & 0xfffdffff;
465 }
466 }
467
468 void spacewire_compute_stats_offsets( void )
469 {
470 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
471 *
472 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
473 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
474 * during the open systel call).
475 *
476 */
477
478 spw_stats spacewire_stats_grspw;
479 rtems_status_code status;
480
481 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
482
483 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
484 + spacewire_stats.packets_received;
485 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
486 + spacewire_stats.packets_sent;
487 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
488 + spacewire_stats.parity_err;
489 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
490 + spacewire_stats.disconnect_err;
491 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
492 + spacewire_stats.escape_err;
493 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
494 + spacewire_stats.credit_err;
495 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
496 + spacewire_stats.write_sync_err;
497 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
498 + spacewire_stats.rx_rmap_header_crc_err;
499 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
500 + spacewire_stats.rx_rmap_data_crc_err;
501 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
502 + spacewire_stats.early_ep;
503 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
504 + spacewire_stats.invalid_address;
505 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
506 + spacewire_stats.rx_eep_err;
507 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
508 + spacewire_stats.rx_truncated;
509 }
510
511 void spacewire_update_statistics( void )
512 {
513 rtems_status_code status;
514 spw_stats spacewire_stats_grspw;
515
516 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
517
518 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
519 + spacewire_stats_grspw.packets_received;
520 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
521 + spacewire_stats_grspw.packets_sent;
522 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
523 + spacewire_stats_grspw.parity_err;
524 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
525 + spacewire_stats_grspw.disconnect_err;
526 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
527 + spacewire_stats_grspw.escape_err;
528 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
529 + spacewire_stats_grspw.credit_err;
530 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
531 + spacewire_stats_grspw.write_sync_err;
532 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
533 + spacewire_stats_grspw.rx_rmap_header_crc_err;
534 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
535 + spacewire_stats_grspw.rx_rmap_data_crc_err;
536 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
537 + spacewire_stats_grspw.early_ep;
538 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
539 + spacewire_stats_grspw.invalid_address;
540 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
541 + spacewire_stats_grspw.rx_eep_err;
542 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
543 + spacewire_stats_grspw.rx_truncated;
544 //spacewire_stats.tx_link_err;
545
546 //****************************
547 // DPU_SPACEWIRE_IF_STATISTICS
548 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
549 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
550 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
551 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
552 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
553 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
554
555 //******************************************
556 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
557 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
558 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
559 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
560 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
561 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
562
563 //*********************************************
564 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
565 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
566 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
567 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
568 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
569 }
570
571 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
93 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
572 {
94 {
573 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 );
95 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 );
This diff has been collapsed as it changes many lines, (710 lines changed) Show them Hide them
@@ -15,7 +15,7
15 //***********
15 //***********
16 // RTEMS TASK
16 // RTEMS TASK
17
17
18 rtems_task actn_task( rtems_task_argument unused )
18 rtems_task act__task( rtems_task_argument unused )
19 {
19 {
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 *
21 *
@@ -66,63 +66,12 rtems_task actn_task( rtems_task_argumen
66 subtype = TC.serviceSubType;
66 subtype = TC.serviceSubType;
67 switch(subtype)
67 switch(subtype)
68 {
68 {
69 case TC_SUBTYPE_RESET:
69 case TC_SUBTYPE_ENTER:
70 // result = action_reset( &TC, queue_snd_id, time );
70 result = timegen_action_enter_mode( &TC, queue_snd_id, time );
71 close_action( &TC, result, queue_snd_id );
72 break;
73 //
74 case TC_SUBTYPE_LOAD_COMM:
75 // result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
77 break;
78 //
79 case TC_SUBTYPE_LOAD_NORM:
80 // result = action_load_normal_par( &TC, queue_snd_id, time );
81 close_action( &TC, result, queue_snd_id );
82 break;
83 //
84 case TC_SUBTYPE_LOAD_BURST:
85 // result = action_load_burst_par( &TC, queue_snd_id, time );
86 close_action( &TC, result, queue_snd_id );
87 break;
88 //
89 case TC_SUBTYPE_LOAD_SBM1:
90 // result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 close_action( &TC, result, queue_snd_id );
92 break;
93 //
94 case TC_SUBTYPE_LOAD_SBM2:
95 // result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 close_action( &TC, result, queue_snd_id );
71 close_action( &TC, result, queue_snd_id );
97 break;
72 break;
98 //
99 case TC_SUBTYPE_DUMP:
100 // result = action_dump_par( queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
103 //
104 case TC_SUBTYPE_ENTER:
105 result = action_enter_mode( &TC, queue_snd_id, time );
106 close_action( &TC, result, queue_snd_id );
107 break;
108 //
109 case TC_SUBTYPE_UPDT_INFO:
110 // result = action_update_info( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
113 //
114 case TC_SUBTYPE_EN_CAL:
115 // result = action_enable_calibration( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
117 break;
118 //
119 case TC_SUBTYPE_DIS_CAL:
120 // result = action_disable_calibration( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
122 break;
123 //
124 case TC_SUBTYPE_UPDT_TIME:
73 case TC_SUBTYPE_UPDT_TIME:
125 result = action_update_time( &TC );
74 result = timegen_action_update_time( &TC );
126 close_action( &TC, result, queue_snd_id );
75 close_action( &TC, result, queue_snd_id );
127 break;
76 break;
128 //
77 //
@@ -136,658 +85,23 rtems_task actn_task( rtems_task_argumen
136 //***********
85 //***********
137 // TC ACTIONS
86 // TC ACTIONS
138
87
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
88 int timegen_action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
89 {
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
90 int ret;
142 *
143 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 *
146 */
147
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 return LFR_DEFAULT;
150 }
151
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
153 {
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 *
156 * @param TC points to the TeleCommand packet that is being processed
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 *
159 */
160
161 rtems_status_code status;
162 unsigned char requestedMode;
163
164 requestedMode = TC->dataAndCRC[1];
165
91
166 if ( (requestedMode != LFR_MODE_STANDBY)
92 ret = LFR_SUCCESSFUL;
167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
169 {
170 status = RTEMS_UNSATISFIED;
171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
172 }
173 else
174 {
175 printf("in action_enter_mode *** enter mode %d\n", requestedMode);
176
177 status = transition_validation(requestedMode);
178
93
179 if ( status == LFR_SUCCESSFUL ) {
94 return ret;
180 if ( lfrCurrentMode != LFR_MODE_STANDBY)
181 {
182 status = stop_current_mode();
183 }
184 if (status != RTEMS_SUCCESSFUL)
185 {
186 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
187 }
188 status = enter_mode( requestedMode );
189 }
190 else
191 {
192 PRINTF("ERR *** in action_enter *** transition rejected\n")
193 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
194 }
195 }
196
197 return status;
198 }
95 }
199
96
200 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
97 int timegen_action_update_time(ccsdsTelecommandPacket_t *TC)
201 {
98 {
202 // /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
99 int ret;
203 // *
204 // * @param TC points to the TeleCommand packet that is being processed
205 // * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
206 // *
207 // * @return LFR directive status code:
208 // * - LFR_DEFAULT
209 // * - LFR_SUCCESSFUL
210 // *
211 // */
212
213 // unsigned int val;
214 int result;
215
216 result = LFR_DEFAULT;
217 // unsigned int status;
218 // unsigned char mode;
219
220 // // check LFR MODE
221 // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1;
222 // status = check_update_info_hk_lfr_mode( mode );
223 // if (status != LFR_DEFAULT) // check TDS mode
224 // {
225 // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4;
226 // status = check_update_info_hk_tds_mode( mode );
227 // }
228 // if (status != LFR_DEFAULT) // check THR mode
229 // {
230 // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f);
231 // status = check_update_info_hk_thr_mode( mode );
232 // }
233 // if (status != LFR_DEFAULT) // if the parameter check is successful
234 // {
235 // val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
236 // + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
237 // val++;
238 // housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
239 // housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
240 // }
241
242 // result = status;
243
244 return result;
245 }
246
247 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
248 {
249 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
250 *
251 * @param TC points to the TeleCommand packet that is being processed
252 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
253 *
254 */
255
100
256 int result;
101 ret = LFR_SUCCESSFUL;
257 unsigned char lfrMode;
258
259 result = LFR_DEFAULT;
260 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
261
262 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
263 result = LFR_DEFAULT;
264
265 return result;
266 }
267
268 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
269 {
270 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
271 *
272 * @param TC points to the TeleCommand packet that is being processed
273 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
274 *
275 */
276
277 int result;
278 unsigned char lfrMode;
279
280 result = LFR_DEFAULT;
281 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
282
102
283 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
103 return ret;
284 result = LFR_DEFAULT;
285
286 return result;
287 }
288
289 int action_update_time(ccsdsTelecommandPacket_t *TC)
290 {
291 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
292 *
293 * @param TC points to the TeleCommand packet that is being processed
294 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
295 *
296 * @return LFR_SUCCESSFUL
297 *
298 */
299
300 unsigned int val;
301
302 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
303 + (TC->dataAndCRC[1] << 16)
304 + (TC->dataAndCRC[2] << 8)
305 + TC->dataAndCRC[3];
306 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
307 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
308 val++;
309 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
310 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
311 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
312
313 return LFR_SUCCESSFUL;
314 }
104 }
315
105
316 //*******************
106 //*******************
317 // ENTERING THE MODES
107 // ENTERING THE MODES
318
319 int transition_validation(unsigned char requestedMode)
320 {
321 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
322 *
323 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
324 *
325 * @return LFR directive status codes:
326 * - LFR_SUCCESSFUL - the transition is authorized
327 * - LFR_DEFAULT - the transition is not authorized
328 *
329 */
330
331 int status;
332
333 switch (requestedMode)
334 {
335 case LFR_MODE_STANDBY:
336 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
337 status = LFR_DEFAULT;
338 }
339 else
340 {
341 status = LFR_SUCCESSFUL;
342 }
343 break;
344 case LFR_MODE_NORMAL:
345 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
346 status = LFR_DEFAULT;
347 }
348 else {
349 status = LFR_SUCCESSFUL;
350 }
351 break;
352 case LFR_MODE_BURST:
353 if ( lfrCurrentMode == LFR_MODE_BURST ) {
354 status = LFR_DEFAULT;
355 }
356 else {
357 status = LFR_SUCCESSFUL;
358 }
359 break;
360 case LFR_MODE_SBM1:
361 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
362 status = LFR_DEFAULT;
363 }
364 else {
365 status = LFR_SUCCESSFUL;
366 }
367 break;
368 case LFR_MODE_SBM2:
369 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
370 status = LFR_DEFAULT;
371 }
372 else {
373 status = LFR_SUCCESSFUL;
374 }
375 break;
376 default:
377 status = LFR_DEFAULT;
378 break;
379 }
380
381 return status;
382 }
383
384 int stop_current_mode(void)
385 {
386 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
387 *
388 * @return RTEMS directive status codes:
389 * - RTEMS_SUCCESSFUL - task restarted successfully
390 * - RTEMS_INVALID_ID - task id invalid
391 * - RTEMS_ALREADY_SUSPENDED - task already suspended
392 *
393 */
394
395 rtems_status_code status;
396
397 status = RTEMS_SUCCESSFUL;
398
399 // (1) mask interruptions
400 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
401 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
402
403 // (2) clear interruptions
404 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
405 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
406
407 // (3) reset registers
408 // waveform picker
409 // reset_wfp_burst_enable(); // reset burst and enable bits
410 // reset_wfp_status(); // reset all the status bits
411 // spectral matrices
412 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
413 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
414 // reset_extractSWF(); // reset the extractSWF flag to false
415
416 // <Spectral Matrices simulator>
417 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
418 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
419 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
420 // </Spectral Matrices simulator>
421
422 // suspend several tasks
423 if (lfrCurrentMode != LFR_MODE_STANDBY) {
424 status = suspend_science_tasks();
425 }
426
427 if (status != RTEMS_SUCCESSFUL)
428 {
429 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
430 }
431
432 return status;
433 }
434
435 int enter_mode(unsigned char mode )
436 {
437 /** This function is launched after a mode transition validation.
438 *
439 * @param mode is the mode in which LFR will be put.
440 *
441 * @return RTEMS directive status codes:
442 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
443 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
444 *
445 */
446
447 rtems_status_code status;
448
449 status = RTEMS_UNSATISFIED;
450
451 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
452 updateLFRCurrentMode();
453
454 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
455 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
456 {
457 #ifdef PRINT_TASK_STATISTICS
458 rtems_cpu_usage_reset();
459 maxCount = 0;
460 #endif
461 status = restart_science_tasks();
462 // launch_waveform_picker( mode );
463 // launch_spectral_matrix( mode );
464 }
465 else if ( mode == LFR_MODE_STANDBY )
466 {
467 #ifdef PRINT_TASK_STATISTICS
468 rtems_cpu_usage_report();
469 #endif
470
471 #ifdef PRINT_STACK_REPORT
472 rtems_stack_checker_report_usage();
473 #endif
474 status = stop_current_mode();
475 PRINTF1("maxCount = %d\n", maxCount)
476 }
477 else
478 {
479 status = RTEMS_UNSATISFIED;
480 }
481
482 if (status != RTEMS_SUCCESSFUL)
483 {
484 PRINTF1("in enter_mode *** ERR = %d\n", status)
485 status = RTEMS_UNSATISFIED;
486 }
487
488 return status;
489 }
490
491 int restart_science_tasks()
492 {
493 /** This function is used to restart all science tasks.
494 *
495 * @return RTEMS directive status codes:
496 * - RTEMS_SUCCESSFUL - task restarted successfully
497 * - RTEMS_INVALID_ID - task id invalid
498 * - RTEMS_INCORRECT_STATE - task never started
499 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
500 *
501 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
502 *
503 */
504
505 rtems_status_code status[6];
506 rtems_status_code ret;
507
508 ret = RTEMS_SUCCESSFUL;
509
510 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
511 if (status[0] != RTEMS_SUCCESSFUL)
512 {
513 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
514 }
515
516 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
517 if (status[2] != RTEMS_SUCCESSFUL)
518 {
519 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
520 }
521
522 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
523 if (status[3] != RTEMS_SUCCESSFUL)
524 {
525 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
526 }
527
528 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
529 if (status[4] != RTEMS_SUCCESSFUL)
530 {
531 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
532 }
533
534 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
535 if (status[5] != RTEMS_SUCCESSFUL)
536 {
537 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
538 }
539
540 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
541 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
542 {
543 ret = RTEMS_UNSATISFIED;
544 }
545
546 return ret;
547 }
548
549 int suspend_science_tasks()
550 {
551 /** This function suspends the science tasks.
552 *
553 * @return RTEMS directive status codes:
554 * - RTEMS_SUCCESSFUL - task restarted successfully
555 * - RTEMS_INVALID_ID - task id invalid
556 * - RTEMS_ALREADY_SUSPENDED - task already suspended
557 *
558 */
559
560 rtems_status_code status;
561
562 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
563 if (status != RTEMS_SUCCESSFUL)
564 {
565 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
566 }
567
568 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
569 {
570 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
571 if (status != RTEMS_SUCCESSFUL)
572 {
573 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
574 }
575 }
576
577 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
578 {
579 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
580 if (status != RTEMS_SUCCESSFUL)
581 {
582 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
583 }
584 }
585
586 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
587 {
588 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
589 if (status != RTEMS_SUCCESSFUL)
590 {
591 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
592 }
593 }
594
595 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
596 {
597 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
598 if (status != RTEMS_SUCCESSFUL)
599 {
600 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
601 }
602 }
603
604 return status;
605 }
606
607 void launch_waveform_picker( unsigned char mode )
608 {
609 // int startDate;
610
611 // reset_current_ring_nodes();
612 // reset_waveform_picker_regs();
613 // set_wfp_burst_enable_register( mode );
614
615 // LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
616 // LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
617
618 // startDate = time_management_regs->coarse_time + 2;
619 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
620 // waveform_picker_regs->start_date = startDate;
621 }
622
623 void launch_spectral_matrix( unsigned char mode )
624 {
625 // reset_nb_sm_f0();
626 // reset_current_sm_ring_nodes();
627 // reset_spectral_matrix_regs();
628
629 //#ifdef VHDL_DEV
630 // set_irq_on_new_ready_matrix( 1 );
631 // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
632 // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
633 // set_run_matrix_spectral( 1 );
634 //#else
635 // // Spectral Matrices simulator
636 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
637 // LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
638 // LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
639 //#endif
640 }
641
642 void set_irq_on_new_ready_matrix( unsigned char value )
643 {
644 if (value == 1)
645 {
646 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
647 }
648 else
649 {
650 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
651 }
652 }
653
654 void set_run_matrix_spectral( unsigned char value )
655 {
656 if (value == 1)
657 {
658 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // 0100 set run_matrix spectral to 1
659 }
660 else
661 {
662 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // 1011 set run_matrix spectral to 0
663 }
664 }
665
666 void launch_spectral_matrix_simu( unsigned char mode )
667 {
668 // reset_nb_sm_f0();
669 // reset_current_sm_ring_nodes();
670 // reset_spectral_matrix_regs();
671
672 // // Spectral Matrices simulator
673 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
674 // LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
675 // LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
676 // set_local_nb_interrupt_f0_MAX();
677 }
678
679 //****************
680 // CLOSING ACTIONS
681 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
682 {
683 /** This function is used to update the HK packets statistics after a successful TC execution.
684 *
685 * @param TC points to the TC being processed
686 * @param time is the time used to date the TC execution
687 *
688 */
689
690 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
691 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
692 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
693 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
694 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
695 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
696 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
697 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
698 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
699 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
700 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
701 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
702 }
703
704 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC )
705 {
706 /** This function is used to update the HK packets statistics after a TC rejection.
707 *
708 * @param TC points to the TC being processed
709 * @param time is the time used to date the TC rejection
710 *
711 */
712
713 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
714 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
715 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
716 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
717 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
718 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
719 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
720 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
721 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
722 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
723 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
724 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
725 }
726
727 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
728 {
729 /** This function is the last step of the TC execution workflow.
730 *
731 * @param TC points to the TC being processed
732 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
733 * @param queue_id is the id of the RTEMS message queue used to send TM packets
734 * @param time is the time used to date the TC execution
735 *
736 */
737
738 unsigned int val = 0;
739
740 if (result == LFR_SUCCESSFUL)
741 {
742 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
743 &&
744 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
745 )
746 {
747 send_tm_lfr_tc_exe_success( TC, queue_id );
748 }
749 update_last_TC_exe( TC );
750 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
751 val++;
752 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
753 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
754 }
755 else
756 {
757 update_last_TC_rej( TC );
758 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
759 val++;
760 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
761 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
762 }
763 }
764
765 //***************************
766 // Interrupt Service Routines
767 rtems_isr commutation_isr1( rtems_vector_number vector )
768 {
769 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
770 printf("In commutation_isr1 *** Error sending event to DUMB\n");
771 }
772 }
773
774 rtems_isr commutation_isr2( rtems_vector_number vector )
775 {
776 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
777 printf("In commutation_isr2 *** Error sending event to DUMB\n");
778 }
779 }
780
781 //****************
782 // OTHER FUNCTIONS
783 void updateLFRCurrentMode()
784 {
785 /** This function updates the value of the global variable lfrCurrentMode.
786 *
787 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
788 *
789 */
790 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
791 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
792 }
793
@@ -1,8 +1,12
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-03-24T15:57:06. -->
3 <!-- Written by QtCreator 3.2.0, 2014-09-24T11:08:34. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>EnvironmentId</variable>
7 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
8 </data>
9 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
10 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">0</value>
11 <value type="int">0</value>
8 </data>
12 </data>
@@ -29,9 +33,12
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
33 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
34 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
35 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36 <value type="int" key="EditorConfiguration.MarginColumn">80</value>
37 <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
38 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
39 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
40 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41 <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
42 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
43 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
44 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
@@ -388,11 +395,11
388 <value type="int">2</value>
395 <value type="int">2</value>
389 </data>
396 </data>
390 <data>
397 <data>
391 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
398 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
392 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
399 <value type="int">16</value>
393 </data>
400 </data>
394 <data>
401 <data>
395 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
402 <variable>Version</variable>
396 <value type="int">15</value>
403 <value type="int">16</value>
397 </data>
404 </data>
398 </qtcreator>
405 </qtcreator>
@@ -39,8 +39,8 int start_recv_send_tasks( void );
39 void init_local_mode_parameters( void );
39 void init_local_mode_parameters( void );
40 void reset_local_time( void );
40 void reset_local_time( void );
41
41
42 extern int rtems_cpu_usage_report( void );
42 extern void rtems_cpu_usage_report( void );
43 extern int rtems_cpu_usage_reset( void );
43 extern void rtems_cpu_usage_reset( void );
44 extern void rtems_stack_checker_report_usage( void );
44 extern void rtems_stack_checker_report_usage( void );
45
45
46 extern int sched_yield( void );
46 extern int sched_yield( void );
@@ -12,10 +12,6
12 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
12 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
13 rtems_id HK_id; // id of the HK rate monotonic period
13 rtems_id HK_id; // id of the HK rate monotonic period
14
14
15 //extern rtems_name misc_name[5];
16 //time_management_regs_t *time_management_regs;
17 //extern Packet_TM_LFR_HK_t housekeeping_packet;
18
19 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
15 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
20 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
16 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
21 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
17 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
@@ -41,7 +37,7 void get_v_e1_e2_f3 (unsigned char *spac
41 void get_cpu_load( unsigned char *resource_statistics );
37 void get_cpu_load( unsigned char *resource_statistics );
42
38
43 extern int sched_yield( void );
39 extern int sched_yield( void );
44 extern int rtems_cpu_usage_reset();
40 extern void rtems_cpu_usage_reset();
45 extern ring_node *current_ring_node_f3;
41 extern ring_node *current_ring_node_f3;
46 extern ring_node *ring_node_to_send_cwf_f3;
42 extern ring_node *ring_node_to_send_cwf_f3;
47 extern unsigned short sequenceCounterHK;
43 extern unsigned short sequenceCounterHK;
@@ -86,12 +86,12 typedef struct ring_node
86 #define DEFAULT_SY_LFR_COMMON0 0x00
86 #define DEFAULT_SY_LFR_COMMON0 0x00
87 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
87 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
88 // NORM
88 // NORM
89 #define SY_LFR_N_SWF_L 2048 // nb sample
89 #define DFLT_SY_LFR_N_SWF_L 2048 // nb sample
90 #define SY_LFR_N_SWF_P 300 // sec
90 #define DFLT_SY_LFR_N_SWF_P 300 // sec
91 #define SY_LFR_N_ASM_P 3600 // sec
91 #define DFLT_SY_LFR_N_ASM_P 3600 // sec
92 #define SY_LFR_N_BP_P0 4 // sec
92 #define DFLT_SY_LFR_N_BP_P0 4 // sec
93 #define SY_LFR_N_BP_P1 20 // sec
93 #define DFLT_SY_LFR_N_BP_P1 20 // sec
94 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
94 #define DFLT_SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
95 #define MIN_DELTA_SNAPSHOT 16 // sec
95 #define MIN_DELTA_SNAPSHOT 16 // sec
96 // BURST
96 // BURST
97 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
97 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
@@ -1,6 +1,32
1 #ifndef LFR_CPU_USAGE_REPORT_H
1 #ifndef LFR_CPU_USAGE_REPORT_H
2 #define LFR_CPU_USAGE_REPORT_H
2 #define LFR_CPU_USAGE_REPORT_H
3
3
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #endif
7
8 #include <rtems.h>
9
10 #include <assert.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <ctype.h>
15 #include <inttypes.h>
16
17 #include <rtems/cpuuse.h>
18 #include <rtems/bspIo.h>
19
20 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
21 #include <rtems/score/timestamp.h>
22 #endif
23
24 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
25 extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
26 #else
27 extern uint32_t CPU_usage_Ticks_at_last_reset;
28 #endif
29
4 unsigned char lfr_rtems_cpu_usage_report( void );
30 unsigned char lfr_rtems_cpu_usage_report( void );
5
31
6 #endif // LFR_CPU_USAGE_REPORT_H
32 #endif // LFR_CPU_USAGE_REPORT_H
@@ -99,7 +99,7 void BP_send( char *data,
99 void reset_spectral_matrix_regs( void );
99 void reset_spectral_matrix_regs( void );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
104 unsigned char getSID( rtems_event_set event );
104 unsigned char getSID( rtems_event_set event );
105
105
@@ -9,6 +9,8
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "fsw_misc.h"
10 #include "fsw_misc.h"
11
11
12 #define FLOAT_EQUAL_ZERO 0.001
13
12 extern unsigned short sequenceCounterParameterDump;
14 extern unsigned short sequenceCounterParameterDump;
13
15
14 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
16 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
@@ -10,36 +10,6 struct drvmgr_key grlib_grspw_0n1_res[]
10 KEY_EMPTY
10 KEY_EMPTY
11 };
11 };
12
12
13 #if 0
14 /* APBUART0 */
15 struct drvmgr_key grlib_drv_res_apbuart0[] =
16 {
17 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
18 {"syscon", KEY_TYPE_INT, {(unsigned int)1}},
19 KEY_EMPTY
20 };
21 /* APBUART1 */
22 struct drvmgr_key grlib_drv_res_apbuart1[] =
23 {
24 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
25 {"syscon", KEY_TYPE_INT, {(unsigned int)0}},
26 KEY_EMPTY
27 };
28 /* LEON3 System with driver configuration for 2 APBUARTs, the
29 * the rest of the AMBA device drivers use their defaults.
30 */
31
32 /* Override default debug UART assignment.
33 * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0,
34 * CPU1=APBUART1...
35 * 1 = APBUART[0]
36 * 2 = APBUART[1]
37 * 3 = APBUART[2]
38 * ...
39 */
40 //int debug_uart_index = 2; /* second UART -- APBUART[1] */
41 #endif
42
43 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
13 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
44
14
45 struct drvmgr_bus_res grlib_drv_resources = {
15 struct drvmgr_bus_res grlib_drv_resources = {
@@ -142,6 +142,7 rtems_task stat_task(rtems_task_argument
142 rtems_task hous_task(rtems_task_argument argument)
142 rtems_task hous_task(rtems_task_argument argument)
143 {
143 {
144 rtems_status_code status;
144 rtems_status_code status;
145 rtems_status_code spare_status;
145 rtems_id queue_id;
146 rtems_id queue_id;
146 rtems_rate_monotonic_period_status period_status;
147 rtems_rate_monotonic_period_status period_status;
147
148
@@ -208,7 +209,7 rtems_task hous_task(rtems_task_argument
208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 if ( status != RTEMS_SUCCESSFUL ) {
210 if ( status != RTEMS_SUCCESSFUL ) {
210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 }
213 }
213 else {
214 else {
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
215 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
@@ -290,11 +291,9 rtems_task dumb_task( rtems_task_argumen
290 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
291 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
291 if (i==8)
292 if (i==8)
292 {
293 {
293 PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status)
294 }
294 }
295 if (i==10)
295 if (i==10)
296 {
296 {
297 PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status)
298 }
297 }
299 }
298 }
300 }
299 }
@@ -453,6 +452,8 void get_v_e1_e2_f3( unsigned char *spac
453 unsigned int offset_in_bytes;
452 unsigned int offset_in_bytes;
454 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
453 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
455
454
455 bufferPtr = NULL;
456
456 if (lfrCurrentMode == LFR_MODE_STANDBY)
457 if (lfrCurrentMode == LFR_MODE_STANDBY)
457 {
458 {
458 spacecraft_potential[0] = 0x00;
459 spacecraft_potential[0] = 0x00;
@@ -374,25 +374,39 int spacewire_configure_link( int fd )
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
375
375
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
377 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
377 if (status!=RTEMS_SUCCESSFUL) {
378 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
379 }
378 //
380 //
379 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
380 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
382 if (status!=RTEMS_SUCCESSFUL) {
383 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
384 }
381 //
385 //
382 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
386 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
383 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
387 if (status!=RTEMS_SUCCESSFUL) {
388 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
389 }
384 //
390 //
385 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
386 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
392 if (status!=RTEMS_SUCCESSFUL) {
393 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
394 }
387 //
395 //
388 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
396 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
397 if (status!=RTEMS_SUCCESSFUL) {
398 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
399 }
390 //
400 //
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
401 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
392 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
402 if (status!=RTEMS_SUCCESSFUL) {
403 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
404 }
393 //
405 //
394 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
406 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
395 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
407 if (status!=RTEMS_SUCCESSFUL) {
408 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
409 }
396
410
397 return status;
411 return status;
398 }
412 }
@@ -11,39 +11,8
11 * $Id$
11 * $Id$
12 */
12 */
13
13
14 #ifdef HAVE_CONFIG_H
15 #include "config.h"
16 #endif
17
18 #include <rtems.h>
19
20 #include <assert.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <ctype.h>
25 #include <inttypes.h>
26
27 #include <rtems/cpuuse.h>
28 #include <rtems/bspIo.h>
29
30 #include "lfr_cpu_usage_report.h"
14 #include "lfr_cpu_usage_report.h"
31
15
32 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
33 #include <rtems/score/timestamp.h>
34 #endif
35
36 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
37 extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
38 #else
39 extern uint32_t CPU_usage_Ticks_at_last_reset;
40 #endif
41
42 /*PAGE
43 *
44 * rtems_cpu_usage_report
45 */
46
47 unsigned char lfr_rtems_cpu_usage_report( void )
16 unsigned char lfr_rtems_cpu_usage_report( void )
48 {
17 {
49 uint32_t api_index;
18 uint32_t api_index;
@@ -51,7 +20,9 unsigned char lfr_rtems_cpu_usage_report
51 Objects_Information *information;
20 Objects_Information *information;
52 uint32_t ival, fval;
21 uint32_t ival, fval;
53 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
22 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
54 Timestamp_Control uptime, total, ran;
23 Timestamp_Control uptime;
24 Timestamp_Control total;
25 Timestamp_Control ran;
55 #else
26 #else
56 uint32_t total_units = 0;
27 uint32_t total_units = 0;
57 #endif
28 #endif
@@ -69,18 +40,18 unsigned char lfr_rtems_cpu_usage_report
69 _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
40 _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
70 #else
41 #else
71 for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
42 for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
72 if ( !_Objects_Information_table[ api_index ] )
43 if ( !_Objects_Information_table[ api_index ] ) { }
44 else
73 {
45 {
74 continue;
46 information = _Objects_Information_table[ api_index ][ 1 ];
75 }
47 if ( information != NULL )
76 information = _Objects_Information_table[ api_index ][ 1 ];
48 {
77 if ( information )
49 for ( i=1 ; i <= information->maximum ; i++ ) {
78 {
50 the_thread = (Thread_Control *)information->local_table[ i ];
79 for ( i=1 ; i <= information->maximum ; i++ ) {
80 the_thread = (Thread_Control *)information->local_table[ i ];
81
51
82 if ( the_thread )
52 if ( the_thread != NULL )
83 total_units += the_thread->cpu_time_used;
53 total_units += the_thread->cpu_time_used;
54 }
84 }
55 }
85 }
56 }
86 }
57 }
@@ -88,53 +59,52 unsigned char lfr_rtems_cpu_usage_report
88
59
89 for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ )
60 for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ )
90 {
61 {
91 if ( !_Objects_Information_table[ api_index ] )
62 if ( !_Objects_Information_table[ api_index ] ) { }
92 {
63 else
93 continue;
94 }
95 information = _Objects_Information_table[ api_index ][ 1 ];
96 if ( information )
97 {
64 {
98 the_thread = (Thread_Control *)information->local_table[ 1 ];
65 information = _Objects_Information_table[ api_index ][ 1 ];
99
66 if ( information != NULL )
100 if ( !the_thread )
101 {
102 continue;
103 }
104
105 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
106 /*
107 * If this is the currently executing thread, account for time
108 * since the last context switch.
109 */
110 ran = the_thread->cpu_time_used;
111 if ( _Thread_Executing->Object.id == the_thread->Object.id )
112 {
67 {
113 Timestamp_Control used;
68 the_thread = (Thread_Control *)information->local_table[ 1 ];
114 _Timestamp_Subtract(
115 &_Thread_Time_of_last_context_switch, &uptime, &used
116 );
117 _Timestamp_Add_to( &ran, &used );
118 }
119 _Timestamp_Divide( &ran, &total, &ival, &fval );
120
121 #else
122 if (total_units)
123 {
124 uint64_t ival_64;
125
69
126 ival_64 = the_thread->cpu_time_used;
70 if ( the_thread == NULL ) { }
127 ival_64 *= 100000;
71 else
128 ival = ival_64 / total_units;
72 {
73 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
74 /*
75 * If this is the currently executing thread, account for time
76 * since the last context switch.
77 */
78 ran = the_thread->cpu_time_used;
79 if ( _Thread_Executing->Object.id == the_thread->Object.id )
80 {
81 Timestamp_Control used;
82 _Timestamp_Subtract(
83 &_Thread_Time_of_last_context_switch, &uptime, &used
84 );
85 _Timestamp_Add_to( &ran, &used );
86 }
87 _Timestamp_Divide( &ran, &total, &ival, &fval );
88
89 #else
90 if (total_units != 0)
91 {
92 uint64_t ival_64;
93
94 ival_64 = the_thread->cpu_time_used;
95 ival_64 *= 100000;
96 ival = ival_64 / total_units;
97 }
98 else
99 {
100 ival = 0;
101 }
102
103 fval = ival % 1000;
104 ival /= 1000;
105 #endif
106 }
129 }
107 }
130 else
131 {
132 ival = 0;
133 }
134
135 fval = ival % 1000;
136 ival /= 1000;
137 #endif
138 }
108 }
139 }
109 }
140 cpu_load = (unsigned char) (100 - ival);
110 cpu_load = (unsigned char) (100 - ival);
@@ -139,6 +139,8 rtems_task prc2_task( rtems_task_argumen
139
139
140 unsigned long long int localTime;
140 unsigned long long int localTime;
141
141
142 incomingMsg = NULL;
143
142 ASM_init_header( &headerASM );
144 ASM_init_header( &headerASM );
143
145
144 //*************
146 //*************
@@ -96,6 +96,7 void spectral_matrices_isr_f1( void )
96 unsigned char status;
96 unsigned char status;
97 unsigned long long int time;
97 unsigned long long int time;
98 unsigned long long int syncBit;
98 unsigned long long int syncBit;
99 rtems_status_code status_code;
99
100
100 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
101 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
101
102
@@ -106,7 +107,7 void spectral_matrices_isr_f1( void )
106 case 3:
107 case 3:
107 // UNEXPECTED VALUE
108 // UNEXPECTED VALUE
108 spectral_matrix_regs->status = 0xc0; // [1100]
109 spectral_matrix_regs->status = 0xc0; // [1100]
109 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
110 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
110 break;
111 break;
111 case 1:
112 case 1:
112 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
113 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
@@ -132,6 +133,7 void spectral_matrices_isr_f1( void )
132 void spectral_matrices_isr_f2( void )
133 void spectral_matrices_isr_f2( void )
133 {
134 {
134 unsigned char status;
135 unsigned char status;
136 rtems_status_code status_code;
135
137
136 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
137
139
@@ -146,7 +148,7 void spectral_matrices_isr_f2( void )
146 case 3:
148 case 3:
147 // UNEXPECTED VALUE
149 // UNEXPECTED VALUE
148 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 spectral_matrix_regs->status = 0x30; // [0011 0000]
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
151 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
150 break;
152 break;
151 case 1:
153 case 1:
152 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
154 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
@@ -155,7 +157,7 void spectral_matrices_isr_f2( void )
155 spectral_matrix_regs->status = 0x10; // [0001 0000]
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
156 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
157 {
159 {
158 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
160 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
159 }
161 }
160 break;
162 break;
161 case 2:
163 case 2:
@@ -165,7 +167,7 void spectral_matrices_isr_f2( void )
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
167 spectral_matrix_regs->status = 0x20; // [0010 0000]
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
168 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
167 {
169 {
168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
170 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
169 }
171 }
170 break;
172 break;
171 }
173 }
@@ -173,9 +175,11 void spectral_matrices_isr_f2( void )
173
175
174 void spectral_matrix_isr_error_handler( void )
176 void spectral_matrix_isr_error_handler( void )
175 {
177 {
178 rtems_status_code status_code;
179
176 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
180 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
177 {
181 {
178 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
182 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
179 }
183 }
180 }
184 }
181
185
@@ -198,6 +202,8 rtems_isr spectral_matrices_isr( rtems_v
198
202
199 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
203 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
200 {
204 {
205 rtems_status_code status_code;
206
201 //***
207 //***
202 // F0
208 // F0
203 nb_sm_f0 = nb_sm_f0 + 1;
209 nb_sm_f0 = nb_sm_f0 + 1;
@@ -206,7 +212,7 rtems_isr spectral_matrices_isr_simu( rt
206 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
212 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
207 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
213 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
208 {
214 {
209 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
215 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
210 }
216 }
211 nb_sm_f0 = 0;
217 nb_sm_f0 = 0;
212 }
218 }
@@ -224,7 +230,7 rtems_isr spectral_matrices_isr_simu( rt
224 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
230 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
225 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
231 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
226 {
232 {
227 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
233 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
228 }
234 }
229 nb_sm_f1 = 0;
235 nb_sm_f1 = 0;
230 }
236 }
@@ -238,7 +244,7 rtems_isr spectral_matrices_isr_simu( rt
238 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
244 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
239 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
245 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
240 {
246 {
241 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
247 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
242 }
248 }
243 }
249 }
244 }
250 }
@@ -620,13 +626,14 unsigned long long int get_acquisition_t
620 return acquisitionTimeAslong;
626 return acquisitionTimeAslong;
621 }
627 }
622
628
623 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
629 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
624 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
630 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
625 unsigned long long int time )
631 unsigned long long int time )
626 {
632 {
627 unsigned char *timePtr;
633 unsigned char *timePtr;
628 unsigned char *coarseTimePtr;
634 unsigned char *coarseTimePtr;
629 unsigned char *fineTimePtr;
635 unsigned char *fineTimePtr;
636 rtems_status_code status_code;
630
637
631 timePtr = (unsigned char *) &time;
638 timePtr = (unsigned char *) &time;
632 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
639 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
@@ -642,9 +649,9 void close_matrix_actions(unsigned int *
642 coarseTimePtr[3] = timePtr[5];
649 coarseTimePtr[3] = timePtr[5];
643 fineTimePtr[2] = timePtr[6];
650 fineTimePtr[2] = timePtr[6];
644 fineTimePtr[3] = timePtr[7];
651 fineTimePtr[3] = timePtr[7];
645 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
652 if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
646 {
653 {
647 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
654 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
648 }
655 }
649 *nb_sm = 0;
656 *nb_sm = 0;
650 }
657 }
@@ -322,7 +322,6 int action_update_time(ccsdsTelecommandP
322 val++;
322 val++;
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326
325
327 return LFR_SUCCESSFUL;
326 return LFR_SUCCESSFUL;
328 }
327 }
@@ -764,6 +763,8 void launch_waveform_picker( unsigned ch
764 {
763 {
765 waveform_picker_regs->start_date = transitionCoarseTime;
764 waveform_picker_regs->start_date = transitionCoarseTime;
766 }
765 }
766
767 PRINTF1("commutation coarse time = %d\n", transitionCoarseTime)
767 }
768 }
768
769
769 void launch_spectral_matrix( void )
770 void launch_spectral_matrix( void )
@@ -120,7 +120,7 int action_load_burst_par(ccsdsTelecomma
120 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
120 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
121 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
121 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
122 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
122 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
123 if (aux != 0)
123 if (aux > FLOAT_EQUAL_ZERO)
124 {
124 {
125 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
125 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
126 flag = LFR_DEFAULT;
126 flag = LFR_DEFAULT;
@@ -185,7 +185,7 int action_load_sbm1_par(ccsdsTelecomman
185 if (flag == LFR_SUCCESSFUL)
185 if (flag == LFR_SUCCESSFUL)
186 {
186 {
187 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
187 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
188 if (aux != 0)
188 if (aux > FLOAT_EQUAL_ZERO)
189 {
189 {
190 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
190 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
191 flag = LFR_DEFAULT;
191 flag = LFR_DEFAULT;
@@ -252,7 +252,7 int action_load_sbm2_par(ccsdsTelecomman
252 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
252 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
253 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
253 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
254 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
254 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
255 if (aux != 0)
255 if (aux > FLOAT_EQUAL_ZERO)
256 {
256 {
257 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
257 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
258 flag = LFR_DEFAULT;
258 flag = LFR_DEFAULT;
@@ -368,7 +368,7 int check_common_par_consistency( ccsdsT
368 // sy_lfr_n_bp_p0
368 // sy_lfr_n_bp_p0
369 if (flag == LFR_SUCCESSFUL)
369 if (flag == LFR_SUCCESSFUL)
370 {
370 {
371 if (sy_lfr_n_bp_p0 < SY_LFR_N_BP_P0)
371 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
372 {
372 {
373 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
373 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
374 flag = WRONG_APP_DATA;
374 flag = WRONG_APP_DATA;
@@ -387,7 +387,7 int check_common_par_consistency( ccsdsT
387 if (flag == LFR_SUCCESSFUL)
387 if (flag == LFR_SUCCESSFUL)
388 {
388 {
389 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
389 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
390 if (aux != 0)
390 if (aux > FLOAT_EQUAL_ZERO)
391 {
391 {
392 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
392 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
393 flag = WRONG_APP_DATA;
393 flag = WRONG_APP_DATA;
@@ -396,7 +396,7 int check_common_par_consistency( ccsdsT
396 // sy_lfr_n_bp_p1
396 // sy_lfr_n_bp_p1
397 if (flag == LFR_SUCCESSFUL)
397 if (flag == LFR_SUCCESSFUL)
398 {
398 {
399 if (sy_lfr_n_bp_p1 < SY_LFR_N_BP_P1)
399 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
400 {
400 {
401 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
401 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
402 flag = WRONG_APP_DATA;
402 flag = WRONG_APP_DATA;
@@ -406,7 +406,7 int check_common_par_consistency( ccsdsT
406 if (flag == LFR_SUCCESSFUL)
406 if (flag == LFR_SUCCESSFUL)
407 {
407 {
408 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
408 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
409 if (aux != 0)
409 if (aux > FLOAT_EQUAL_ZERO)
410 {
410 {
411 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
411 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
412 flag = LFR_DEFAULT;
412 flag = LFR_DEFAULT;
@@ -476,7 +476,7 int set_sy_lfr_n_asm_p( ccsdsTelecommand
476
476
477 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
477 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
478 {
478 {
479 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
479 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
480 *
480 *
481 * @param TC points to the TeleCommand packet that is being processed
481 * @param TC points to the TeleCommand packet that is being processed
482 * @param queue_id is the id of the queue which handles TM related to this execution step
482 * @param queue_id is the id of the queue which handles TM related to this execution step
@@ -738,15 +738,15 void init_parameter_dump( void )
738
738
739 //******************
739 //******************
740 // NORMAL PARAMETERS
740 // NORMAL PARAMETERS
741 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
741 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
742 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
742 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
743 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
743 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
744 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
744 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
745 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
745 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
746 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
746 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
747 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
747 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
748 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
748 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
749 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
749 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
750
750
751 //*****************
751 //*****************
752 // BURST PARAMETERS
752 // BURST PARAMETERS
@@ -68,6 +68,7 rtems_isr waveforms_isr( rtems_vector_nu
68 */
68 */
69
69
70 rtems_status_code status;
70 rtems_status_code status;
71 rtems_status_code spare_status;
71
72
72 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
73 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
73 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
74 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
@@ -79,7 +80,7 rtems_isr waveforms_isr( rtems_vector_nu
79 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
80 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
80 // (2) send an event for the waveforms transmission
81 // (2) send an event for the waveforms transmission
81 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 }
84 }
84 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
85 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
@@ -98,7 +99,7 rtems_isr waveforms_isr( rtems_vector_nu
98 case(LFR_MODE_NORMAL):
99 case(LFR_MODE_NORMAL):
99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 {
101 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 }
103 }
103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 {
105 {
@@ -117,7 +118,7 rtems_isr waveforms_isr( rtems_vector_nu
117 //
118 //
118 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
119 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
119 {
120 {
120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 }
122 }
122 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
123 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
123 }
124 }
@@ -133,7 +134,7 rtems_isr waveforms_isr( rtems_vector_nu
133 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
134 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
134 // (2) send an event for the waveforms transmission
135 // (2) send an event for the waveforms transmission
135 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
136 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 }
138 }
138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
139 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
139 }
140 }
@@ -505,6 +506,9 void WFP_reset_current_ring_nodes( void
505 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
506 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
506 {
507 {
507 unsigned char i;
508 unsigned char i;
509 int return_value;
510
511 return_value = LFR_SUCCESSFUL;
508
512
509 for (i=0; i<7; i++)
513 for (i=0; i<7; i++)
510 {
514 {
@@ -547,12 +551,16 int init_header_snapshot_wf_table( unsig
547 headerSWF[ i ].sid = sid;
551 headerSWF[ i ].sid = sid;
548 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
552 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
549 }
553 }
550 return LFR_SUCCESSFUL;
554
555 return return_value;
551 }
556 }
552
557
553 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
558 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
554 {
559 {
555 unsigned int i;
560 unsigned int i;
561 int return_value;
562
563 return_value = LFR_SUCCESSFUL;
556
564
557 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
565 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
558 {
566 {
@@ -591,12 +599,16 int init_header_continuous_wf_table( uns
591 headerCWF[ i ].time[0] = 0x00;
599 headerCWF[ i ].time[0] = 0x00;
592 headerCWF[ i ].time[0] = 0x00;
600 headerCWF[ i ].time[0] = 0x00;
593 }
601 }
594 return LFR_SUCCESSFUL;
602
603 return return_value;
595 }
604 }
596
605
597 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
606 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
598 {
607 {
599 unsigned int i;
608 unsigned int i;
609 int return_value;
610
611 return_value = LFR_SUCCESSFUL;
600
612
601 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
613 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
602 {
614 {
@@ -630,7 +642,8 int init_header_continuous_cwf3_light_ta
630 headerCWF[ i ].time[0] = 0x00;
642 headerCWF[ i ].time[0] = 0x00;
631 headerCWF[ i ].time[0] = 0x00;
643 headerCWF[ i ].time[0] = 0x00;
632 }
644 }
633 return LFR_SUCCESSFUL;
645
646 return return_value;
634 }
647 }
635
648
636 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
649 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
General Comments 0
You need to be logged in to leave comments. Login now