##// END OF EJS Templates
Commit before working on the ERR 4 due to message queue...
paul -
r34:c3c11207c46d default
parent child
Show More
@@ -1,6 +1,6
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Sep 30 15:28:56 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Oct 4 15:16:59 2013
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 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 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=13 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=13 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DPRINT_STACK_REPORT
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
1 NO CONTENT: modified file, binary diff hidden
@@ -1,7 +1,7
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** cpu_usage_report *** gsa
4 CONFIG += console verbose
3 # CONFIG options = verbose *** cpu_usage_report *** gsa *** stack_report
4 CONFIG += console verbose stack_report cpu_usage_report
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
@@ -21,6 +21,10 contains( CONFIG, cpu_usage_report ) {
21 21 DEFINES += PRINT_TASK_STATISTICS
22 22 }
23 23
24 contains( CONFIG, stack_report ) {
25 DEFINES += PRINT_STACK_REPORT
26 }
27
24 28 TARGET = fsw
25 29 contains( CONFIG, gsa ) {
26 30 DEFINES += GSA
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.0, 2013-10-01T07:01:25. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-04T15:45:21. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -15,14 +15,14
15 15
16 16 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
17 17 #define DEFAULT_RESERVED 0x00
18 #define DEFAULT_HKBIA 0x1f
18 #define DEFAULT_HKBIA 0x1e // 0001 1110
19 19
20 20 // PACKET ID
21 21 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
22 22 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
23 23 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
24 #define TM_PACKET_ID_SCIENCE_NORMAL 0x0ccc // PID 76 CAT 12
25 #define TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 0x0cfc // PID 79 CAT 12
24 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
25 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
26 26 #define TM_PACKET_PID_DEFAULT 76
27 27 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
28 28 #define TM_PACKET_CAT_TC_EXE 1
@@ -23,7 +23,9 extern int sched_yield( void );
23 23 extern int errno;
24 24 extern rtems_id Task_id[ ]; /* array of task ids */
25 25 extern rtems_name Task_name[ ]; /* array of task names */
26 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
26 extern rtems_name misc_id[ ];
27 extern rtems_name misc_name[ ]; /* array of miscellaneous names for rtems objects */
28 extern unsigned int maxCount;
27 29 extern int fdSPW; // grspw file descriptor
28 30 extern int fdUART; // uart file descriptor
29 31 extern unsigned char lfrCurrentMode;
@@ -38,18 +40,20 rtems_task Init( rtems_task_argument arg
38 40 rtems_task recv_task(rtems_task_argument argument);
39 41 rtems_task stat_task(rtems_task_argument argument);
40 42 rtems_task wfrm_task(rtems_task_argument argument);
43
44 // OTHER functions
41 45 int create_names( void );
42 46 int create_all_tasks( void );
43 47 int start_all_tasks( void );
44 int create_message_queue( void );
48 //
45 49 int create_message_queues( void );
46
47 // OTHER functions
50 //
48 51 void init_parameter_dump( void );
49 52 void init_local_mode_parameters( void );
50 53 void init_housekeeping_parameters( void );
51 54
52 55 extern int rtems_cpu_usage_report( void );
53 56 extern int rtems_cpu_usage_reset( void );
57 extern void rtems_stack_checker_report_usage( void );
54 58
55 59 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -24,6 +24,7
24 24 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
25 25 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
26 26 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
27 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
27 28
28 29 //****************************
29 30 // LFR DEFAULT MODE PARAMETERS
@@ -114,28 +115,32
114 115 #define TASKID_CWF1 14
115 116 #define TASKID_SEND 15
116 117
117 //*********************************************************************
118 // ALL TASKS THAT USE THE SPACEWIRE DIRVER SHALL HAVE THE SAME PRIORITY
119 // OR CHANGE THE SEMAPHORE CREATION IN THE DRIVER...
120 118 #define TASK_PRIORITY_SPIQ 5
121 119 #define TASK_PRIORITY_SMIQ 10
122 #define TASK_PRIORITY_SEND 11
123 #define TASK_PRIORITY_RECV 12
124 #define TASK_PRIORITY_ACTN 12
125 #define TASK_PRIORITY_CWF1 14
126 #define TASK_PRIORITY_HOUS 15
127 #define TASK_PRIORITY_CWF2 15
128 #define TASK_PRIORITY_WFRM 15
129 #define TASK_PRIORITY_CWF3 15
130 #define TASK_PRIORITY_AVF0 50
131 #define TASK_PRIORITY_BPF0 50
132 #define TASK_PRIORITY_MATR 250
133 #define TASK_PRIORITY_STAT 251
134 #define TASK_PRIORITY_DUMB 251
120 //
121 #define TASK_PRIORITY_SEND 30
122 //
123 #define TASK_PRIORITY_RECV 40
124 #define TASK_PRIORITY_ACTN 40
125 //
126 #define TASK_PRIORITY_HOUS 40
127 #define TASK_PRIORITY_CWF1 40
128 #define TASK_PRIORITY_CWF2 40
129 #define TASK_PRIORITY_WFRM 40
130 #define TASK_PRIORITY_CWF3 40
131 //
132 #define TASK_PRIORITY_AVF0 60
133 #define TASK_PRIORITY_BPF0 60
134 #define TASK_PRIORITY_MATR 100
135 #define TASK_PRIORITY_STAT 200
136 #define TASK_PRIORITY_DUMB 200
135 137
136 138 #define ACTION_MSG_QUEUE_COUNT 10
137 139 #define ACTION_MSG_PKTS_COUNT 50
138 #define ACTION_MSG_PKTS_SIZE
140 #define ACTION_MSG_PKTS_SIZE 24 // hlen *hdr dlen *data sent options
141
142 #define QUEUE_QUEU 0
143 #define QUEUE_PKTS 1
139 144
140 145 //*******
141 146 // MACROS
@@ -15,6 +15,8
15 15
16 16 extern volatile int spec_mat_f0_0[ ];
17 17 extern volatile int spec_mat_f0_1[ ];
18 extern volatile int spec_mat_f0_a[ ];
19 extern volatile int spec_mat_f0_b[ ];
18 20 extern volatile int spec_mat_f0_c[ ];
19 21 extern volatile int spec_mat_f0_d[ ];
20 22 extern volatile int spec_mat_f0_e[ ];
@@ -41,6 +43,7 extern spectral_matrix_regs_t *spectral_
41 43
42 44 // ISR
43 45 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
46 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
44 47
45 48 // RTEMS TASKS
46 49 rtems_task spw_bppr_task(rtems_task_argument argument);
@@ -12,15 +12,9
12 12 #include "fsw_init.h"
13 13 #include "fsw_misc.h"
14 14
15 extern int fdSPW;
16 extern unsigned char lfrCurrentMode;
17 extern rtems_name misc_name[ ];
18 extern rtems_name misc_id[ ];
19 extern rtems_id Task_id[ ]; // array of task ids
20 15 // MODE PARAMETERS
21 16 extern struct param_sbm1_str param_sbm1;
22 17 extern struct param_sbm2_str param_sbm2;
23 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
24 18 extern time_management_regs_t *time_management_regs;
25 19 extern waveform_picker_regs_t *waveform_picker_regs;
26 20 extern gptimer_regs_t *gptimer_regs;
@@ -31,7 +31,6 extern volatile int wf_snap_f2_norm[ ];
31 31 extern volatile int wf_cont_f3[ ];
32 32 extern volatile int wf_cont_f3_bis[ ];
33 33 extern waveform_picker_regs_t *waveform_picker_regs;
34 extern unsigned char lfrCurrentMode;
35 34
36 35 rtems_isr waveforms_isr( rtems_vector_number vector );
37 36 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
@@ -44,12 +43,12 rtems_task cwf1_task(rtems_task_argument
44 43 // general functions
45 44 void init_waveforms( void );
46 45 //
47 int init_header_snapshot_wf_table( unsigned int sid );
46 int init_header_snapshot_wf_table(unsigned int sid , Header_TM_LFR_SCIENCE_SWF_t *headerSWF);
48 47 int init_header_continuous_wf_table(unsigned int sid , Header_TM_LFR_SCIENCE_CWF_t *headerCWF);
49 48 //
50 49 void reset_waveforms( void );
51 50
52 int send_waveform_SWF(volatile int *waveform, unsigned int sid);
51 int send_waveform_SWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF);
53 52 int send_waveform_CWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF);
54 53
55 54 //**************
@@ -10,6 +10,7 rtems_name misc_name[5];
10 10 rtems_name misc_id[5];
11 11 rtems_id Task_id[20]; /* array of task ids */
12 12 rtems_name Task_name[20]; /* array of task names */
13 unsigned int maxCount;
13 14 int fdSPW = 0;
14 15 int fdUART = 0;
15 16 unsigned char lfrCurrentMode;
@@ -40,6 +41,8 volatile int wf_cont_f3_bis[ NB_SAMPLES_
40 41 // SPECTRAL MATRICES GLOBAL VARIABLES
41 42 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
42 43 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
44 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
45 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
43 46 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
44 47 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
45 48 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
@@ -19,10 +19,15
19 19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 5 // instead of 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
23 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
23 24 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 25 #define CONFIGURE_MAXIMUM_PERIODS 5
26 #define CONFIGURE_MAXIMUM_TIMERS 5
25 27 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
28 #ifdef PRINT_STACK_REPORT
29 #define CONFIGURE_STACK_CHECKER_ENABLED
30 #endif
26 31
27 32 #include <rtems/confdefs.h>
28 33
@@ -62,12 +67,15 rtems_task Init( rtems_task_argument ign
62 67 init_parameter_dump();
63 68 init_local_mode_parameters();
64 69 init_housekeeping_parameters();
70
71 create_names(); // create all names
72
65 73 create_message_queues();
66 74
67 create_names(); // create all names
68 75 create_all_tasks(); // create all tasks
69 76
70 77 start_all_tasks(); // start all tasks
78
71 79 stop_current_mode(); // go in STANDBY mode
72 80
73 81 grspw_timecode_callback = &timecode_irq_handler;
@@ -75,15 +83,19 rtems_task Init( rtems_task_argument ign
75 83 spacewire_configure_link();
76 84
77 85 #ifdef GSA
86 // mask IRQ lines
87 LEON_Mask_interrupt( IRQ_SM );
88 LEON_Mask_interrupt( IRQ_WF );
78 89 // Spectral Matrices simulator
79 90 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
80 91 IRQ_SPARC_SM, spectral_matrices_isr );
81 92 // WaveForms
82 93 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
83 94 IRQ_SPARC_WF, waveforms_simulator_isr );
84 LEON_Mask_interrupt( IRQ_SM );
85 LEON_Mask_interrupt( IRQ_WF );
86 95 #else
96 // mask IRQ lines
97 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
98 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX );
87 99 // reset configuration registers
88 100 reset_waveform_picker_regs();
89 101 reset_spectral_matrix_regs();
@@ -92,19 +104,21 rtems_task Init( rtems_task_argument ign
92 104 IRQ_SPARC_WAVEFORM_PICKER,
93 105 &old_isr_handler) ;
94 106 // configure IRQ handling for the spectral matrix unit
95 status = rtems_interrupt_catch( spectral_matrices_isr,
96 IRQ_SPARC_SPECTRAL_MATRIX,
97 &old_isr_handler) ;
98 // mask IRQ lines
99 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
100 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX );
107 // status = rtems_interrupt_catch( spectral_matrices_isr,
108 // IRQ_SPARC_SPECTRAL_MATRIX,
109 // &old_isr_handler) ;
110 // Spectral Matrices simulator
111 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
112 IRQ_SPARC_SM, spectral_matrices_isr_simu );
101 113 #endif
102 114
115 PRINTF("delete INIT\n")
116
103 117 status = rtems_task_delete(RTEMS_SELF);
104 118
105 119 }
106 120
107 void init_parameter_dump(void)
121 void init_parameter_dump( void )
108 122 {
109 123 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
110 124 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
@@ -161,7 +175,7 void init_parameter_dump(void)
161 175 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
162 176 }
163 177
164 void init_local_mode_parameters(void)
178 void init_local_mode_parameters( void )
165 179 {
166 180 // LOCAL PARAMETERS
167 181 set_local_sbm1_nb_cwf_max();
@@ -176,7 +190,7 void init_local_mode_parameters(void)
176 190 reset_local_sbm2_nb_cwf_sent();
177 191 }
178 192
179 void init_housekeeping_parameters(void)
193 void init_housekeeping_parameters( void )
180 194 {
181 195 unsigned int i = 0;
182 196 unsigned int j = 0;
@@ -232,6 +246,9 int create_names( void )
232 246 // rate monotonic period name
233 247 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
234 248
249 misc_name[QUEUE_QUEU] = rtems_build_name( 'Q', 'U', 'E', 'U' );
250 misc_name[QUEUE_PKTS] = rtems_build_name( 'P', 'K', 'T', 'S' );
251
235 252 return 0;
236 253 }
237 254
@@ -241,91 +258,91 int create_all_tasks( void )
241 258
242 259 // RECV
243 260 status = rtems_task_create(
244 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE * 2,
261 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
245 262 RTEMS_DEFAULT_MODES,
246 263 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
247 264 );
248 265 // ACTN
249 266 status = rtems_task_create(
250 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE * 2,
267 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
251 268 RTEMS_DEFAULT_MODES,
252 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
269 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
253 270 );
254 271 // SPIQ
255 272 status = rtems_task_create(
256 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE * 2,
273 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
257 274 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
258 275 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
259 276 );
260 277 // SMIQ
261 278 status = rtems_task_create(
262 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE * 2,
279 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
263 280 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
264 281 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
265 282 );
266 283 // STAT
267 284 status = rtems_task_create(
268 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE * 2,
285 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
269 286 RTEMS_DEFAULT_MODES,
270 287 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
271 288 );
272 289 // AVF0
273 290 status = rtems_task_create(
274 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE * 2,
291 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
275 292 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
276 293 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
277 294 );
278 295 // BPF0
279 296 status = rtems_task_create(
280 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE * 2,
297 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
281 298 RTEMS_DEFAULT_MODES,
282 299 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
283 300 );
284 301 // WFRM
285 302 status = rtems_task_create(
286 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE * 2,
303 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
287 304 RTEMS_DEFAULT_MODES,
288 305 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
289 306 );
290 307 // DUMB
291 308 status = rtems_task_create(
292 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE * 2,
309 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
293 310 RTEMS_DEFAULT_MODES,
294 311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
295 312 );
296 313 // HOUS
297 314 status = rtems_task_create(
298 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE * 2,
315 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
299 316 RTEMS_DEFAULT_MODES,
300 317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
301 318 );
302 319 // MATR
303 320 status = rtems_task_create(
304 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE * 2,
321 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
305 322 RTEMS_DEFAULT_MODES,
306 323 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
307 324 );
308 325 // CWF3
309 326 status = rtems_task_create(
310 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE * 2,
327 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
311 328 RTEMS_DEFAULT_MODES,
312 329 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
313 330 );
314 331 // CWF2
315 332 status = rtems_task_create(
316 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE * 2,
333 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
317 334 RTEMS_DEFAULT_MODES,
318 335 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
319 336 );
320 337 // CWF1
321 338 status = rtems_task_create(
322 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE * 2,
339 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
323 340 RTEMS_DEFAULT_MODES,
324 341 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
325 342 );
326 343 // SEND
327 344 status = rtems_task_create(
328 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
345 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
329 346 RTEMS_DEFAULT_MODES,
330 347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
331 348 );
@@ -418,19 +435,16 int create_message_queues( void )
418 435 {
419 436 rtems_status_code status;
420 437
421 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
422 misc_name[1] = rtems_build_name( 'P', 'K', 'T', 'S' );
423
424 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
425 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
438 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
439 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[QUEUE_QUEU] );
426 440 if (status!=RTEMS_SUCCESSFUL) {
427 PRINTF("in create_message_queues *** error creating QUEU\n")
441 PRINTF("in create_message_queues *** ERR creating QUEU\n")
428 442 }
429 443
430 status = rtems_message_queue_create( misc_name[1], ACTION_MSG_PKTS_COUNT, sizeof(spw_ioctl_pkt_send),
431 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[1] );
444 status = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_SIZE,
445 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[QUEUE_PKTS] );
432 446 if (status!=RTEMS_SUCCESSFUL) {
433 PRINTF("in create_message_queues *** error creating PKTS\n")
447 PRINTF("in create_message_queues *** ERR creating PKTS\n")
434 448 }
435 449
436 450 return 0;
@@ -162,7 +162,7 rtems_task hous_task(rtems_task_argument
162 162
163 163 spw_ioctl_send.hlen = 0;
164 164 spw_ioctl_send.hdr = NULL;
165 spw_ioctl_send.dlen = sizeof(spw_ioctl_send);
165 spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
166 166 spw_ioctl_send.data = (char*) &housekeeping_packet;
167 167 spw_ioctl_send.options = 0;
168 168
@@ -215,8 +215,7 rtems_task hous_task(rtems_task_argument
215 215 update_spacewire_statistics();
216 216
217 217 // SEND PACKET
218 //result = write( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
219 status = rtems_message_queue_send( misc_id[1], &spw_ioctl_send, sizeof(spw_ioctl_send));
218 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
220 219 if (status != RTEMS_SUCCESSFUL) {
221 220 PRINTF1("in HOUS *** ERR %d\n", (int) status)
222 221 }
@@ -233,22 +232,45 rtems_task hous_task(rtems_task_argument
233 232 rtems_task send_task( rtems_task_argument argument)
234 233 {
235 234 rtems_status_code status; // RTEMS status code
236 spw_ioctl_pkt_send spw_ioctl_send_CWF; // incoming spw_ioctl_pkt_send structure
235 spw_ioctl_pkt_send spw_ioctl_send; // incoming spw_ioctl_pkt_send structure
237 236 size_t size; // size of the incoming TC packet
237 u_int32_t count;
238 238
239 239 PRINTF("in SEND *** \n")
240 240
241 241 while(1)
242 242 {
243 status = rtems_message_queue_receive(misc_id[1], (char*) &spw_ioctl_send_CWF, &size,
243 status = rtems_message_queue_receive(misc_id[QUEUE_PKTS], (char*) &spw_ioctl_send, &size,
244 244 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
245 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
245 if (status!=RTEMS_SUCCESSFUL)
246 {
247 PRINTF1("in SEND *** (1) ERR = %d \n", status)
248 }
246 249 else
247 250 {
248 status = write_spw(&spw_ioctl_send_CWF);
251 status = write_spw(&spw_ioctl_send);
249 252 if (status != RTEMS_SUCCESSFUL) {
250 253 PRINTF("in SEND *** TRAFFIC JAM\n")
251 254 }
252 255 }
256
257 status = rtems_message_queue_get_number_pending( misc_id[QUEUE_PKTS], &count );
258 if (status != RTEMS_SUCCESSFUL)
259 {
260 PRINTF1("in SEND *** (2) ERR = %d \n", status)
261 }
262 else
263 {
264 if (count > maxCount)
265 {
266 maxCount = count;
267 }
268 }
253 269 }
254 270 }
271
272
273
274
275
276
@@ -81,8 +81,16 rtems_isr spectral_matrices_isr( rtems_v
81 81 }
82 82 }
83 83
84 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
85 {
86 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
87 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
88 }
89 }
90
84 91 //************
85 92 // RTEMS TASKS
93
86 94 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
87 95 {
88 96 rtems_event_set event_out;
@@ -93,8 +101,8 rtems_task smiq_task(rtems_task_argument
93 101 while(1){
94 102 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
95 103 nb_interrupt_f0 = nb_interrupt_f0 + 1;
96 if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){
97 if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
104 if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
105 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
98 106 {
99 107 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
100 108 }
@@ -103,6 +111,26 rtems_task smiq_task(rtems_task_argument
103 111 }
104 112 }
105 113
114 //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
115 //{
116 // rtems_event_set event_out;
117 // unsigned int nb_interrupt_f0 = 0;
118
119 // PRINTF("in SMIQ *** \n")
120
121 // while(1){
122 // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
123 // nb_interrupt_f0 = nb_interrupt_f0 + 1;
124 // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){
125 // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
126 // {
127 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
128 // }
129 // nb_interrupt_f0 = 0;
130 // }
131 // }
132 //}
133
106 134 rtems_task spw_bppr_task(rtems_task_argument argument)
107 135 {
108 136 rtems_status_code status;
@@ -140,7 +168,7 rtems_task spw_bppr_task(rtems_task_argu
140 168
141 169 rtems_task avf0_task(rtems_task_argument argument)
142 170 {
143 //int i;
171 int i;
144 172 static int nb_average;
145 173 rtems_event_set event_out;
146 174 rtems_status_code status;
@@ -151,7 +179,7 rtems_task avf0_task(rtems_task_argument
151 179
152 180 while(1){
153 181 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
154 /*for(i=0; i<TOTAL_SIZE_SM; i++){
182 for(i=0; i<TOTAL_SIZE_SM; i++){
155 183 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
156 184 + spec_mat_f0_b[i]
157 185 + spec_mat_f0_c[i]
@@ -160,7 +188,7 rtems_task avf0_task(rtems_task_argument
160 188 + spec_mat_f0_f[i]
161 189 + spec_mat_f0_g[i]
162 190 + spec_mat_f0_h[i];
163 }*/
191 }
164 192 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
165 193 if (nb_average == NB_AVERAGE_NORMAL_f0) {
166 194 nb_average = 0;
@@ -454,8 +482,8 void init_header_asm( Header_TM_LFR_SCIE
454 482 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
455 483 header->reserved = 0x00;
456 484 header->userApplication = CCSDS_USER_APP;
457 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL >> 8);
458 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL);
485 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
486 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
459 487 header->packetSequenceControl[0] = 0xc0;
460 488 header->packetSequenceControl[1] = 0x00;
461 489 header->packetLength[0] = 0x00;
@@ -137,7 +137,7 int TC_acceptance(ccsdsTelecommandPacket
137 137 status = write( fdSPW, (char *) &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4);
138 138 }
139 139 else { // send valid TC to the action launcher
140 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
140 status = rtems_message_queue_send( misc_id[QUEUE_QUEU], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
141 141 ret = -1;
142 142 }
143 143 return ret;
@@ -335,12 +335,12 unsigned char TM_build_header( enum TM_T
335 335 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
336 336 break;
337 337 case(TM_LFR_SCI):
338 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL;
338 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL_BURST;
339 339 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
340 340 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
341 341 break;
342 342 case(TM_LFR_SCI_SBM):
343 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2;
343 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_SBM1_SBM2;
344 344 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
345 345 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
346 346 break;
@@ -389,7 +389,6 rtems_task recv_task( rtems_task_argumen
389 389 //}
390 390 }
391 391 else {
392 PRINTF1("Got pck of length %d\n", len+1)
393 392 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
394 393 PRINTF("In RECV *** packet lenght too short\n")
395 394 }
@@ -422,7 +421,7 rtems_task actn_task( rtems_task_argumen
422 421
423 422 while(1)
424 423 {
425 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
424 status = rtems_message_queue_receive(misc_id[QUEUE_QUEU], (char*) &TC, &size,
426 425 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
427 426 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
428 427 else
@@ -545,28 +544,43 int action_load_common_par(ccsdsTelecomm
545 544 int action_load_normal_par(ccsdsTelecommandPacket_t *TC)
546 545 {
547 546 int result;
548 unsigned char lfrMode;
547 unsigned int tmp;
549 548
550 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
549 result = LFR_SUCCESSFUL;
551 550
552 if ( lfrMode == LFR_MODE_NORMAL ) {
551 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
553 552 send_tm_lfr_tc_exe_not_executable( TC );
554 553 result = LFR_DEFAULT;
555 554 }
556 555 else {
556 // sy_lfr_n_swf_l
557 557 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[0];
558 558 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[1];
559 559
560 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[2];
561 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[3];
560 // sy_lfr_n_swf_p
561 tmp = (unsigned int ) floor(
562 (TC->dataAndCRC[2] * 256
563 + TC->dataAndCRC[3])/8
564 ) * 8;
565 if ( (tmp < 16) || (tmp>65528) )
566 {
567 result = LFR_DEFAULT;
568 }
569 else
570 {
571 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
572 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
573 }
562 574
575 // sy_lfr_n_asm_p
563 576 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[4];
564 577 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[5];
565 578
579 // sy_lfr_n_bp_p0
566 580 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
581
582 // sy_lfr_n_bp_p1
567 583 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
568
569 result = LFR_SUCCESSFUL;
570 584 }
571 585
572 586 return result;
@@ -670,6 +684,7 int action_enter_mode(ccsdsTelecommandPa
670 684 if (requestedMode != LFR_MODE_STANDBY)
671 685 {
672 686 rtems_cpu_usage_reset();
687 maxCount = 0;
673 688 }
674 689 #endif
675 690
@@ -854,6 +869,7 int stop_current_mode()
854 869 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
855 870 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
856 871 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
872 LEON_Mask_interrupt( IRQ_SM );
857 873 #endif
858 874 //**********************
859 875 // suspend several tasks
@@ -918,9 +934,17 int enter_mode(unsigned char mode, ccsds
918 934 int enter_standby_mode()
919 935 {
920 936 reset_waveform_picker_regs();
937
938 PRINTF1("maxCount = %d\n", maxCount)
939
921 940 #ifdef PRINT_TASK_STATISTICS
922 941 rtems_cpu_usage_report();
923 942 #endif
943
944 #ifdef PRINT_STACK_REPORT
945 rtems_stack_checker_report_usage();
946 #endif
947
924 948 return LFR_SUCCESSFUL;
925 949 }
926 950
@@ -996,6 +1020,10 int enter_sbm1_mode()
996 1020 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
997 1021 reset_waveform_picker_regs();
998 1022 set_wfp_burst_enable_register(LFR_MODE_SBM1);
1023 // SM simulation
1024 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
1025 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
1026 LEON_Unmask_interrupt( IRQ_SM );
999 1027 #endif
1000 1028
1001 1029 return status;
@@ -1082,6 +1110,8 int send_tm_lfr_tc_exe_success(ccsdsTele
1082 1110 char data[4];
1083 1111 spw_ioctl_pkt_send spw_ioctl_send;
1084 1112
1113 ret = LFR_SUCCESSFUL;
1114
1085 1115 TM_build_header( TM_LFR_TC_EXE_OK, PACKET_LENGTH_TC_EXE_SUCCESS,
1086 1116 &TM_header,
1087 1117 TC->sourceID); // TC source ID
@@ -1100,7 +1130,7 int send_tm_lfr_tc_exe_success(ccsdsTele
1100 1130
1101 1131 // SEND DATA
1102 1132 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1103 status = rtems_message_queue_send( misc_id[1], &spw_ioctl_send, sizeof(spw_ioctl_send));
1133 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1104 1134 if (status != RTEMS_SUCCESSFUL) {
1105 1135 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1106 1136 ret = LFR_DEFAULT;
@@ -1111,11 +1141,14 int send_tm_lfr_tc_exe_success(ccsdsTele
1111 1141
1112 1142 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC)
1113 1143 {
1144 int ret;
1114 1145 rtems_status_code status;
1115 1146 TMHeader_t TM_header;
1116 1147 char data[10];
1117 1148 spw_ioctl_pkt_send spw_ioctl_send;
1118 1149
1150 ret = LFR_SUCCESSFUL;
1151
1119 1152 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE,
1120 1153 &TM_header,
1121 1154 TC->sourceID); // TC source ID
@@ -1139,18 +1172,26 int send_tm_lfr_tc_exe_not_executable(cc
1139 1172 spw_ioctl_send.options = 0;
1140 1173
1141 1174 // SEND DATA
1142 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1175 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1176 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1177 if (status != RTEMS_SUCCESSFUL) {
1178 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1179 ret = LFR_DEFAULT;
1180 }
1143 1181
1144 1182 return LFR_SUCCESSFUL;
1145 1183 }
1146 1184
1147 1185 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC)
1148 1186 {
1187 int ret;
1149 1188 rtems_status_code status;
1150 1189 TMHeader_t TM_header;
1151 1190 char data[8];
1152 1191 spw_ioctl_pkt_send spw_ioctl_send;
1153 1192
1193 ret = LFR_SUCCESSFUL;
1194
1154 1195 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED,
1155 1196 &TM_header,
1156 1197 TC->sourceID); // TC source ID
@@ -1172,13 +1213,19 int send_tm_lfr_tc_exe_not_implemented(c
1172 1213 spw_ioctl_send.options = 0;
1173 1214
1174 1215 // SEND DATA
1175 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1216 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1217 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1218 if (status != RTEMS_SUCCESSFUL) {
1219 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1220 ret = LFR_DEFAULT;
1221 }
1176 1222
1177 1223 return LFR_SUCCESSFUL;
1178 1224 }
1179 1225
1180 1226 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC)
1181 1227 {
1228 int ret;
1182 1229 rtems_status_code status;
1183 1230 TMHeader_t TM_header;
1184 1231 char data[8];
@@ -1205,7 +1252,12 int send_tm_lfr_tc_exe_error(ccsdsTeleco
1205 1252 spw_ioctl_send.options = 0;
1206 1253
1207 1254 // SEND DATA
1208 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1255 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1256 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1257 if (status != RTEMS_SUCCESSFUL) {
1258 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1259 ret = LFR_DEFAULT;
1260 }
1209 1261
1210 1262 return LFR_SUCCESSFUL;
1211 1263 }
@@ -1,9 +1,13
1 1 #include <wf_handler.h>
2 2
3 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0_F1_F2[3][7];
3 // SWF
4 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
5 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
6 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
7 // CWF
4 8 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
5 9 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
6 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM1[7];
10 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
7 11 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
8 12
9 13 unsigned char doubleSendCWF1 = 0;
@@ -127,7 +131,19 rtems_isr waveforms_isr( rtems_vector_nu
127 131 #else
128 132 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
129 133 // (1) change the receiving buffer for the waveform picker
130 if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
134 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
135 {
136 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
137 }
138 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
139 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
140 doubleSendCWF2 = 1;
141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
143 }
144 reset_local_sbm2_nb_cwf_sent();
145 }
146 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
131 147 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
132 148 }
133 149 else {
@@ -144,8 +160,6 rtems_isr waveforms_isr( rtems_vector_nu
144 160 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
145 161 }
146 162 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
147 doubleSendCWF2 = 1;
148 reset_local_sbm2_nb_cwf_sent();
149 163 }
150 164 #endif
151 165 break;
@@ -183,9 +197,9 rtems_task wfrm_task(rtems_task_argument
183 197 {
184 198 rtems_event_set event_out;
185 199
186 init_header_snapshot_wf_table( SID_NORM_SWF_F0 );
187 init_header_snapshot_wf_table( SID_NORM_SWF_F1 );
188 init_header_snapshot_wf_table( SID_NORM_SWF_F2 );
200 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
201 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
202 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
189 203
190 204 init_waveforms();
191 205
@@ -193,36 +207,41 rtems_task wfrm_task(rtems_task_argument
193 207
194 208 while(1){
195 209 // wait for an RTEMS_EVENT
196 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
210 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
211 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
197 212 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
198 213
199 214 switch( event_out) {
200 215
201 case RTEMS_EVENT_MODE_NORMAL:
202 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0);
203 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1);
204 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2);
216 case RTEMS_EVENT_MODE_NORMAL:
217 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
218 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1);
219 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2);
205 220 #ifdef GSA
206 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
207 #endif
208 break;
209
210 case RTEMS_EVENT_MODE_SBM1:
211 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0);
212 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1);
213 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2);
214 #ifdef GSA
215 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
221 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
216 222 #endif
217 223 break;
218 224
219 case RTEMS_EVENT_MODE_SBM2:
220 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0);
221 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1);
225 case RTEMS_EVENT_MODE_SBM1:
226 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
227 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1);
228 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2);
222 229 #ifdef GSA
223 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
230 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
224 231 #endif
225 break;
232 break;
233
234 case RTEMS_EVENT_MODE_SBM2:
235 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
236 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1);
237 #ifdef GSA
238 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
239 #endif
240 break;
241
242 case RTEMS_EVENT_MODE_SBM2_WFRM:
243 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2);
244 break;
226 245
227 246 default:
228 247 break;
@@ -267,7 +286,7 rtems_task cwf2_task(rtems_task_argument
267 286 rtems_event_set event_out;
268 287
269 288 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
270 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM1 );
289 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
271 290
272 291 PRINTF("in CWF2 ***\n")
273 292
@@ -292,12 +311,18 rtems_task cwf2_task(rtems_task_argument
292 311 {
293 312 #ifdef GSA
294 313 #else
295 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
296 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM1 );
314 if (doubleSendCWF2 == 1)
315 {
316 doubleSendCWF2 = 0;
317 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
318 }
319 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
320 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
297 321 }
298 322 else {
299 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM1 );
323 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
300 324 }
325 param_local.local_sbm2_nb_cwf_sent ++;
301 326 #endif
302 327 }
303 328 else
@@ -378,77 +403,59 void init_waveforms( void )
378 403 }
379 404 }
380 405
381 int init_header_snapshot_wf_table( unsigned int sid)
406 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
382 407 {
383 408 unsigned char i;
384 unsigned char j;
385
386 j = 0;
387
388 switch(sid)
389 {
390 case SID_NORM_SWF_F0:
391 j = 0;
392 break;
393 case SID_NORM_SWF_F1:
394 j = 1;
395 break;
396 case SID_NORM_SWF_F2:
397 j = 2;
398 break;
399 default:
400 return LFR_DEFAULT;
401 }
402 409
403 410 for (i=0; i<7; i++)
404 411 {
405 headerSWF_F0_F1_F2[j][i].targetLogicalAddress = CCSDS_DESTINATION_ID;
406 headerSWF_F0_F1_F2[j][i].protocolIdentifier = CCSDS_PROTOCOLE_ID;
407 headerSWF_F0_F1_F2[j][i].reserved = DEFAULT_RESERVED;
408 headerSWF_F0_F1_F2[j][i].userApplication = CCSDS_USER_APP;
409 headerSWF_F0_F1_F2[j][i].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL >> 8);
410 headerSWF_F0_F1_F2[j][i].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL);
412 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
413 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
414 headerSWF[ i ].reserved = DEFAULT_RESERVED;
415 headerSWF[ i ].userApplication = CCSDS_USER_APP;
416 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
417 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
411 418 if (i == 0)
412 419 {
413 headerSWF_F0_F1_F2[j][i].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
414 headerSWF_F0_F1_F2[j][i].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
415 headerSWF_F0_F1_F2[j][i].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
416 headerSWF_F0_F1_F2[j][i].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
417 headerSWF_F0_F1_F2[j][i].blkNr[1] = (unsigned char) (BLK_NR_340 );
420 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
421 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
422 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
423 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
424 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
418 425 }
419 426 else if (i == 6)
420 427 {
421 headerSWF_F0_F1_F2[j][i].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
422 headerSWF_F0_F1_F2[j][i].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
423 headerSWF_F0_F1_F2[j][i].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
424 headerSWF_F0_F1_F2[j][i].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
425 headerSWF_F0_F1_F2[j][i].blkNr[1] = (unsigned char) (BLK_NR_8 );
428 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
429 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
430 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
431 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
432 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
426 433 }
427 434 else
428 435 {
429 headerSWF_F0_F1_F2[j][i].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
430 headerSWF_F0_F1_F2[j][i].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
431 headerSWF_F0_F1_F2[j][i].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
432 headerSWF_F0_F1_F2[j][i].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
433 headerSWF_F0_F1_F2[j][i].blkNr[1] = (unsigned char) (BLK_NR_340 );
436 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
437 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
438 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
439 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
440 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
434 441 }
435 headerSWF_F0_F1_F2[j][i].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
436 headerSWF_F0_F1_F2[j][i].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
437 headerSWF_F0_F1_F2[j][i].pktNr = i+1; // PKT_NR
442 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
443 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
444 headerSWF[ i ].pktNr = i+1; // PKT_NR
438 445 // DATA FIELD HEADER
439 headerSWF_F0_F1_F2[j][i].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
440 headerSWF_F0_F1_F2[j][i].serviceType = TM_TYPE_LFR_SCIENCE; // service type
441 headerSWF_F0_F1_F2[j][i].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
442 headerSWF_F0_F1_F2[j][i].destinationID = TM_DESTINATION_ID_GROUND;
446 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
447 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
448 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
449 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
443 450 // AUXILIARY DATA HEADER
444 headerSWF_F0_F1_F2[j][i].sid = sid;
445 headerSWF_F0_F1_F2[j][i].hkBIA = DEFAULT_HKBIA;
446 headerSWF_F0_F1_F2[j][i].time[0] = 0x00;
447 headerSWF_F0_F1_F2[j][i].time[0] = 0x00;
448 headerSWF_F0_F1_F2[j][i].time[0] = 0x00;
449 headerSWF_F0_F1_F2[j][i].time[0] = 0x00;
450 headerSWF_F0_F1_F2[j][i].time[0] = 0x00;
451 headerSWF_F0_F1_F2[j][i].time[0] = 0x00;
451 headerSWF[ i ].sid = sid;
452 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
453 headerSWF[ i ].time[0] = 0x00;
454 headerSWF[ i ].time[0] = 0x00;
455 headerSWF[ i ].time[0] = 0x00;
456 headerSWF[ i ].time[0] = 0x00;
457 headerSWF[ i ].time[0] = 0x00;
458 headerSWF[ i ].time[0] = 0x00;
452 459 }
453 460 return LFR_SUCCESSFUL;
454 461 }
@@ -463,8 +470,16 int init_header_continuous_wf_table( uns
463 470 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
464 471 headerCWF[ i ].reserved = DEFAULT_RESERVED;
465 472 headerCWF[ i ].userApplication = CCSDS_USER_APP;
466 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 >> 8);
467 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2);
473 if (SID_SBM1_CWF_F1 || SID_SBM2_CWF_F2)
474 {
475 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
476 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
477 }
478 else
479 {
480 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
481 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
482 }
468 483 if (i == 0)
469 484 {
470 485 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
@@ -540,10 +555,9 void reset_waveforms( void )
540 555 }
541 556 }
542 557
543 int send_waveform_SWF( volatile int *waveform, unsigned int sid )
558 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF )
544 559 {
545 560 unsigned int i;
546 unsigned int j;
547 561 int ret;
548 562 rtems_status_code status;
549 563 spw_ioctl_pkt_send spw_ioctl_send_SWF;
@@ -551,29 +565,12 int send_waveform_SWF( volatile int *wav
551 565 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
552 566 spw_ioctl_send_SWF.options = 0;
553 567
554 j = 0;
555 568 ret = LFR_DEFAULT;
556 569
557 switch(sid)
558 {
559 case SID_NORM_SWF_F0:
560 j = 0;
561 break;
562 case SID_NORM_SWF_F1:
563 j = 1;
564 break;
565 case SID_NORM_SWF_F2:
566 j = 2;
567 break;
568 default:
569 ret = LFR_DEFAULT;
570 break;
571 }
572
573 570 for (i=0; i<7; i++) // send waveform
574 571 {
575 572 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
576 spw_ioctl_send_SWF.hdr = (char*) &headerSWF_F0_F1_F2[j][i];
573 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
577 574 // BUILD THE DATA
578 575 if (i==6) {
579 576 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
@@ -582,23 +579,22 int send_waveform_SWF( volatile int *wav
582 579 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
583 580 }
584 581 // SET PACKET TIME
585 headerSWF_F0_F1_F2[j][i].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
586 headerSWF_F0_F1_F2[j][i].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
587 headerSWF_F0_F1_F2[j][i].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
588 headerSWF_F0_F1_F2[j][i].time[3] = (unsigned char) (time_management_regs->coarse_time);
589 headerSWF_F0_F1_F2[j][i].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
590 headerSWF_F0_F1_F2[j][i].time[5] = (unsigned char) (time_management_regs->fine_time);
591 headerSWF_F0_F1_F2[j][i].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
592 headerSWF_F0_F1_F2[j][i].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
593 headerSWF_F0_F1_F2[j][i].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
594 headerSWF_F0_F1_F2[j][i].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
595 headerSWF_F0_F1_F2[j][i].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
596 headerSWF_F0_F1_F2[j][i].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
582 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
583 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
584 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
585 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
586 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
587 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
588 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
589 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
590 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
591 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
592 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
593 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
597 594 // SEND PACKET
598 //status = write_spw(&spw_ioctl_send_SWF);
599 status = rtems_message_queue_send( misc_id[1], &spw_ioctl_send_SWF, sizeof(spw_ioctl_send_SWF));
595 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send_SWF, ACTION_MSG_PKTS_SIZE);
600 596 if (status != RTEMS_SUCCESSFUL) {
601 PRINTF2("sid %d, i = %d\n", sid, i)
597 printf("%d-%d, ERR %d\n", sid, i, (int) status);
602 598 ret = LFR_DEFAULT;
603 599 }
604 600 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
@@ -648,19 +644,22 int send_waveform_CWF( volatile int *wav
648 644 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
649 645 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
650 646 // SEND PACKET
651 //status = write_spw(&spw_ioctl_send_CWF);
652 status = rtems_message_queue_urgent( misc_id[1], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
653 if (status != RTEMS_SUCCESSFUL) {
654 PRINTF2("sid %d, i = %d\n", sid, i)
655 ret = LFR_DEFAULT;
647 if (sid == SID_NORM_CWF_F3)
648 {
649 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
650 if (status != RTEMS_SUCCESSFUL) {
651 printf("%d-%d, ERR %d\n", sid, i, (int) status);
652 ret = LFR_DEFAULT;
653 }
654 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
656 655 }
657 656 else
658 657 {
659 sched_yield();
660 }
661 if (sid == SID_NORM_CWF_F3)
662 {
663 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
658 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
659 if (status != RTEMS_SUCCESSFUL) {
660 printf("%d-%d, ERR %d\n", sid, i, (int) status);
661 ret = LFR_DEFAULT;
662 }
664 663 }
665 664 }
666 665
@@ -786,19 +785,16 void reset_waveform_picker_regs()
786 785 void set_local_sbm1_nb_cwf_max()
787 786 {
788 787 // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
789 param_local.local_sbm1_nb_cwf_max = 2 * (
790 parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
791 + parameter_dump_packet.sy_lfr_n_swf_p[1]
792 ) - 8; // 16 CWF1 parts during 1 SWF2
788 param_local.local_sbm1_nb_cwf_max = 2 *
789 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
790 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
793 791 }
794 792
795 793 void set_local_sbm2_nb_cwf_max()
796 794 {
797 795 // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
798 param_local.local_sbm2_nb_cwf_max = (
799 parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
800 + parameter_dump_packet.sy_lfr_n_swf_p[1]
801 )/ 8;
796 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
797 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
802 798 }
803 799
804 800 void set_local_nb_interrupt_f0_MAX()
General Comments 0
You need to be logged in to leave comments. Login now