##// END OF EJS Templates
Creation of a spool task (SPOO) to handle
paul -
r165:c9daaae78ba2 spool
parent child
Show More
@@ -0,0 +1,64
1 #ifndef FSW_SPOOL_H_INCLUDED
2 #define FSW_SPOOL_H_INCLUDED
3
4 #include <rtems.h>
5 #include <stdio.h>
6
7 #include "fsw_params.h"
8 #include "fsw_processing.h"
9
10 rtems_name name_spool_rate_monotonic; // name of the SPOOL rate monotonic
11 rtems_id spool_period_id; // id of the SPOOL rate monotonic period
12
13 extern unsigned char lfrCurrentMode;
14
15 extern waveform_picker_regs_new_t *waveform_picker_regs;
16 extern spectral_matrix_regs_t *spectral_matrix_regs;
17
18 // WAVEFORMS
19 extern ring_node *current_ring_node_f0;
20 extern ring_node *ring_node_to_send_swf_f0;
21 extern ring_node *current_ring_node_f1;
22 extern ring_node *ring_node_to_send_swf_f1;
23 extern ring_node *ring_node_to_send_cwf_f1;
24 extern ring_node *current_ring_node_f2;
25 extern ring_node *ring_node_to_send_swf_f2;
26 extern ring_node *ring_node_to_send_cwf_f2;
27 extern ring_node *current_ring_node_f3;
28 extern ring_node *ring_node_to_send_cwf_f3;
29
30 // SPECTRAL MATRICES
31 unsigned int spool_nb_sm_f0;
32 unsigned int spool_nb_sm_f1;
33 extern ring_node_sm *current_ring_node_sm_f0;
34 extern ring_node_sm *current_ring_node_sm_f1;
35 extern ring_node_sm *current_ring_node_sm_f2;
36 extern ring_node_sm *ring_node_for_averaging_sm_f0;
37 extern ring_node_sm *ring_node_for_averaging_sm_f1;
38 extern ring_node_sm *ring_node_for_averaging_sm_f2;
39
40 extern rtems_id Task_id[]; /* array of task ids */
41
42 extern bool swf_f0_ready;
43 extern bool swf_f1_ready;
44 extern bool swf_f2_ready;
45
46 extern bool wake_up_task_wfrm;
47 extern bool wake_up_task_cwf_f1;
48 extern bool wake_up_task_cwf_f2_burst;
49 extern bool wake_up_task_cwf_f2_sbm2;
50 extern bool wake_up_task_cwf_f3;
51
52 //***********
53 // RTEMS_TASK
54 rtems_task spoo_task( rtems_task_argument argument );
55
56 // OTHER FUNCTIONS
57 void spool_waveforms( void );
58 void spool_spectral_matrices_f0( void );
59 void spool_spectral_matrices_f1( void );
60 void spool_spectral_matrices_f2( void );
61 void spool_spectral_matrices( void );
62 void spool_reset_nb_sm( void );
63
64 #endif // FSW_SPOOL_H_INCLUDED
@@ -0,0 +1,276
1 /** Functions and tasks related to waveform packet generation.
2 *
3 * @file
4 * @author P. LEROY
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
8 */
9
10 #include "fsw_spool.h"
11
12 //*********************
13 // Interrupt SubRoutine
14
15 void spool_waveforms( void )
16 {
17 /** This is the interrupt sub routine called by the waveform picker core.
18 *
19 * This ISR launch different actions depending mainly on two pieces of information:
20 * 1. the values read in the registers of the waveform picker.
21 * 2. the current LFR mode.
22 *
23 */
24
25 rtems_status_code status;
26
27 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
28 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
29 { // in modes other than STANDBY and BURST, send the CWF_F3 data
30 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
31 // (1) change the receiving buffer for the waveform picker
32 ring_node_to_send_cwf_f3 = current_ring_node_f3;
33 current_ring_node_f3 = current_ring_node_f3->next;
34 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
35 // (2) send an event for the waveforms transmission
36 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
37 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
38 }
39 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
40 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
41 }
42 }
43
44 switch(lfrCurrentMode)
45 {
46 //********
47 // STANDBY
48 case(LFR_MODE_STANDBY):
49 break;
50
51 //******
52 // NORMAL
53 case(LFR_MODE_NORMAL):
54 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
55 {
56 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
57 }
58 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
59 {
60 // change F0 ring node
61 ring_node_to_send_swf_f0 = current_ring_node_f0;
62 current_ring_node_f0 = current_ring_node_f0->next;
63 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
64 // change F1 ring node
65 ring_node_to_send_swf_f1 = current_ring_node_f1;
66 current_ring_node_f1 = current_ring_node_f1->next;
67 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
68 // change F2 ring node
69 ring_node_to_send_swf_f2 = current_ring_node_f2;
70 current_ring_node_f2 = current_ring_node_f2->next;
71 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
72 //
73 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
74 {
75 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
76 }
77 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
78 }
79 break;
80
81 //******
82 // BURST
83 case(LFR_MODE_BURST):
84 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
85 // (1) change the receiving buffer for the waveform picker
86 ring_node_to_send_cwf_f2 = current_ring_node_f2;
87 current_ring_node_f2 = current_ring_node_f2->next;
88 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
89 // (2) send an event for the waveforms transmission
90 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
91 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
92 }
93 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
94 }
95 break;
96
97 //*****
98 // SBM1
99 case(LFR_MODE_SBM1):
100 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
101 // (1) change the receiving buffer for the waveform picker
102 ring_node_to_send_cwf_f1 = current_ring_node_f1;
103 current_ring_node_f1 = current_ring_node_f1->next;
104 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
105 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
106 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
107 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
108 }
109 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
110 swf_f0_ready = true;
111 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
112 }
113 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
114 swf_f2_ready = true;
115 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
116 }
117 break;
118
119 //*****
120 // SBM2
121 case(LFR_MODE_SBM2):
122 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
123 // (1) change the receiving buffer for the waveform picker
124 ring_node_to_send_cwf_f2 = current_ring_node_f2;
125 current_ring_node_f2 = current_ring_node_f2->next;
126 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
127 // (2) send an event for the waveforms transmission
128 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
129 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
130 }
131 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
132 swf_f0_ready = true;
133 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
134 }
135 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
136 swf_f1_ready = true;
137 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
138 }
139 break;
140
141 //********
142 // DEFAULT
143 default:
144 break;
145 }
146 }
147
148 void spool_waveforms_alt( void )
149 {
150 // WFRM
151 if (wake_up_task_wfrm == true)
152 {
153 rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
154 wake_up_task_wfrm = false;
155 }
156 // CWF_F1
157 if (wake_up_task_cwf_f1 == true)
158 {
159 rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
160 wake_up_task_cwf_f1 = false;
161 }
162 // CWF_F2 BURST
163 if (wake_up_task_cwf_f2_burst == true)
164 {
165 rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST );
166 wake_up_task_cwf_f2_burst = false;
167 }
168 // CWF_F2 SBM2
169 if (wake_up_task_cwf_f2_sbm2 == true)
170 {
171 rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
172 wake_up_task_cwf_f2_sbm2 = false;
173 }
174 // CWF_F3
175 if (wake_up_task_cwf_f3 == true)
176 {
177 rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 );
178 wake_up_task_cwf_f3 = false;
179 }
180 }
181
182 void spool_spectral_matrices( void )
183 {
184 // STATUS REGISTER
185 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
186 // 10 9 8
187 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
188 // 7 6 5 4 3 2 1 0
189
190 unsigned char status_f0;
191 unsigned char status_f1;
192 unsigned char status_f2;
193 static unsigned int counter = 0;
194
195 rtems_interrupt_level level;
196
197 rtems_interrupt_disable( level );
198
199 status_f0 = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
200 status_f1 = (spectral_matrix_regs->status & 0x0c) >> 2; // [0011] get the status_ready_matrix_f0_x bits
201 status_f2 = (spectral_matrix_regs->status & 0x30) >> 4; // [0011] get the status_ready_matrix_f0_x bits
202
203 // if ( status_f0 == 0x03)
204 // {
205 // printf("%d \n", counter);
206 // }
207 if ( status_f1 == 0x03)
208 {
209 printf("f1 %d \n", counter);
210 }
211 if ( status_f2 == 0x03)
212 {
213 printf("f2 %d \n", counter);
214 }
215
216 spectral_matrices_isr_f0();
217
218 spectral_matrices_isr_f1();
219
220 spectral_matrices_isr_f2();
221
222 spectral_matrix_isr_error_handler();
223
224 rtems_interrupt_enable( level );
225
226 counter = counter + 1;
227 }
228
229 //************
230 // RTEMS TASKS
231
232 rtems_task spoo_task(rtems_task_argument argument)
233 {
234 rtems_status_code status;
235
236 BOOT_PRINTF("in SPOOL ***\n")
237
238 if (rtems_rate_monotonic_ident( name_spool_rate_monotonic, &spool_period_id) != RTEMS_SUCCESSFUL) {
239 status = rtems_rate_monotonic_create( name_spool_rate_monotonic, &spool_period_id );
240 if( status != RTEMS_SUCCESSFUL ) {
241 PRINTF1( "in SPOO *** rtems_rate_monotonic_create failed with status %d\n", status )
242 }
243 }
244
245 status = rtems_rate_monotonic_cancel( spool_period_id );
246 if( status != RTEMS_SUCCESSFUL )
247 {
248 PRINTF1( "ERR *** in SPOOL *** rtems_rate_monotonic_cancel(spool_period_id) ***code: %d\n", status )
249 }
250 else
251 {
252 DEBUG_PRINTF("OK *** in SPOOL *** rtems_rate_monotonic_cancel(spool_period_id)\n")
253 }
254
255 while(1){ // launch the rate monotonic task
256 // status = rtems_rate_monotonic_period( spool_period_id, SPOOL_TIMEOUT_in_ticks );
257 rtems_task_wake_after( SPOOL_TIMEOUT_in_ticks / 2 );
258 spool_waveforms_alt();
259 spool_spectral_matrices();
260 // if ( status != RTEMS_SUCCESSFUL )
261 // {
262 // PRINTF1( "in SPOOL *** ERR period: %d\n", status);
263 // }
264 // else
265 // {
266 // spool_waveforms();
267 // spool_spectral_matrices();
268 // }
269 }
270
271 PRINTF("in SPOOL *** deleting task\n")
272
273 status = rtems_task_delete( RTEMS_SELF ); // should not return
274 printf( "rtems_task_delete returned with status of %d.\n", status );
275 return;
276 }
@@ -1,273 +1,278
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: Thu Jul 17 15:49:45 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
7 #############################################################################
7 #############################################################################
8
8
9 ####### Compiler, tools and options
9 ####### Compiler, tools and options
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 -DPRINT_TASK_STATISTICS -DFAST_SCHEDULER
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
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
23 TAR = tar -cf
23 TAR = tar -cf
24 COMPRESS = gzip -9f
24 COMPRESS = gzip -9f
25 COPY = cp -f
25 COPY = cp -f
26 SED = sed
26 SED = sed
27 COPY_FILE = $(COPY)
27 COPY_FILE = $(COPY)
28 COPY_DIR = $(COPY) -r
28 COPY_DIR = $(COPY) -r
29 STRIP = sparc-rtems-strip
29 STRIP = sparc-rtems-strip
30 INSTALL_FILE = install -m 644 -p
30 INSTALL_FILE = install -m 644 -p
31 INSTALL_DIR = $(COPY_DIR)
31 INSTALL_DIR = $(COPY_DIR)
32 INSTALL_PROGRAM = install -m 755 -p
32 INSTALL_PROGRAM = install -m 755 -p
33 DEL_FILE = rm -f
33 DEL_FILE = rm -f
34 SYMLINK = ln -f -s
34 SYMLINK = ln -f -s
35 DEL_DIR = rmdir
35 DEL_DIR = rmdir
36 MOVE = mv -f
36 MOVE = mv -f
37 CHK_DIR_EXISTS= test -d
37 CHK_DIR_EXISTS= test -d
38 MKDIR = mkdir -p
38 MKDIR = mkdir -p
39
39
40 ####### Output directory
40 ####### Output directory
41
41
42 OBJECTS_DIR = obj/
42 OBJECTS_DIR = obj/
43
43
44 ####### Files
44 ####### Files
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_misc.c \
48 ../src/fsw_misc.c \
49 ../src/fsw_init.c \
49 ../src/fsw_init.c \
50 ../src/fsw_globals.c \
50 ../src/fsw_globals.c \
51 ../src/fsw_spacewire.c \
51 ../src/fsw_spacewire.c \
52 ../src/tc_load_dump_parameters.c \
52 ../src/tc_load_dump_parameters.c \
53 ../src/tm_lfr_tc_exe.c \
53 ../src/tm_lfr_tc_exe.c \
54 ../src/tc_acceptance.c \
54 ../src/tc_acceptance.c \
55 ../src/processing/fsw_processing.c \
55 ../src/processing/fsw_processing.c \
56 ../src/processing/avf0_prc0.c \
56 ../src/processing/avf0_prc0.c \
57 ../src/processing/avf1_prc1.c \
57 ../src/processing/avf1_prc1.c \
58 ../src/processing/avf2_prc2.c \
58 ../src/processing/avf2_prc2.c \
59 ../src/lfr_cpu_usage_report.c \
59 ../src/lfr_cpu_usage_report.c \
60 ../src/LFR_basic-parameters/basic_parameters.c
60 ../src/LFR_basic-parameters/basic_parameters.c \
61 ../src/fsw_spool.c
61 OBJECTS = obj/wf_handler.o \
62 OBJECTS = obj/wf_handler.o \
62 obj/tc_handler.o \
63 obj/tc_handler.o \
63 obj/fsw_misc.o \
64 obj/fsw_misc.o \
64 obj/fsw_init.o \
65 obj/fsw_init.o \
65 obj/fsw_globals.o \
66 obj/fsw_globals.o \
66 obj/fsw_spacewire.o \
67 obj/fsw_spacewire.o \
67 obj/tc_load_dump_parameters.o \
68 obj/tc_load_dump_parameters.o \
68 obj/tm_lfr_tc_exe.o \
69 obj/tm_lfr_tc_exe.o \
69 obj/tc_acceptance.o \
70 obj/tc_acceptance.o \
70 obj/fsw_processing.o \
71 obj/fsw_processing.o \
71 obj/avf0_prc0.o \
72 obj/avf0_prc0.o \
72 obj/avf1_prc1.o \
73 obj/avf1_prc1.o \
73 obj/avf2_prc2.o \
74 obj/avf2_prc2.o \
74 obj/lfr_cpu_usage_report.o \
75 obj/lfr_cpu_usage_report.o \
75 obj/basic_parameters.o
76 obj/basic_parameters.o \
77 obj/fsw_spool.o
76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
78 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 /usr/lib64/qt4/mkspecs/common/linux.conf \
79 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
80 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
81 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
82 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
83 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 /usr/lib64/qt4/mkspecs/qconfig.pri \
84 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
85 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
86 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
87 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
88 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
89 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 sparc.pri \
90 sparc.pri \
89 /usr/lib64/qt4/mkspecs/features/release.prf \
91 /usr/lib64/qt4/mkspecs/features/release.prf \
90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
92 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 /usr/lib64/qt4/mkspecs/features/shared.prf \
93 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
94 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
95 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 /usr/lib64/qt4/mkspecs/features/resources.prf \
96 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 /usr/lib64/qt4/mkspecs/features/uic.prf \
97 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
98 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 /usr/lib64/qt4/mkspecs/features/lex.prf \
99 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
100 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 fsw-qt.pro
101 fsw-qt.pro
100 QMAKE_TARGET = fsw
102 QMAKE_TARGET = fsw
101 DESTDIR = bin/
103 DESTDIR = bin/
102 TARGET = bin/fsw
104 TARGET = bin/fsw
103
105
104 first: all
106 first: all
105 ####### Implicit rules
107 ####### Implicit rules
106
108
107 .SUFFIXES: .o .c .cpp .cc .cxx .C
109 .SUFFIXES: .o .c .cpp .cc .cxx .C
108
110
109 .cpp.o:
111 .cpp.o:
110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111
113
112 .cc.o:
114 .cc.o:
113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
115 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114
116
115 .cxx.o:
117 .cxx.o:
116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
118 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117
119
118 .C.o:
120 .C.o:
119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
121 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120
122
121 .c.o:
123 .c.o:
122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
124 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123
125
124 ####### Build rules
126 ####### Build rules
125
127
126 all: Makefile $(TARGET)
128 all: Makefile $(TARGET)
127
129
128 $(TARGET): $(OBJECTS)
130 $(TARGET): $(OBJECTS)
129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
131 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
132 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131
133
132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
134 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 /usr/lib64/qt4/mkspecs/common/linux.conf \
135 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
136 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
137 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
138 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
139 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 /usr/lib64/qt4/mkspecs/qconfig.pri \
140 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
141 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
142 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
143 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
144 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
145 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 sparc.pri \
146 sparc.pri \
145 /usr/lib64/qt4/mkspecs/features/release.prf \
147 /usr/lib64/qt4/mkspecs/features/release.prf \
146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
148 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 /usr/lib64/qt4/mkspecs/features/shared.prf \
149 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
150 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
151 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 /usr/lib64/qt4/mkspecs/features/resources.prf \
152 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 /usr/lib64/qt4/mkspecs/features/uic.prf \
153 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
154 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 /usr/lib64/qt4/mkspecs/features/lex.prf \
155 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
156 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
157 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 /usr/lib64/qt4/mkspecs/common/unix.conf:
158 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 /usr/lib64/qt4/mkspecs/common/linux.conf:
159 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
160 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
161 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
162 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
163 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 /usr/lib64/qt4/mkspecs/qconfig.pri:
164 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
165 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
166 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
167 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
168 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
169 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 sparc.pri:
170 sparc.pri:
169 /usr/lib64/qt4/mkspecs/features/release.prf:
171 /usr/lib64/qt4/mkspecs/features/release.prf:
170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
172 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 /usr/lib64/qt4/mkspecs/features/shared.prf:
173 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
174 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
175 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 /usr/lib64/qt4/mkspecs/features/resources.prf:
176 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 /usr/lib64/qt4/mkspecs/features/uic.prf:
177 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
178 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 /usr/lib64/qt4/mkspecs/features/lex.prf:
179 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
180 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 qmake: FORCE
181 qmake: FORCE
180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
182 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181
183
182 dist:
184 dist:
183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
185 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
186 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185
187
186
188
187 clean:compiler_clean
189 clean:compiler_clean
188 -$(DEL_FILE) $(OBJECTS)
190 -$(DEL_FILE) $(OBJECTS)
189 -$(DEL_FILE) *~ core *.core
191 -$(DEL_FILE) *~ core *.core
190
192
191
193
192 ####### Sub-libraries
194 ####### Sub-libraries
193
195
194 distclean: clean
196 distclean: clean
195 -$(DEL_FILE) $(TARGET)
197 -$(DEL_FILE) $(TARGET)
196 -$(DEL_FILE) Makefile
198 -$(DEL_FILE) Makefile
197
199
198
200
199 grmon:
201 grmon:
200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
202 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201
203
202 check: first
204 check: first
203
205
204 compiler_rcc_make_all:
206 compiler_rcc_make_all:
205 compiler_rcc_clean:
207 compiler_rcc_clean:
206 compiler_uic_make_all:
208 compiler_uic_make_all:
207 compiler_uic_clean:
209 compiler_uic_clean:
208 compiler_image_collection_make_all: qmake_image_collection.cpp
210 compiler_image_collection_make_all: qmake_image_collection.cpp
209 compiler_image_collection_clean:
211 compiler_image_collection_clean:
210 -$(DEL_FILE) qmake_image_collection.cpp
212 -$(DEL_FILE) qmake_image_collection.cpp
211 compiler_yacc_decl_make_all:
213 compiler_yacc_decl_make_all:
212 compiler_yacc_decl_clean:
214 compiler_yacc_decl_clean:
213 compiler_yacc_impl_make_all:
215 compiler_yacc_impl_make_all:
214 compiler_yacc_impl_clean:
216 compiler_yacc_impl_clean:
215 compiler_lex_make_all:
217 compiler_lex_make_all:
216 compiler_lex_clean:
218 compiler_lex_clean:
217 compiler_clean:
219 compiler_clean:
218
220
219 ####### Compile
221 ####### Compile
220
222
221 obj/wf_handler.o: ../src/wf_handler.c
223 obj/wf_handler.o: ../src/wf_handler.c
222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223
225
224 obj/tc_handler.o: ../src/tc_handler.c
226 obj/tc_handler.o: ../src/tc_handler.c
225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
227 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226
228
227 obj/fsw_misc.o: ../src/fsw_misc.c
229 obj/fsw_misc.o: ../src/fsw_misc.c
228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
230 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229
231
230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
232 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
233 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232
234
233 obj/fsw_globals.o: ../src/fsw_globals.c
235 obj/fsw_globals.o: ../src/fsw_globals.c
234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235
237
236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
238 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238
240
239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
241 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
242 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241
243
242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
244 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
245 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244
246
245 obj/tc_acceptance.o: ../src/tc_acceptance.c
247 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
248 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247
249
248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
250 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
251 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250
252
251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
253 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
254 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253
255
254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
256 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
257 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256
258
257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
259 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
260 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259
261
260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
262 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
263 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262
264
263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
265 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
266 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265
267
268 obj/fsw_spool.o: ../src/fsw_spool.c
269 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spool.o ../src/fsw_spool.c
270
266 ####### Install
271 ####### Install
267
272
268 install: FORCE
273 install: FORCE
269
274
270 uninstall: FORCE
275 uninstall: FORCE
271
276
272 FORCE:
277 FORCE:
273
278
@@ -1,21 +1,20
1 SREC_PREFIX = RpwLfrApp
1 SREC_PREFIX = RpwLfrApp
2 SREC_COUNTER_TEXT = 0003
2 SREC_COUNTER = 0003
3 SREC_COUNTER_DATA = 0004
3 SREC_FSW_REF = rev-2-0-1-0
4 SREC_FSW_REF = rev-1-0-0-7
5 SREC_SUFFIX = .srec
4 SREC_SUFFIX = .srec
6 SREC_TEXT = $(SREC_PREFIX)_$(SREC_COUNTER_TEXT)_text_$(SREC_FSW_REF)$(SREC_SUFFIX)
5 SREC_TEXT = $(SREC_PREFIX)_$(SREC_COUNTER)_text_$(SREC_FSW_REF)$(SREC_SUFFIX)
7 SREC_DATA = $(SREC_PREFIX)_$(SREC_COUNTER_DATA)_data_$(SREC_FSW_REF)$(SREC_SUFFIX)
6 SREC_DATA = $(SREC_PREFIX)_$(SREC_COUNTER)_data_$(SREC_FSW_REF)$(SREC_SUFFIX)
8 OBJCOPY = sparc-rtems-objcopy
7 OBJCOPY = sparc-rtems-objcopy
9 OBJCOPY_OPT = -g -v
8 OBJCOPY_OPT = -g -v
10
9
11 all: text data
10 all: text data
12
11
13 text: fsw
12 text: fsw
14 $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_TEXT) -O srec -j .text
13 $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_TEXT) -O srec -j .text
15
14
16 data: fsw
15 data: fsw
17 $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_DATA) -O srec -j .data
16 $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_DATA) -O srec -j .data
18
17
19 clean:
18 clean:
20 rm *.srec
19 rm *.srec
21
20
@@ -1,95 +1,101
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose
4 CONFIG += console verbose fast_scheduler cpu_usage_report
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-1-0
10 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
18 }
18 }
19
19
20 contains( CONFIG, vhdl_dev ) {
20 contains( CONFIG, vhdl_dev ) {
21 DEFINES += VHDL_DEV
21 DEFINES += VHDL_DEV
22 }
22 }
23
23
24 contains( CONFIG, verbose ) {
24 contains( CONFIG, verbose ) {
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 }
26 }
27
27
28 contains( CONFIG, debug_messages ) {
28 contains( CONFIG, debug_messages ) {
29 DEFINES += DEBUG_MESSAGES
29 DEFINES += DEBUG_MESSAGES
30 }
30 }
31
31
32 contains( CONFIG, cpu_usage_report ) {
32 contains( CONFIG, cpu_usage_report ) {
33 DEFINES += PRINT_TASK_STATISTICS
33 DEFINES += PRINT_TASK_STATISTICS
34 }
34 }
35
35
36 contains( CONFIG, stack_report ) {
36 contains( CONFIG, stack_report ) {
37 DEFINES += PRINT_STACK_REPORT
37 DEFINES += PRINT_STACK_REPORT
38 }
38 }
39
39
40 contains( CONFIG, boot_messages ) {
40 contains( CONFIG, boot_messages ) {
41 DEFINES += BOOT_MESSAGES
41 DEFINES += BOOT_MESSAGES
42 }
42 }
43
43
44 contains( CONFIG, fast_scheduler ) {
45 DEFINES += FAST_SCHEDULER
46 }
47
44 #doxygen.target = doxygen
48 #doxygen.target = doxygen
45 #doxygen.commands = doxygen ../doc/Doxyfile
49 #doxygen.commands = doxygen ../doc/Doxyfile
46 #QMAKE_EXTRA_TARGETS += doxygen
50 #QMAKE_EXTRA_TARGETS += doxygen
47
51
48 TARGET = fsw
52 TARGET = fsw
49
53
50 INCLUDEPATH += \
54 INCLUDEPATH += \
51 ../src \
55 ../src \
52 ../header \
56 ../header \
53 ../header/processing \
57 ../header/processing \
54 ../src/LFR_basic-parameters
58 ../src/LFR_basic-parameters
55
59
56 SOURCES += \
60 SOURCES += \
57 ../src/wf_handler.c \
61 ../src/wf_handler.c \
58 ../src/tc_handler.c \
62 ../src/tc_handler.c \
59 ../src/fsw_misc.c \
63 ../src/fsw_misc.c \
60 ../src/fsw_init.c \
64 ../src/fsw_init.c \
61 ../src/fsw_globals.c \
65 ../src/fsw_globals.c \
62 ../src/fsw_spacewire.c \
66 ../src/fsw_spacewire.c \
63 ../src/tc_load_dump_parameters.c \
67 ../src/tc_load_dump_parameters.c \
64 ../src/tm_lfr_tc_exe.c \
68 ../src/tm_lfr_tc_exe.c \
65 ../src/tc_acceptance.c \
69 ../src/tc_acceptance.c \
66 ../src/processing/fsw_processing.c \
70 ../src/processing/fsw_processing.c \
67 ../src/processing/avf0_prc0.c \
71 ../src/processing/avf0_prc0.c \
68 ../src/processing/avf1_prc1.c \
72 ../src/processing/avf1_prc1.c \
69 ../src/processing/avf2_prc2.c \
73 ../src/processing/avf2_prc2.c \
70 ../src/lfr_cpu_usage_report.c \
74 ../src/lfr_cpu_usage_report.c \
71 ../src/LFR_basic-parameters/basic_parameters.c
75 ../src/LFR_basic-parameters/basic_parameters.c \
76 ../src/fsw_spool.c
72
77
73 HEADERS += \
78 HEADERS += \
74 ../header/wf_handler.h \
79 ../header/wf_handler.h \
75 ../header/tc_handler.h \
80 ../header/tc_handler.h \
76 ../header/grlib_regs.h \
81 ../header/grlib_regs.h \
77 ../header/fsw_params.h \
82 ../header/fsw_params.h \
78 ../header/fsw_misc.h \
83 ../header/fsw_misc.h \
79 ../header/fsw_init.h \
84 ../header/fsw_init.h \
80 ../header/ccsds_types.h \
85 ../header/ccsds_types.h \
81 ../header/fsw_spacewire.h \
86 ../header/fsw_spacewire.h \
82 ../header/tc_load_dump_parameters.h \
87 ../header/tc_load_dump_parameters.h \
83 ../header/tm_lfr_tc_exe.h \
88 ../header/tm_lfr_tc_exe.h \
84 ../header/tc_acceptance.h \
89 ../header/tc_acceptance.h \
85 ../header/fsw_params_nb_bytes.h \
90 ../header/fsw_params_nb_bytes.h \
86 ../header/fsw_params_processing.h \
91 ../header/fsw_params_processing.h \
87 ../header/processing/fsw_processing.h \
92 ../header/processing/fsw_processing.h \
88 ../header/processing/avf0_prc0.h \
93 ../header/processing/avf0_prc0.h \
89 ../header/processing/avf1_prc1.h \
94 ../header/processing/avf1_prc1.h \
90 ../header/processing/avf2_prc2.h \
95 ../header/processing/avf2_prc2.h \
91 ../header/fsw_params_wf_handler.h \
96 ../header/fsw_params_wf_handler.h \
92 ../header/lfr_cpu_usage_report.h \
97 ../header/lfr_cpu_usage_report.h \
93 ../src/LFR_basic-parameters/basic_parameters.h \
98 ../src/LFR_basic-parameters/basic_parameters.h \
94 ../src/LFR_basic-parameters/basic_parameters_params.h
99 ../src/LFR_basic-parameters/basic_parameters_params.h \
100 ../header/fsw_spool.h
95
101
@@ -1,201 +1,204
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.1.2, 2014-08-28T14:53:30. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">0</value>
7 <value type="int">0</value>
8 </data>
8 </data>
9 <data>
9 <data>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 <valuemap type="QVariantMap">
11 <valuemap type="QVariantMap">
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 <value type="QString" key="language">Cpp</value>
16 <value type="QString" key="language">Cpp</value>
17 <valuemap type="QVariantMap" key="value">
17 <valuemap type="QVariantMap" key="value">
18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 </valuemap>
19 </valuemap>
20 </valuemap>
20 </valuemap>
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 <value type="QString" key="language">QmlJS</value>
22 <value type="QString" key="language">QmlJS</value>
23 <valuemap type="QVariantMap" key="value">
23 <valuemap type="QVariantMap" key="value">
24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 </valuemap>
25 </valuemap>
26 </valuemap>
26 </valuemap>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 <value type="int" key="EditorConfiguration.MarginColumn">80</value>
33 <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
34 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
35 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
36 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
37 <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
38 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
39 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
40 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
41 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
42 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
43 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
44 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
45 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
46 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
47 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 </valuemap>
48 </valuemap>
46 </data>
49 </data>
47 <data>
50 <data>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
51 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 <valuemap type="QVariantMap"/>
52 <valuemap type="QVariantMap"/>
50 </data>
53 </data>
51 <data>
54 <data>
52 <variable>ProjectExplorer.Project.Target.0</variable>
55 <variable>ProjectExplorer.Project.Target.0</variable>
53 <valuemap type="QVariantMap">
56 <valuemap type="QVariantMap">
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
57 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
58 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
59 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
60 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
61 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
62 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
63 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
64 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
65 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
66 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
67 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
68 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
69 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
70 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
71 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
72 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
73 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
74 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 </valuemap>
75 </valuemap>
73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
76 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
77 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
78 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
79 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
80 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
81 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 <value type="QString">-w</value>
82 <value type="QString">-w</value>
80 <value type="QString">-r</value>
83 <value type="QString">-r</value>
81 </valuelist>
84 </valuelist>
82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
85 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
86 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
87 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 </valuemap>
88 </valuemap>
86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
89 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
90 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
91 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
92 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 </valuemap>
93 </valuemap>
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
94 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
95 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
96 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
97 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
98 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
99 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
100 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 <value type="QString">-w</value>
101 <value type="QString">-w</value>
99 <value type="QString">-r</value>
102 <value type="QString">-r</value>
100 </valuelist>
103 </valuelist>
101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
104 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
105 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
106 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 </valuemap>
107 </valuemap>
105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
108 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
109 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
110 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
111 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 </valuemap>
112 </valuemap>
110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
113 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
114 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
115 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
116 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
117 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
118 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
119 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
120 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 </valuemap>
121 </valuemap>
119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
122 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
123 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
124 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
125 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
126 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
127 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 </valuemap>
129 </valuemap>
127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
130 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
132 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 </valuemap>
134 </valuemap>
132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
135 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
136 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
137 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
138 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
139 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
140 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
141 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
142 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
143 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
144 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
145 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
146 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
147 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
148 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
149 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
150 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
151 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
152 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
153 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
154 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
155 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 <value type="int">0</value>
156 <value type="int">0</value>
154 <value type="int">1</value>
157 <value type="int">1</value>
155 <value type="int">2</value>
158 <value type="int">2</value>
156 <value type="int">3</value>
159 <value type="int">3</value>
157 <value type="int">4</value>
160 <value type="int">4</value>
158 <value type="int">5</value>
161 <value type="int">5</value>
159 <value type="int">6</value>
162 <value type="int">6</value>
160 <value type="int">7</value>
163 <value type="int">7</value>
161 <value type="int">8</value>
164 <value type="int">8</value>
162 <value type="int">9</value>
165 <value type="int">9</value>
163 <value type="int">10</value>
166 <value type="int">10</value>
164 <value type="int">11</value>
167 <value type="int">11</value>
165 <value type="int">12</value>
168 <value type="int">12</value>
166 <value type="int">13</value>
169 <value type="int">13</value>
167 <value type="int">14</value>
170 <value type="int">14</value>
168 </valuelist>
171 </valuelist>
169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
172 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
173 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
174 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
175 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
176 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
177 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
179 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
180 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
181 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
182 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
183 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
184 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
185 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
186 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
187 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 </valuemap>
188 </valuemap>
186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
189 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 </valuemap>
190 </valuemap>
188 </data>
191 </data>
189 <data>
192 <data>
190 <variable>ProjectExplorer.Project.TargetCount</variable>
193 <variable>ProjectExplorer.Project.TargetCount</variable>
191 <value type="int">1</value>
194 <value type="int">1</value>
192 </data>
195 </data>
193 <data>
196 <data>
194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
197 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
198 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
196 </data>
199 </data>
197 <data>
200 <data>
198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
201 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 <value type="int">15</value>
202 <value type="int">15</value>
200 </data>
203 </data>
201 </qtcreator>
204 </qtcreator>
@@ -1,48 +1,49
1 #ifndef FSW_INIT_H_INCLUDED
1 #ifndef FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
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"
9 #include "fsw_processing.h"
10
10
11 #include "tc_handler.h"
11 #include "tc_handler.h"
12 #include "wf_handler.h"
12 #include "wf_handler.h"
13 #include "fsw_spacewire.h"
13 #include "fsw_spacewire.h"
14
14
15 #include "avf0_prc0.h"
15 #include "avf0_prc0.h"
16 #include "avf1_prc1.h"
16 #include "avf1_prc1.h"
17 #include "avf2_prc2.h"
17 #include "avf2_prc2.h"
18 #include "fsw_spool.h"
18
19
19 extern rtems_name Task_name[20]; /* array of task names */
20 extern rtems_name Task_name[]; /* array of task names */
20 extern rtems_id Task_id[20]; /* array of task ids */
21 extern rtems_id Task_id[]; /* array of task ids */
21
22
22 // RTEMS TASKS
23 // RTEMS TASKS
23 rtems_task Init( rtems_task_argument argument);
24 rtems_task Init( rtems_task_argument argument);
24
25
25 // OTHER functions
26 // OTHER functions
26 void create_names( void );
27 void create_names( void );
27 int create_all_tasks( void );
28 int create_all_tasks( void );
28 int start_all_tasks( void );
29 int start_all_tasks( void );
29 //
30 //
30 rtems_status_code create_message_queues( void );
31 rtems_status_code create_message_queues( void );
31 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
32 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
32 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
33 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
33 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
34 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
34 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
35 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
35 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
36 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
36 //
37 //
37 int start_recv_send_tasks( void );
38 int start_recv_send_tasks( void );
38 //
39 //
39 void init_local_mode_parameters( void );
40 void init_local_mode_parameters( void );
40 void reset_local_time( void );
41 void reset_local_time( void );
41
42
42 extern int rtems_cpu_usage_report( void );
43 extern int rtems_cpu_usage_report( void );
43 extern int rtems_cpu_usage_reset( void );
44 extern int rtems_cpu_usage_reset( void );
44 extern void rtems_stack_checker_report_usage( void );
45 extern void rtems_stack_checker_report_usage( void );
45
46
46 extern int sched_yield( void );
47 extern int sched_yield( void );
47
48
48 #endif // FSW_INIT_H_INCLUDED
49 #endif // FSW_INIT_H_INCLUDED
@@ -1,255 +1,271
1 #ifndef FSW_PARAMS_H_INCLUDED
1 #ifndef FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
3
3
4 #include "grlib_regs.h"
4 #include "grlib_regs.h"
5 #include "fsw_params_processing.h"
5 #include "fsw_params_processing.h"
6 #include "fsw_params_nb_bytes.h"
6 #include "fsw_params_nb_bytes.h"
7 #include "tm_byte_positions.h"
7 #include "tm_byte_positions.h"
8 #include "ccsds_types.h"
8 #include "ccsds_types.h"
9
9
10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 #define UART_DEVICE_NAME "/dev/console"
11 #define UART_DEVICE_NAME "/dev/console"
12
12
13 typedef struct ring_node
13 typedef struct ring_node
14 {
14 {
15 struct ring_node *previous;
15 struct ring_node *previous;
16 int buffer_address;
16 int buffer_address;
17 struct ring_node *next;
17 struct ring_node *next;
18 unsigned int status;
18 unsigned int status;
19 } ring_node;
19 } ring_node;
20
20
21 //************************
21 //************************
22 // flight software version
22 // flight software version
23 // this parameters is handled by the Qt project options
23 // this parameters is handled by the Qt project options
24
24
25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 #define TIME_OFFSET 2
28 #define TIME_OFFSET 2
29 #define TIME_OFFSET_IN_BYTES 8
29 #define TIME_OFFSET_IN_BYTES 8
30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 #define NB_BYTES_SWF_BLK (2 * 6)
31 #define NB_BYTES_SWF_BLK (2 * 6)
32 #define NB_WORDS_SWF_BLK 3
32 #define NB_WORDS_SWF_BLK 3
33 #define NB_BYTES_CWF3_LIGHT_BLK 6
33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 #define NB_RING_NODES_F0 3 // AT LEAST 3
35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 #define NB_RING_NODES_F1 5 // AT LEAST 3
36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 #define NB_RING_NODES_F2 5 // AT LEAST 3
37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 #define NB_RING_NODES_F3 3 // AT LEAST 3
38 #define NB_RING_NODES_F3 3 // AT LEAST 3
39
39
40 //**********
40 //**********
41 // LFR MODES
41 // LFR MODES
42 #define LFR_MODE_STANDBY 0
42 #define LFR_MODE_STANDBY 0
43 #define LFR_MODE_NORMAL 1
43 #define LFR_MODE_NORMAL 1
44 #define LFR_MODE_BURST 2
44 #define LFR_MODE_BURST 2
45 #define LFR_MODE_SBM1 3
45 #define LFR_MODE_SBM1 3
46 #define LFR_MODE_SBM2 4
46 #define LFR_MODE_SBM2 4
47
47
48 #define TDS_MODE_LFM 5
48 #define TDS_MODE_LFM 5
49 #define TDS_MODE_STANDBY 0
49 #define TDS_MODE_STANDBY 0
50 #define TDS_MODE_NORMAL 1
50 #define TDS_MODE_NORMAL 1
51 #define TDS_MODE_BURST 2
51 #define TDS_MODE_BURST 2
52 #define TDS_MODE_SBM1 3
52 #define TDS_MODE_SBM1 3
53 #define TDS_MODE_SBM2 4
53 #define TDS_MODE_SBM2 4
54
54
55 #define THR_MODE_STANDBY 0
55 #define THR_MODE_STANDBY 0
56 #define THR_MODE_NORMAL 1
56 #define THR_MODE_NORMAL 1
57 #define THR_MODE_BURST 2
57 #define THR_MODE_BURST 2
58
58
59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
74 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
74 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
75 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
75 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
76 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
76 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
77 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
77 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
78 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
78 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
79 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
79 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
80 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
80 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
81 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
81 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
82
82
83 //****************************
83 //****************************
84 // LFR DEFAULT MODE PARAMETERS
84 // LFR DEFAULT MODE PARAMETERS
85 // COMMON
85 // COMMON
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 SY_LFR_N_SWF_L 2048 // nb sample
90 #define SY_LFR_N_SWF_P 300 // sec
90 #define SY_LFR_N_SWF_P 300 // sec
91 #define SY_LFR_N_ASM_P 3600 // sec
91 #define SY_LFR_N_ASM_P 3600 // sec
92 #define SY_LFR_N_BP_P0 4 // sec
92 #define SY_LFR_N_BP_P0 4 // sec
93 #define SY_LFR_N_BP_P1 20 // sec
93 #define 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 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
98 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
98 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
99 // SBM1
99 // SBM1
100 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
100 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
101 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
101 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
102 // SBM2
102 // SBM2
103 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
103 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
104 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
104 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
105 // ADDITIONAL PARAMETERS
105 // ADDITIONAL PARAMETERS
106 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
106 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
107 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
107 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
108 // STATUS WORD
108 // STATUS WORD
109 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
109 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
110 #define DEFAULT_STATUS_WORD_BYTE1 0x00
110 #define DEFAULT_STATUS_WORD_BYTE1 0x00
111 //
111 //
112 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
112 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
113 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
113 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
114 //****************************
114 //****************************
115
115
116 //*****************************
116 //*****************************
117 // APB REGISTERS BASE ADDRESSES
117 // APB REGISTERS BASE ADDRESSES
118 #define REGS_ADDR_APBUART 0x80000100
118 #define REGS_ADDR_APBUART 0x80000100
119 #define REGS_ADDR_GPTIMER 0x80000300
119 #define REGS_ADDR_GPTIMER 0x80000300
120 #define REGS_ADDR_GRSPW 0x80000500
120 #define REGS_ADDR_GRSPW 0x80000500
121 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
121 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
122 #define REGS_ADDR_GRGPIO 0x80000b00
122 #define REGS_ADDR_GRGPIO 0x80000b00
123
123
124 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
124 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
125 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
125 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
126 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
126 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
127
127
128 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
128 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
129 #define APBUART_CTRL_REG_MASK_TE 0x00000002
129 #define APBUART_CTRL_REG_MASK_TE 0x00000002
130 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
130 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
131
131
132 //**********
132 //**********
133 // IRQ LINES
133 // IRQ LINES
134 #define IRQ_SM_SIMULATOR 9
134 #define IRQ_SM_SIMULATOR 9
135 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
135 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
136 #define IRQ_WAVEFORM_PICKER 14
136 #define IRQ_WAVEFORM_PICKER 14
137 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
137 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
138 #define IRQ_SPECTRAL_MATRIX 6
138 #define IRQ_SPECTRAL_MATRIX 6
139 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
139 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
140
140
141 //*****
141 //*****
142 // TIME
142 // TIME
143 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
143 #ifdef FAST_SCHEDULER
144 #define TIMER_SM_SIMULATOR 1
144 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
145 #define HK_PERIOD 100 // 100 * 10ms => 1s
145 #define TIMER_SM_SIMULATOR 1
146 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
146 #define HK_PERIOD 1000 // 1000 * 1ms = 1s
147 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
147 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
148 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 2000 // 2000 * 1ms = 2s
149 #define SPOOL_TIMEOUT_in_ms 10
150 #define SPOOL_TIMEOUT_in_ticks 5 // 10 * 1ms = 10ms
151 #define STAT_TASK_PERIOD 10000 // 10000 * 1ms = 10s
152 #else
153 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
154 #define TIMER_SM_SIMULATOR 1
155 #define HK_PERIOD 100 // 100 * 10ms = 1s
156 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
157 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
158 #define SPOOL_TIMEOUT_in_ms 10
159 #define SPOOL_TIMEOUT_in_ticks 1 // 200 * 10 ms = 2 s
160 #define STAT_TASK_PERIOD 1000 // 1000 * 10ms = 10s
161 #endif
148
162
149 //**********
163 //**********
150 // LPP CODES
164 // LPP CODES
151 #define LFR_SUCCESSFUL 0
165 #define LFR_SUCCESSFUL 0
152 #define LFR_DEFAULT 1
166 #define LFR_DEFAULT 1
153 #define LFR_EXE_ERROR 2
167 #define LFR_EXE_ERROR 2
154
168
155 //******
169 //******
156 // RTEMS
170 // RTEMS
157 #define TASKID_RECV 1
171 #define TASKID_RECV 1
158 #define TASKID_ACTN 2
172 #define TASKID_ACTN 2
159 #define TASKID_SPIQ 3
173 #define TASKID_SPIQ 3
160 #define TASKID_STAT 4
174 #define TASKID_STAT 4
161 #define TASKID_AVF0 5
175 #define TASKID_AVF0 5
162 #define TASKID_SWBD 6
176 #define TASKID_SWBD 6
163 #define TASKID_WFRM 7
177 #define TASKID_WFRM 7
164 #define TASKID_DUMB 8
178 #define TASKID_DUMB 8
165 #define TASKID_HOUS 9
179 #define TASKID_HOUS 9
166 #define TASKID_PRC0 10
180 #define TASKID_PRC0 10
167 #define TASKID_CWF3 11
181 #define TASKID_CWF3 11
168 #define TASKID_CWF2 12
182 #define TASKID_CWF2 12
169 #define TASKID_CWF1 13
183 #define TASKID_CWF1 13
170 #define TASKID_SEND 14
184 #define TASKID_SEND 14
171 #define TASKID_WTDG 15
185 #define TASKID_WTDG 15
172 #define TASKID_AVF1 16
186 #define TASKID_AVF1 16
173 #define TASKID_PRC1 17
187 #define TASKID_PRC1 17
174 #define TASKID_AVF2 18
188 #define TASKID_AVF2 18
175 #define TASKID_PRC2 19
189 #define TASKID_PRC2 19
190 #define TASKID_SPOO 20
176
191
177 #define TASK_PRIORITY_SPIQ 5
192 #define TASK_PRIORITY_SPIQ 5
178 #define TASK_PRIORITY_WTDG 20
193 #define TASK_PRIORITY_WTDG 20
179 #define TASK_PRIORITY_HOUS 30
194 #define TASK_PRIORITY_HOUS 30
180 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
195 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
181 #define TASK_PRIORITY_CWF2 35 //
196 #define TASK_PRIORITY_CWF2 35 //
182 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
197 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
183 #define TASK_PRIORITY_WFRM 40
198 #define TASK_PRIORITY_WFRM 40
184 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
199 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
185 #define TASK_PRIORITY_SEND 45
200 #define TASK_PRIORITY_SEND 45
186 #define TASK_PRIORITY_RECV 50
201 #define TASK_PRIORITY_RECV 50
187 #define TASK_PRIORITY_ACTN 50
202 #define TASK_PRIORITY_ACTN 50
188 #define TASK_PRIORITY_AVF0 60
203 #define TASK_PRIORITY_AVF0 60
189 #define TASK_PRIORITY_AVF1 70
204 #define TASK_PRIORITY_AVF1 70
190 #define TASK_PRIORITY_PRC0 100
205 #define TASK_PRIORITY_PRC0 100
191 #define TASK_PRIORITY_PRC1 100
206 #define TASK_PRIORITY_PRC1 100
192 #define TASK_PRIORITY_AVF2 110
207 #define TASK_PRIORITY_AVF2 110
193 #define TASK_PRIORITY_PRC2 110
208 #define TASK_PRIORITY_PRC2 110
209 #define TASK_PRIORITY_SPOO 150
194 #define TASK_PRIORITY_STAT 200
210 #define TASK_PRIORITY_STAT 200
195 #define TASK_PRIORITY_DUMB 200
211 #define TASK_PRIORITY_DUMB 200
196
212
197 #define MSG_QUEUE_COUNT_RECV 10
213 #define MSG_QUEUE_COUNT_RECV 10
198 #define MSG_QUEUE_COUNT_SEND 50
214 #define MSG_QUEUE_COUNT_SEND 50
199 #define MSG_QUEUE_COUNT_PRC0 10
215 #define MSG_QUEUE_COUNT_PRC0 10
200 #define MSG_QUEUE_COUNT_PRC1 10
216 #define MSG_QUEUE_COUNT_PRC1 10
201 #define MSG_QUEUE_COUNT_PRC2 5
217 #define MSG_QUEUE_COUNT_PRC2 5
202 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
218 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
203 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
219 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
204 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
220 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
205 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
221 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
206 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
222 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
207
223
208 #define QUEUE_RECV 0
224 #define QUEUE_RECV 0
209 #define QUEUE_SEND 1
225 #define QUEUE_SEND 1
210 #define QUEUE_PRC0 2
226 #define QUEUE_PRC0 2
211 #define QUEUE_PRC1 3
227 #define QUEUE_PRC1 3
212 #define QUEUE_PRC2 4
228 #define QUEUE_PRC2 4
213
229
214 //*******
230 //*******
215 // MACROS
231 // MACROS
216 #ifdef PRINT_MESSAGES_ON_CONSOLE
232 #ifdef PRINT_MESSAGES_ON_CONSOLE
217 #define PRINTF(x) printf(x);
233 #define PRINTF(x) printf(x);
218 #define PRINTF1(x,y) printf(x,y);
234 #define PRINTF1(x,y) printf(x,y);
219 #define PRINTF2(x,y,z) printf(x,y,z);
235 #define PRINTF2(x,y,z) printf(x,y,z);
220 #else
236 #else
221 #define PRINTF(x) ;
237 #define PRINTF(x) ;
222 #define PRINTF1(x,y) ;
238 #define PRINTF1(x,y) ;
223 #define PRINTF2(x,y,z) ;
239 #define PRINTF2(x,y,z) ;
224 #endif
240 #endif
225
241
226 #ifdef BOOT_MESSAGES
242 #ifdef BOOT_MESSAGES
227 #define BOOT_PRINTF(x) printf(x);
243 #define BOOT_PRINTF(x) printf(x);
228 #define BOOT_PRINTF1(x,y) printf(x,y);
244 #define BOOT_PRINTF1(x,y) printf(x,y);
229 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
245 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
230 #else
246 #else
231 #define BOOT_PRINTF(x) ;
247 #define BOOT_PRINTF(x) ;
232 #define BOOT_PRINTF1(x,y) ;
248 #define BOOT_PRINTF1(x,y) ;
233 #define BOOT_PRINTF2(x,y,z) ;
249 #define BOOT_PRINTF2(x,y,z) ;
234 #endif
250 #endif
235
251
236 #ifdef DEBUG_MESSAGES
252 #ifdef DEBUG_MESSAGES
237 #define DEBUG_PRINTF(x) printf(x);
253 #define DEBUG_PRINTF(x) printf(x);
238 #define DEBUG_PRINTF1(x,y) printf(x,y);
254 #define DEBUG_PRINTF1(x,y) printf(x,y);
239 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
255 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
240 #else
256 #else
241 #define DEBUG_PRINTF(x) ;
257 #define DEBUG_PRINTF(x) ;
242 #define DEBUG_PRINTF1(x,y) ;
258 #define DEBUG_PRINTF1(x,y) ;
243 #define DEBUG_PRINTF2(x,y,z) ;
259 #define DEBUG_PRINTF2(x,y,z) ;
244 #endif
260 #endif
245
261
246 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
262 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
247
263
248 struct param_local_str{
264 struct param_local_str{
249 unsigned int local_sbm1_nb_cwf_sent;
265 unsigned int local_sbm1_nb_cwf_sent;
250 unsigned int local_sbm1_nb_cwf_max;
266 unsigned int local_sbm1_nb_cwf_max;
251 unsigned int local_sbm2_nb_cwf_sent;
267 unsigned int local_sbm2_nb_cwf_sent;
252 unsigned int local_sbm2_nb_cwf_max;
268 unsigned int local_sbm2_nb_cwf_max;
253 };
269 };
254
270
255 #endif // FSW_PARAMS_H_INCLUDED
271 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,243 +1,247
1 #ifndef FSW_PROCESSING_H_INCLUDED
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <math.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h> // printf()
8 #include <stdio.h> // printf()
9 #include <math.h>
9 #include <math.h>
10
10
11 #include "fsw_params.h"
11 #include "fsw_params.h"
12 #include "fsw_spacewire.h"
12 #include "fsw_spacewire.h"
13
13
14 typedef struct ring_node_sm
14 typedef struct ring_node_sm
15 {
15 {
16 struct ring_node_sm *previous;
16 struct ring_node_sm *previous;
17 struct ring_node_sm *next;
17 struct ring_node_sm *next;
18 int buffer_address;
18 int buffer_address;
19 unsigned int status;
19 unsigned int status;
20 unsigned int coarseTime;
20 unsigned int coarseTime;
21 unsigned int fineTime;
21 unsigned int fineTime;
22 } ring_node_sm;
22 } ring_node_sm;
23
23
24 typedef struct ring_node_asm
24 typedef struct ring_node_asm
25 {
25 {
26 struct ring_node_asm *next;
26 struct ring_node_asm *next;
27 float matrix[ TOTAL_SIZE_SM ];
27 float matrix[ TOTAL_SIZE_SM ];
28 unsigned int status;
28 unsigned int status;
29 } ring_node_asm;
29 } ring_node_asm;
30
30
31 typedef struct
31 typedef struct
32 {
32 {
33 Header_TM_LFR_SCIENCE_BP_t header;
33 Header_TM_LFR_SCIENCE_BP_t header;
34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
35 } bp_packet;
35 } bp_packet;
36
36
37 typedef struct
37 typedef struct
38 {
38 {
39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 } bp_packet_with_spare;
41 } bp_packet_with_spare;
42
42
43 typedef struct
43 typedef struct
44 {
44 {
45 ring_node_asm *norm;
45 ring_node_asm *norm;
46 ring_node_asm *burst_sbm;
46 ring_node_asm *burst_sbm;
47 rtems_event_set event;
47 rtems_event_set event;
48 unsigned int coarseTime;
48 unsigned int coarseTime;
49 unsigned int fineTime;
49 unsigned int fineTime;
50 } asm_msg;
50 } asm_msg;
51
51
52 extern volatile int sm_f0[ ];
52 extern volatile int sm_f0[ ];
53 extern volatile int sm_f1[ ];
53 extern volatile int sm_f1[ ];
54 extern volatile int sm_f2[ ];
54 extern volatile int sm_f2[ ];
55
55
56 // parameters
56 // parameters
57 extern struct param_local_str param_local;
57 extern struct param_local_str param_local;
58
58
59 // registers
59 // registers
60 extern time_management_regs_t *time_management_regs;
60 extern time_management_regs_t *time_management_regs;
61 extern spectral_matrix_regs_t *spectral_matrix_regs;
61 extern spectral_matrix_regs_t *spectral_matrix_regs;
62
62
63 extern rtems_name misc_name[5];
63 extern rtems_name misc_name[];
64 extern rtems_id Task_id[20]; /* array of task ids */
64 extern rtems_id Task_id[]; /* array of task ids */
65
65
66 // ISR
66 // ISR
67 void spectral_matrices_isr_f0( void );
68 void spectral_matrices_isr_f1( void );
69 void spectral_matrices_isr_f2( void );
70 void spectral_matrix_isr_error_handler( void );
67 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
71 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
68 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
72 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
69
73
70 //******************
74 //******************
71 // Spectral Matrices
75 // Spectral Matrices
72 void reset_nb_sm( void );
76 void reset_nb_sm( void );
73 // SM
77 // SM
74 void SM_init_rings( void );
78 void SM_init_rings( void );
75 void SM_reset_current_ring_nodes( void );
79 void SM_reset_current_ring_nodes( void );
76 void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] );
80 void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] );
77 // ASM
81 // ASM
78 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
82 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
79 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
83 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
80 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
84 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
81 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
85 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
82
86
83 //*****************
87 //*****************
84 // Basic Parameters
88 // Basic Parameters
85
89
86 void BP_reset_current_ring_nodes( void );
90 void BP_reset_current_ring_nodes( void );
87 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
91 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
88 unsigned int apid, unsigned char sid,
92 unsigned int apid, unsigned char sid,
89 unsigned int packetLength , unsigned char blkNr);
93 unsigned int packetLength , unsigned char blkNr);
90 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
94 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
91 unsigned int apid, unsigned char sid,
95 unsigned int apid, unsigned char sid,
92 unsigned int packetLength, unsigned char blkNr );
96 unsigned int packetLength, unsigned char blkNr );
93 void BP_send( char *data,
97 void BP_send( char *data,
94 rtems_id queue_id ,
98 rtems_id queue_id ,
95 unsigned int nbBytesToSend , unsigned int sid );
99 unsigned int nbBytesToSend , unsigned int sid );
96
100
97 //******************
101 //******************
98 // general functions
102 // general functions
99 void reset_spectral_matrix_regs( void );
103 void reset_spectral_matrix_regs( void );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
104 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
105 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,
106 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
107 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
104 unsigned char getSID( rtems_event_set event );
108 unsigned char getSID( rtems_event_set event );
105
109
106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
110 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
107 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
111 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
108
112
109 //***************************************
113 //***************************************
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
114 // DEFINITIONS OF STATIC INLINE FUNCTIONS
111 static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
115 static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
112 ring_node_sm *ring_node_tab[],
116 ring_node_sm *ring_node_tab[],
113 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
117 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
118 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
115 float divider );
119 float divider );
116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
120 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
117 float divider,
121 float divider,
118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
122 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
123 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
120
124
121 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
125 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
122 ring_node_sm *ring_node_tab[],
126 ring_node_sm *ring_node_tab[],
123 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
127 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
124 {
128 {
125 float sum;
129 float sum;
126 unsigned int i;
130 unsigned int i;
127
131
128 for(i=0; i<TOTAL_SIZE_SM; i++)
132 for(i=0; i<TOTAL_SIZE_SM; i++)
129 {
133 {
130 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
134 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
131 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
132 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
133 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
137 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
138 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
139 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
140 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
141 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
138
142
139 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
143 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
140 {
144 {
141 averaged_spec_mat_NORM[ i ] = sum;
145 averaged_spec_mat_NORM[ i ] = sum;
142 averaged_spec_mat_SBM[ i ] = sum;
146 averaged_spec_mat_SBM[ i ] = sum;
143 }
147 }
144 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
148 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
145 {
149 {
146 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
150 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
147 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
151 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
148 }
152 }
149 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
153 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
150 {
154 {
151 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
155 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
152 averaged_spec_mat_SBM[ i ] = sum;
156 averaged_spec_mat_SBM[ i ] = sum;
153 }
157 }
154 else
158 else
155 {
159 {
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
160 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
157 }
161 }
158 }
162 }
159 }
163 }
160
164
161 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
165 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
162 {
166 {
163 int frequencyBin;
167 int frequencyBin;
164 int asmComponent;
168 int asmComponent;
165 unsigned int offsetAveragedSpecMatReorganized;
169 unsigned int offsetAveragedSpecMatReorganized;
166 unsigned int offsetAveragedSpecMat;
170 unsigned int offsetAveragedSpecMat;
167
171
168 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
172 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
169 {
173 {
170 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
174 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
171 {
175 {
172 offsetAveragedSpecMatReorganized =
176 offsetAveragedSpecMatReorganized =
173 frequencyBin * NB_VALUES_PER_SM
177 frequencyBin * NB_VALUES_PER_SM
174 + asmComponent;
178 + asmComponent;
175 offsetAveragedSpecMat =
179 offsetAveragedSpecMat =
176 asmComponent * NB_BINS_PER_SM
180 asmComponent * NB_BINS_PER_SM
177 + frequencyBin;
181 + frequencyBin;
178 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
182 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
179 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
183 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
180 }
184 }
181 }
185 }
182 }
186 }
183
187
184 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
188 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
185 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
189 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
186 {
190 {
187 int frequencyBin;
191 int frequencyBin;
188 int asmComponent;
192 int asmComponent;
189 int offsetASM;
193 int offsetASM;
190 int offsetCompressed;
194 int offsetCompressed;
191 int k;
195 int k;
192
196
193 // build data
197 // build data
194 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
198 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
195 {
199 {
196 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
200 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
197 {
201 {
198 offsetCompressed = // NO TIME OFFSET
202 offsetCompressed = // NO TIME OFFSET
199 frequencyBin * NB_VALUES_PER_SM
203 frequencyBin * NB_VALUES_PER_SM
200 + asmComponent;
204 + asmComponent;
201 offsetASM = // NO TIME OFFSET
205 offsetASM = // NO TIME OFFSET
202 asmComponent * NB_BINS_PER_SM
206 asmComponent * NB_BINS_PER_SM
203 + ASMIndexStart
207 + ASMIndexStart
204 + frequencyBin * nbBinsToAverage;
208 + frequencyBin * nbBinsToAverage;
205 compressed_spec_mat[ offsetCompressed ] = 0;
209 compressed_spec_mat[ offsetCompressed ] = 0;
206 for ( k = 0; k < nbBinsToAverage; k++ )
210 for ( k = 0; k < nbBinsToAverage; k++ )
207 {
211 {
208 compressed_spec_mat[offsetCompressed ] =
212 compressed_spec_mat[offsetCompressed ] =
209 ( compressed_spec_mat[ offsetCompressed ]
213 ( compressed_spec_mat[ offsetCompressed ]
210 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
214 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
211 }
215 }
212 }
216 }
213 }
217 }
214 }
218 }
215
219
216 void ASM_convert( volatile float *input_matrix, char *output_matrix)
220 void ASM_convert( volatile float *input_matrix, char *output_matrix)
217 {
221 {
218 unsigned int frequencyBin;
222 unsigned int frequencyBin;
219 unsigned int asmComponent;
223 unsigned int asmComponent;
220 char * pt_char_input;
224 char * pt_char_input;
221 char * pt_char_output;
225 char * pt_char_output;
222 unsigned int offsetInput;
226 unsigned int offsetInput;
223 unsigned int offsetOutput;
227 unsigned int offsetOutput;
224
228
225 pt_char_input = (char*) &input_matrix;
229 pt_char_input = (char*) &input_matrix;
226 pt_char_output = (char*) &output_matrix;
230 pt_char_output = (char*) &output_matrix;
227
231
228 // convert all other data
232 // convert all other data
229 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
233 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
230 {
234 {
231 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
235 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
232 {
236 {
233 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
237 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
234 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
238 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
235 pt_char_input = (char*) &input_matrix [ offsetInput ];
239 pt_char_input = (char*) &input_matrix [ offsetInput ];
236 pt_char_output = (char*) &output_matrix[ offsetOutput ];
240 pt_char_output = (char*) &output_matrix[ offsetOutput ];
237 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
241 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
238 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
242 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
239 }
243 }
240 }
244 }
241 }
245 }
242
246
243 #endif // FSW_PROCESSING_H_INCLUDED
247 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,62 +1,64
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 #include "lfr_cpu_usage_report.h"
13 #include "lfr_cpu_usage_report.h"
14
14
15 // MODE PARAMETERS
15 // MODE PARAMETERS
16 extern unsigned int maxCount;
16 extern unsigned int maxCount;
17
17
18 //****
18 //****
19 // ISR
19 // ISR
20 rtems_isr commutation_isr1( rtems_vector_number vector );
20 rtems_isr commutation_isr1( rtems_vector_number vector );
21 rtems_isr commutation_isr2( rtems_vector_number vector );
21 rtems_isr commutation_isr2( rtems_vector_number vector );
22
22
23 //***********
23 //***********
24 // RTEMS TASK
24 // RTEMS TASK
25 rtems_task actn_task( rtems_task_argument unused );
25 rtems_task actn_task( rtems_task_argument unused );
26
26
27 //***********
27 //***********
28 // TC ACTIONS
28 // TC ACTIONS
29 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
29 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
30 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
30 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
31 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
31 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
32 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
32 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
33 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
33 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
34 int action_update_time( ccsdsTelecommandPacket_t *TC);
34 int action_update_time( ccsdsTelecommandPacket_t *TC);
35
35
36 // mode transition
36 // mode transition
37 int check_mode_value( unsigned char requestedMode );
37 int check_mode_value( unsigned char requestedMode );
38 int check_mode_transition( unsigned char requestedMode );
38 int check_mode_transition( unsigned char requestedMode );
39 int check_transition_date( unsigned int transitionCoarseTime );
39 int check_transition_date( unsigned int transitionCoarseTime );
40 int stop_current_mode( void );
40 int stop_current_mode( void );
41 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
41 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
42 int restart_science_tasks(unsigned char lfrRequestedMode );
42 int restart_science_tasks(unsigned char lfrRequestedMode );
43 int suspend_science_tasks();
43 int suspend_science_tasks();
44 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
44 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
45 void launch_waveform_picker_spool(unsigned char mode , unsigned int transitionCoarseTime);
45 void launch_spectral_matrix( void );
46 void launch_spectral_matrix( void );
47 void launch_spectral_matrix_spool( void );
46 void launch_spectral_matrix_simu( void );
48 void launch_spectral_matrix_simu( void );
47 void set_irq_on_new_ready_matrix(unsigned char value );
49 void set_irq_on_new_ready_matrix(unsigned char value );
48 void set_run_matrix_spectral( unsigned char value );
50 void set_run_matrix_spectral( unsigned char value );
49
51
50 // other functions
52 // other functions
51 void updateLFRCurrentMode();
53 void updateLFRCurrentMode();
52 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
54 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
53 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
55 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
54 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
56 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
55
57
56 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
58 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
57 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
59 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
58
60
59 #endif // TC_HANDLER_H_INCLUDED
61 #endif // TC_HANDLER_H_INCLUDED
60
62
61
63
62
64
@@ -1,92 +1,93
1 #ifndef WF_HANDLER_H_INCLUDED
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <math.h>
7 #include <math.h>
8
8
9 #include "fsw_params.h"
9 #include "fsw_params.h"
10 #include "fsw_spacewire.h"
10 #include "fsw_spacewire.h"
11 #include "fsw_misc.h"
11 #include "fsw_misc.h"
12 #include "fsw_params_wf_handler.h"
12 #include "fsw_params_wf_handler.h"
13
13
14 #define pi 3.1415
14 #define pi 3.1415
15
15
16 extern int fdSPW;
16 extern int fdSPW;
17
17
18 //*****************
18 //*****************
19 // waveform buffers
19 // waveform buffers
20 extern volatile int wf_snap_f0[ ];
20 extern volatile int wf_snap_f0[ ];
21 extern volatile int wf_snap_f1[ ];
21 extern volatile int wf_snap_f1[ ];
22 extern volatile int wf_snap_f2[ ];
22 extern volatile int wf_snap_f2[ ];
23 extern volatile int wf_cont_f3[ ];
23 extern volatile int wf_cont_f3[ ];
24 extern char wf_cont_f3_light[ ];
24 extern char wf_cont_f3_light[ ];
25
25
26 extern waveform_picker_regs_new_t *waveform_picker_regs;
26 extern waveform_picker_regs_new_t *waveform_picker_regs;
27 extern time_management_regs_t *time_management_regs;
27 extern time_management_regs_t *time_management_regs;
28 extern Packet_TM_LFR_HK_t housekeeping_packet;
28 extern Packet_TM_LFR_HK_t housekeeping_packet;
29 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
29 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
30 extern struct param_local_str param_local;
30 extern struct param_local_str param_local;
31
31
32 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
32 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
33 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
33 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
34
34
35 extern rtems_id Task_id[20]; /* array of task ids */
35 extern rtems_id Task_id[]; /* array of task ids */
36
36
37 extern unsigned char lfrCurrentMode;
37 extern unsigned char lfrCurrentMode;
38
38
39 //**********
39 //**********
40 // RTEMS_ISR
40 // RTEMS_ISR
41 void reset_extractSWF( void );
41 void reset_extractSWF( void );
42 rtems_isr waveforms_isr( rtems_vector_number vector );
42 rtems_isr waveforms_isr( rtems_vector_number vector );
43 rtems_isr waveforms_isr_alt( rtems_vector_number vector );
43
44
44 //***********
45 //***********
45 // RTEMS_TASK
46 // RTEMS_TASK
46 rtems_task wfrm_task( rtems_task_argument argument );
47 rtems_task wfrm_task( rtems_task_argument argument );
47 rtems_task cwf3_task( rtems_task_argument argument );
48 rtems_task cwf3_task( rtems_task_argument argument );
48 rtems_task cwf2_task( rtems_task_argument argument );
49 rtems_task cwf2_task( rtems_task_argument argument );
49 rtems_task cwf1_task( rtems_task_argument argument );
50 rtems_task cwf1_task( rtems_task_argument argument );
50 rtems_task swbd_task( rtems_task_argument argument );
51 rtems_task swbd_task( rtems_task_argument argument );
51
52
52 //******************
53 //******************
53 // general functions
54 // general functions
54 void WFP_init_rings( void );
55 void WFP_init_rings( void );
55 void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] );
56 void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] );
56 void WFP_reset_current_ring_nodes( void );
57 void WFP_reset_current_ring_nodes( void );
57 //
58 //
58 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
59 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
59 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
60 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
60 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
61 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
61 //
62 //
62 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 //
67 //
67 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
69 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
69 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
70 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
70 void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node );
71 void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node );
71 //
72 //
72 rtems_id get_pkts_queue_id( void );
73 rtems_id get_pkts_queue_id( void );
73
74
74 //**************
75 //**************
75 // wfp registers
76 // wfp registers
76 // RESET
77 // RESET
77 void reset_wfp_burst_enable( void );
78 void reset_wfp_burst_enable( void );
78 void reset_wfp_status(void);
79 void reset_wfp_status(void);
79 void reset_waveform_picker_regs( void );
80 void reset_waveform_picker_regs( void );
80 // SET
81 // SET
81 void set_wfp_data_shaping(void);
82 void set_wfp_data_shaping(void);
82 void set_wfp_burst_enable_register( unsigned char mode );
83 void set_wfp_burst_enable_register( unsigned char mode );
83 void set_wfp_delta_snapshot( void );
84 void set_wfp_delta_snapshot( void );
84 void set_wfp_delta_f0_f0_2( void );
85 void set_wfp_delta_f0_f0_2( void );
85 void set_wfp_delta_f1( void );
86 void set_wfp_delta_f1( void );
86 void set_wfp_delta_f2( void );
87 void set_wfp_delta_f2( void );
87
88
88 //*****************
89 //*****************
89 // local parameters
90 // local parameters
90 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
91 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
91
92
92 #endif // WF_HANDLER_H_INCLUDED
93 #endif // WF_HANDLER_H_INCLUDED
@@ -1,75 +1,75
1 /** Global variables of the LFR flight software.
1 /** Global variables of the LFR flight software.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * Among global variables, there are:
6 * Among global variables, there are:
7 * - RTEMS names and id.
7 * - RTEMS names and id.
8 * - APB configuration registers.
8 * - APB configuration registers.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
11 * - variable related to LFR modes parameters.
11 * - variable related to LFR modes parameters.
12 * - the global HK packet buffer.
12 * - the global HK packet buffer.
13 * - the global dump parameter buffer.
13 * - the global dump parameter buffer.
14 *
14 *
15 */
15 */
16
16
17 #include <rtems.h>
17 #include <rtems.h>
18 #include <grspw.h>
18 #include <grspw.h>
19
19
20 #include "ccsds_types.h"
20 #include "ccsds_types.h"
21 #include "grlib_regs.h"
21 #include "grlib_regs.h"
22 #include "fsw_params.h"
22 #include "fsw_params.h"
23 #include "fsw_params_wf_handler.h"
23 #include "fsw_params_wf_handler.h"
24
24
25 // RTEMS GLOBAL VARIABLES
25 // RTEMS GLOBAL VARIABLES
26 rtems_name misc_name[5];
26 rtems_name misc_name[5];
27 rtems_id misc_id[5];
27 rtems_id misc_id[5];
28 rtems_name Task_name[20]; /* array of task names */
28 rtems_name Task_name[21]; /* array of task names */
29 rtems_id Task_id[20]; /* array of task ids */
29 rtems_id Task_id[21]; /* array of task ids */
30 unsigned int maxCount;
30 unsigned int maxCount;
31 int fdSPW = 0;
31 int fdSPW = 0;
32 int fdUART = 0;
32 int fdUART = 0;
33 unsigned char lfrCurrentMode;
33 unsigned char lfrCurrentMode;
34
34
35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
39 // F0 F1 F2 F3
39 // F0 F1 F2 F3
40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
45
45
46 //***********************************
46 //***********************************
47 // SPECTRAL MATRICES GLOBAL VARIABLES
47 // SPECTRAL MATRICES GLOBAL VARIABLES
48
48
49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53
53
54 // APB CONFIGURATION REGISTERS
54 // APB CONFIGURATION REGISTERS
55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
59
59
60 // MODE PARAMETERS
60 // MODE PARAMETERS
61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
62 struct param_local_str param_local;
62 struct param_local_str param_local;
63
63
64 // HK PACKETS
64 // HK PACKETS
65 Packet_TM_LFR_HK_t housekeeping_packet;
65 Packet_TM_LFR_HK_t housekeeping_packet;
66 // sequence counters are incremented by APID (PID + CAT) and destination ID
66 // sequence counters are incremented by APID (PID + CAT) and destination ID
67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
70 unsigned short sequenceCounterHK;
70 unsigned short sequenceCounterHK;
71 unsigned short sequenceCounterParameterDump;
71 unsigned short sequenceCounterParameterDump;
72 spw_stats spacewire_stats;
72 spw_stats spacewire_stats;
73 spw_stats spacewire_stats_backup;
73 spw_stats spacewire_stats_backup;
74
74
75
75
@@ -1,780 +1,800
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 21
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43 #ifdef FAST_SCHEDULER
44 #define CONFIGURE_MICROSECONDS_PER_TICK 1000 /* 1 millisecond */
45 #endif
43
46
44 #include <rtems/confdefs.h>
47 #include <rtems/confdefs.h>
45
48
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
49 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
50 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
51 #ifdef LEON3
49 /* Add Timer and UART Driver */
52 /* Add Timer and UART Driver */
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #endif
55 #endif
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
56 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 #endif
58 #endif
56 #endif
59 #endif
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 #include <drvmgr/drvmgr_confdefs.h>
61 #include <drvmgr/drvmgr_confdefs.h>
59 #endif
62 #endif
60
63
61 #include "fsw_init.h"
64 #include "fsw_init.h"
62 #include "fsw_config.c"
65 #include "fsw_config.c"
63
66
64 rtems_task Init( rtems_task_argument ignored )
67 rtems_task Init( rtems_task_argument ignored )
65 {
68 {
66 /** This is the RTEMS INIT taks, it the first task launched by the system.
69 /** This is the RTEMS INIT taks, it the first task launched by the system.
67 *
70 *
68 * @param unused is the starting argument of the RTEMS task
71 * @param unused is the starting argument of the RTEMS task
69 *
72 *
70 * The INIT task create and run all other RTEMS tasks.
73 * The INIT task create and run all other RTEMS tasks.
71 *
74 *
72 */
75 */
73
76
74 unsigned char *vhdlVersion;
77 unsigned char *vhdlVersion;
75
78
76 reset_local_time();
79 reset_local_time();
77
80
78 rtems_cpu_usage_reset();
81 rtems_cpu_usage_reset();
79
82
80 rtems_status_code status;
83 rtems_status_code status;
81 rtems_status_code status_spw;
84 rtems_status_code status_spw;
82 rtems_isr_entry old_isr_handler;
85 rtems_isr_entry old_isr_handler;
83
86
84 // UART settings
87 // UART settings
85 send_console_outputs_on_apbuart_port();
88 send_console_outputs_on_apbuart_port();
86 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
89 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
87 enable_apbuart_transmitter();
90 enable_apbuart_transmitter();
88 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
91 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
89
92
90 PRINTF("\n\n\n\n\n")
93 PRINTF("\n\n\n\n\n")
91 PRINTF("*************************\n")
94 PRINTF("*************************\n")
92 PRINTF("** LFR Flight Software **\n")
95 PRINTF("** LFR Flight Software **\n")
93 PRINTF1("** %d.", SW_VERSION_N1)
96 PRINTF1("** %d.", SW_VERSION_N1)
94 PRINTF1("%d." , SW_VERSION_N2)
97 PRINTF1("%d." , SW_VERSION_N2)
95 PRINTF1("%d." , SW_VERSION_N3)
98 PRINTF1("%d." , SW_VERSION_N3)
96 PRINTF1("%d **\n", SW_VERSION_N4)
99 PRINTF1("%d **\n", SW_VERSION_N4)
97
100
98 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
101 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
99 PRINTF("** VHDL **\n")
102 PRINTF("** VHDL **\n")
100 PRINTF1("** %d.", vhdlVersion[1])
103 PRINTF1("** %d.", vhdlVersion[1])
101 PRINTF1("%d." , vhdlVersion[2])
104 PRINTF1("%d." , vhdlVersion[2])
102 PRINTF1("%d **\n", vhdlVersion[3])
105 PRINTF1("%d **\n", vhdlVersion[3])
103 PRINTF("*************************\n")
106 PRINTF("*************************\n")
104 PRINTF("\n\n")
107 PRINTF("\n\n")
105
108
106 init_parameter_dump();
109 init_parameter_dump();
107 init_local_mode_parameters();
110 init_local_mode_parameters();
108 init_housekeeping_parameters();
111 init_housekeeping_parameters();
109
112
110 // waveform picker initialization
113 // waveform picker initialization
111 WFP_init_rings(); // initialize the waveform rings
114 WFP_init_rings(); // initialize the waveform rings
112 WFP_reset_current_ring_nodes();
115 WFP_reset_current_ring_nodes();
113 reset_waveform_picker_regs();
116 reset_waveform_picker_regs();
114
117
115 // spectral matrices initialization
118 // spectral matrices initialization
116 SM_init_rings(); // initialize spectral matrices rings
119 SM_init_rings(); // initialize spectral matrices rings
117 SM_reset_current_ring_nodes();
120 SM_reset_current_ring_nodes();
118 reset_spectral_matrix_regs();
121 reset_spectral_matrix_regs();
119
122
120 updateLFRCurrentMode();
123 updateLFRCurrentMode();
121
124
122 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
125 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
123
126
124 create_names(); // create all names
127 create_names(); // create all names
125
128
126 status = create_message_queues(); // create message queues
129 status = create_message_queues(); // create message queues
127 if (status != RTEMS_SUCCESSFUL)
130 if (status != RTEMS_SUCCESSFUL)
128 {
131 {
129 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
132 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
130 }
133 }
131
134
132 status = create_all_tasks(); // create all tasks
135 status = create_all_tasks(); // create all tasks
133 if (status != RTEMS_SUCCESSFUL)
136 if (status != RTEMS_SUCCESSFUL)
134 {
137 {
135 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
138 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
136 }
139 }
137
140
138 // **************************
141 // **************************
139 // <SPACEWIRE INITIALIZATION>
142 // <SPACEWIRE INITIALIZATION>
140 grspw_timecode_callback = &timecode_irq_handler;
143 grspw_timecode_callback = &timecode_irq_handler;
141
144
142 status_spw = spacewire_open_link(); // (1) open the link
145 status_spw = spacewire_open_link(); // (1) open the link
143 if ( status_spw != RTEMS_SUCCESSFUL )
146 if ( status_spw != RTEMS_SUCCESSFUL )
144 {
147 {
145 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
148 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
146 }
149 }
147
150
148 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
151 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
149 {
152 {
150 status_spw = spacewire_configure_link( fdSPW );
153 status_spw = spacewire_configure_link( fdSPW );
151 if ( status_spw != RTEMS_SUCCESSFUL )
154 if ( status_spw != RTEMS_SUCCESSFUL )
152 {
155 {
153 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
156 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
154 }
157 }
155 }
158 }
156
159
157 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
160 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
158 {
161 {
159 status_spw = spacewire_start_link( fdSPW );
162 status_spw = spacewire_start_link( fdSPW );
160 if ( status_spw != RTEMS_SUCCESSFUL )
163 if ( status_spw != RTEMS_SUCCESSFUL )
161 {
164 {
162 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
165 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
163 }
166 }
164 }
167 }
165 // </SPACEWIRE INITIALIZATION>
168 // </SPACEWIRE INITIALIZATION>
166 // ***************************
169 // ***************************
167
170
168 status = start_all_tasks(); // start all tasks
171 status = start_all_tasks(); // start all tasks
169 if (status != RTEMS_SUCCESSFUL)
172 if (status != RTEMS_SUCCESSFUL)
170 {
173 {
171 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
174 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
172 }
175 }
173
176
174 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
177 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
175 status = start_recv_send_tasks();
178 status = start_recv_send_tasks();
176 if ( status != RTEMS_SUCCESSFUL )
179 if ( status != RTEMS_SUCCESSFUL )
177 {
180 {
178 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
181 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
179 }
182 }
180
183
181 // suspend science tasks, they will be restarted later depending on the mode
184 // suspend science tasks, they will be restarted later depending on the mode
182 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
185 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
183 if (status != RTEMS_SUCCESSFUL)
186 if (status != RTEMS_SUCCESSFUL)
184 {
187 {
185 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
188 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
186 }
189 }
187
190
188 //******************************
191 //******************************
189 // <SPECTRAL MATRICES SIMULATOR>
192 // <SPECTRAL MATRICES SIMULATOR>
190 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
193 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
191 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
194 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
192 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
195 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
193 // </SPECTRAL MATRICES SIMULATOR>
196 // </SPECTRAL MATRICES SIMULATOR>
194 //*******************************
197 //*******************************
195
198
196 // configure IRQ handling for the waveform picker unit
199 // configure IRQ handling for the waveform picker unit
197 status = rtems_interrupt_catch( waveforms_isr,
200 status = rtems_interrupt_catch( waveforms_isr_alt,
198 IRQ_SPARC_WAVEFORM_PICKER,
201 IRQ_SPARC_WAVEFORM_PICKER,
199 &old_isr_handler) ;
202 &old_isr_handler) ;
200 // configure IRQ handling for the spectral matrices unit
203 // configure IRQ handling for the spectral matrices unit
201 status = rtems_interrupt_catch( spectral_matrices_isr,
204 // status = rtems_interrupt_catch( spectral_matrices_isr,
202 IRQ_SPARC_SPECTRAL_MATRIX,
205 // IRQ_SPARC_SPECTRAL_MATRIX,
203 &old_isr_handler) ;
206 // &old_isr_handler) ;
204
207
205 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
208 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
206 if ( status_spw != RTEMS_SUCCESSFUL )
209 if ( status_spw != RTEMS_SUCCESSFUL )
207 {
210 {
208 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
211 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
209 if ( status != RTEMS_SUCCESSFUL ) {
212 if ( status != RTEMS_SUCCESSFUL ) {
210 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
213 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
211 }
214 }
212 }
215 }
213
216
214 BOOT_PRINTF("delete INIT\n")
217 BOOT_PRINTF("delete INIT\n")
215
218
216 status = rtems_task_delete(RTEMS_SELF);
219 status = rtems_task_delete(RTEMS_SELF);
217
220
218 }
221 }
219
222
220 void init_local_mode_parameters( void )
223 void init_local_mode_parameters( void )
221 {
224 {
222 /** This function initialize the param_local global variable with default values.
225 /** This function initialize the param_local global variable with default values.
223 *
226 *
224 */
227 */
225
228
226 unsigned int i;
229 unsigned int i;
227
230
228 // LOCAL PARAMETERS
231 // LOCAL PARAMETERS
229
232
230 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
233 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
231 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
234 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
232 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
235 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
233
236
234 // init sequence counters
237 // init sequence counters
235
238
236 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
239 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
237 {
240 {
238 sequenceCounters_TC_EXE[i] = 0x00;
241 sequenceCounters_TC_EXE[i] = 0x00;
239 }
242 }
240 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
243 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
241 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
244 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
242 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
245 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
243 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
246 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
244 }
247 }
245
248
246 void reset_local_time( void )
249 void reset_local_time( void )
247 {
250 {
248 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
251 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
249 }
252 }
250
253
251 void create_names( void ) // create all names for tasks and queues
254 void create_names( void ) // create all names for tasks and queues
252 {
255 {
253 /** This function creates all RTEMS names used in the software for tasks and queues.
256 /** This function creates all RTEMS names used in the software for tasks and queues.
254 *
257 *
255 * @return RTEMS directive status codes:
258 * @return RTEMS directive status codes:
256 * - RTEMS_SUCCESSFUL - successful completion
259 * - RTEMS_SUCCESSFUL - successful completion
257 *
260 *
258 */
261 */
259
262
260 // task names
263 // task names
261 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
264 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
262 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
265 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
263 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
266 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
264 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
267 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
265 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
268 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
266 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
269 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
267 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
270 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
268 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
271 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
269 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
272 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
270 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
273 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
271 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
274 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
272 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
275 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
273 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
276 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
274 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
277 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
275 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
278 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
276 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
279 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
277 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
280 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
278 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
281 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
279 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
282 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
283 Task_name[TASKID_SPOO] = rtems_build_name( 'S', 'P', 'O', 'O' );
280
284
281 // rate monotonic period names
285 // rate monotonic period names
282 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
286 name_hk_rate_monotonic = rtems_build_name( 'R', '_', 'H', 'K' );
287 name_spool_rate_monotonic = rtems_build_name( 'R', '_', 'S', 'P' );
283
288
284 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
289 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
285 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
290 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
286 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
291 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
287 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
292 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
288 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
293 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
289 }
294 }
290
295
291 int create_all_tasks( void ) // create all tasks which run in the software
296 int create_all_tasks( void ) // create all tasks which run in the software
292 {
297 {
293 /** This function creates all RTEMS tasks used in the software.
298 /** This function creates all RTEMS tasks used in the software.
294 *
299 *
295 * @return RTEMS directive status codes:
300 * @return RTEMS directive status codes:
296 * - RTEMS_SUCCESSFUL - task created successfully
301 * - RTEMS_SUCCESSFUL - task created successfully
297 * - RTEMS_INVALID_ADDRESS - id is NULL
302 * - RTEMS_INVALID_ADDRESS - id is NULL
298 * - RTEMS_INVALID_NAME - invalid task name
303 * - RTEMS_INVALID_NAME - invalid task name
299 * - RTEMS_INVALID_PRIORITY - invalid task priority
304 * - RTEMS_INVALID_PRIORITY - invalid task priority
300 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
305 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
301 * - RTEMS_TOO_MANY - too many tasks created
306 * - RTEMS_TOO_MANY - too many tasks created
302 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
307 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
303 * - RTEMS_TOO_MANY - too many global objects
308 * - RTEMS_TOO_MANY - too many global objects
304 *
309 *
305 */
310 */
306
311
307 rtems_status_code status;
312 rtems_status_code status;
308
313
309 //**********
314 //**********
310 // SPACEWIRE
315 // SPACEWIRE
311 // RECV
316 // RECV
312 status = rtems_task_create(
317 status = rtems_task_create(
313 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
318 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
314 RTEMS_DEFAULT_MODES,
319 RTEMS_DEFAULT_MODES,
315 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
320 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
316 );
321 );
317 if (status == RTEMS_SUCCESSFUL) // SEND
322 if (status == RTEMS_SUCCESSFUL) // SEND
318 {
323 {
319 status = rtems_task_create(
324 status = rtems_task_create(
320 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
325 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
321 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
326 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
322 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
327 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
323 );
328 );
324 }
329 }
325 if (status == RTEMS_SUCCESSFUL) // WTDG
330 if (status == RTEMS_SUCCESSFUL) // WTDG
326 {
331 {
327 status = rtems_task_create(
332 status = rtems_task_create(
328 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
333 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
329 RTEMS_DEFAULT_MODES,
334 RTEMS_DEFAULT_MODES,
330 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
335 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
331 );
336 );
332 }
337 }
333 if (status == RTEMS_SUCCESSFUL) // ACTN
338 if (status == RTEMS_SUCCESSFUL) // ACTN
334 {
339 {
335 status = rtems_task_create(
340 status = rtems_task_create(
336 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
341 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
337 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
342 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
338 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
343 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
339 );
344 );
340 }
345 }
341 if (status == RTEMS_SUCCESSFUL) // SPIQ
346 if (status == RTEMS_SUCCESSFUL) // SPIQ
342 {
347 {
343 status = rtems_task_create(
348 status = rtems_task_create(
344 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
349 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
345 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
350 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
346 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
351 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
347 );
352 );
348 }
353 }
349
354
350 //******************
355 //******************
351 // SPECTRAL MATRICES
356 // SPECTRAL MATRICES
352 if (status == RTEMS_SUCCESSFUL) // AVF0
357 if (status == RTEMS_SUCCESSFUL) // AVF0
353 {
358 {
354 status = rtems_task_create(
359 status = rtems_task_create(
355 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
360 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
356 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
361 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
357 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
362 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
358 );
363 );
359 }
364 }
360 if (status == RTEMS_SUCCESSFUL) // PRC0
365 if (status == RTEMS_SUCCESSFUL) // PRC0
361 {
366 {
362 status = rtems_task_create(
367 status = rtems_task_create(
363 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
368 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
364 RTEMS_DEFAULT_MODES,
369 RTEMS_DEFAULT_MODES,
365 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
370 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
366 );
371 );
367 }
372 }
368 if (status == RTEMS_SUCCESSFUL) // AVF1
373 if (status == RTEMS_SUCCESSFUL) // AVF1
369 {
374 {
370 status = rtems_task_create(
375 status = rtems_task_create(
371 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
376 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
372 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
377 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
373 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
378 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
374 );
379 );
375 }
380 }
376 if (status == RTEMS_SUCCESSFUL) // PRC1
381 if (status == RTEMS_SUCCESSFUL) // PRC1
377 {
382 {
378 status = rtems_task_create(
383 status = rtems_task_create(
379 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
384 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
380 RTEMS_DEFAULT_MODES,
385 RTEMS_DEFAULT_MODES,
381 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
386 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
382 );
387 );
383 }
388 }
384 if (status == RTEMS_SUCCESSFUL) // AVF2
389 if (status == RTEMS_SUCCESSFUL) // AVF2
385 {
390 {
386 status = rtems_task_create(
391 status = rtems_task_create(
387 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
392 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
388 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
393 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
389 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
394 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
390 );
395 );
391 }
396 }
392 if (status == RTEMS_SUCCESSFUL) // PRC2
397 if (status == RTEMS_SUCCESSFUL) // PRC2
393 {
398 {
394 status = rtems_task_create(
399 status = rtems_task_create(
395 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
400 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
396 RTEMS_DEFAULT_MODES,
401 RTEMS_DEFAULT_MODES,
397 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
402 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
398 );
403 );
399 }
404 }
400
405
401 //****************
406 //****************
402 // WAVEFORM PICKER
407 // WAVEFORM PICKER
403 if (status == RTEMS_SUCCESSFUL) // WFRM
408 if (status == RTEMS_SUCCESSFUL) // WFRM
404 {
409 {
405 status = rtems_task_create(
410 status = rtems_task_create(
406 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
411 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
407 RTEMS_DEFAULT_MODES,
412 RTEMS_DEFAULT_MODES,
408 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
413 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
409 );
414 );
410 }
415 }
411 if (status == RTEMS_SUCCESSFUL) // CWF3
416 if (status == RTEMS_SUCCESSFUL) // CWF3
412 {
417 {
413 status = rtems_task_create(
418 status = rtems_task_create(
414 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
419 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
415 RTEMS_DEFAULT_MODES,
420 RTEMS_DEFAULT_MODES,
416 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
421 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
417 );
422 );
418 }
423 }
419 if (status == RTEMS_SUCCESSFUL) // CWF2
424 if (status == RTEMS_SUCCESSFUL) // CWF2
420 {
425 {
421 status = rtems_task_create(
426 status = rtems_task_create(
422 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
427 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
423 RTEMS_DEFAULT_MODES,
428 RTEMS_DEFAULT_MODES,
424 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
429 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
425 );
430 );
426 }
431 }
427 if (status == RTEMS_SUCCESSFUL) // CWF1
432 if (status == RTEMS_SUCCESSFUL) // CWF1
428 {
433 {
429 status = rtems_task_create(
434 status = rtems_task_create(
430 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
435 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
431 RTEMS_DEFAULT_MODES,
436 RTEMS_DEFAULT_MODES,
432 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
437 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
433 );
438 );
434 }
439 }
435 if (status == RTEMS_SUCCESSFUL) // SWBD
440 if (status == RTEMS_SUCCESSFUL) // SWBD
436 {
441 {
437 status = rtems_task_create(
442 status = rtems_task_create(
438 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
443 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
439 RTEMS_DEFAULT_MODES,
444 RTEMS_DEFAULT_MODES,
440 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
441 );
446 );
442 }
447 }
443
448
444 //*****
449 //*****
445 // MISC
450 // MISC
446 if (status == RTEMS_SUCCESSFUL) // STAT
451 if (status == RTEMS_SUCCESSFUL) // STAT
447 {
452 {
448 status = rtems_task_create(
453 status = rtems_task_create(
449 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
454 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
450 RTEMS_DEFAULT_MODES,
455 RTEMS_DEFAULT_MODES,
451 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
456 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
452 );
457 );
453 }
458 }
454 if (status == RTEMS_SUCCESSFUL) // DUMB
459 if (status == RTEMS_SUCCESSFUL) // DUMB
455 {
460 {
456 status = rtems_task_create(
461 status = rtems_task_create(
457 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
462 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
458 RTEMS_DEFAULT_MODES,
463 RTEMS_DEFAULT_MODES,
459 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
464 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
460 );
465 );
461 }
466 }
462 if (status == RTEMS_SUCCESSFUL) // HOUS
467 if (status == RTEMS_SUCCESSFUL) // HOUS
463 {
468 {
464 status = rtems_task_create(
469 status = rtems_task_create(
465 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
470 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
471 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
467 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
472 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
468 );
473 );
469 }
474 }
475 if (status == RTEMS_SUCCESSFUL) // SPOO
476 {
477 status = rtems_task_create(
478 Task_name[TASKID_SPOO], TASK_PRIORITY_SPOO, RTEMS_MINIMUM_STACK_SIZE,
479 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
480 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPOO]
481 );
482 }
470
483
471 return status;
484 return status;
472 }
485 }
473
486
474 int start_recv_send_tasks( void )
487 int start_recv_send_tasks( void )
475 {
488 {
476 rtems_status_code status;
489 rtems_status_code status;
477
490
478 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
491 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
479 if (status!=RTEMS_SUCCESSFUL) {
492 if (status!=RTEMS_SUCCESSFUL) {
480 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
493 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
481 }
494 }
482
495
483 if (status == RTEMS_SUCCESSFUL) // SEND
496 if (status == RTEMS_SUCCESSFUL) // SEND
484 {
497 {
485 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
498 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
486 if (status!=RTEMS_SUCCESSFUL) {
499 if (status!=RTEMS_SUCCESSFUL) {
487 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
500 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
488 }
501 }
489 }
502 }
490
503
491 return status;
504 return status;
492 }
505 }
493
506
494 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
507 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
495 {
508 {
496 /** This function starts all RTEMS tasks used in the software.
509 /** This function starts all RTEMS tasks used in the software.
497 *
510 *
498 * @return RTEMS directive status codes:
511 * @return RTEMS directive status codes:
499 * - RTEMS_SUCCESSFUL - ask started successfully
512 * - RTEMS_SUCCESSFUL - ask started successfully
500 * - RTEMS_INVALID_ADDRESS - invalid task entry point
513 * - RTEMS_INVALID_ADDRESS - invalid task entry point
501 * - RTEMS_INVALID_ID - invalid task id
514 * - RTEMS_INVALID_ID - invalid task id
502 * - RTEMS_INCORRECT_STATE - task not in the dormant state
515 * - RTEMS_INCORRECT_STATE - task not in the dormant state
503 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
516 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
504 *
517 *
505 */
518 */
506 // starts all the tasks fot eh flight software
519 // starts all the tasks fot eh flight software
507
520
508 rtems_status_code status;
521 rtems_status_code status;
509
522
510 //**********
523 //**********
511 // SPACEWIRE
524 // SPACEWIRE
512 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
525 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
513 if (status!=RTEMS_SUCCESSFUL) {
526 if (status!=RTEMS_SUCCESSFUL) {
514 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
527 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
515 }
528 }
516
529
517 if (status == RTEMS_SUCCESSFUL) // WTDG
530 if (status == RTEMS_SUCCESSFUL) // WTDG
518 {
531 {
519 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
532 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
520 if (status!=RTEMS_SUCCESSFUL) {
533 if (status!=RTEMS_SUCCESSFUL) {
521 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
534 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
522 }
535 }
523 }
536 }
524
537
525 if (status == RTEMS_SUCCESSFUL) // ACTN
538 if (status == RTEMS_SUCCESSFUL) // ACTN
526 {
539 {
527 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
540 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
528 if (status!=RTEMS_SUCCESSFUL) {
541 if (status!=RTEMS_SUCCESSFUL) {
529 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
542 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
530 }
543 }
531 }
544 }
532
545
533 //******************
546 //******************
534 // SPECTRAL MATRICES
547 // SPECTRAL MATRICES
535 if (status == RTEMS_SUCCESSFUL) // AVF0
548 if (status == RTEMS_SUCCESSFUL) // AVF0
536 {
549 {
537 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
550 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
538 if (status!=RTEMS_SUCCESSFUL) {
551 if (status!=RTEMS_SUCCESSFUL) {
539 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
552 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
540 }
553 }
541 }
554 }
542 if (status == RTEMS_SUCCESSFUL) // PRC0
555 if (status == RTEMS_SUCCESSFUL) // PRC0
543 {
556 {
544 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
557 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
545 if (status!=RTEMS_SUCCESSFUL) {
558 if (status!=RTEMS_SUCCESSFUL) {
546 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
559 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
547 }
560 }
548 }
561 }
549 if (status == RTEMS_SUCCESSFUL) // AVF1
562 if (status == RTEMS_SUCCESSFUL) // AVF1
550 {
563 {
551 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
564 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
552 if (status!=RTEMS_SUCCESSFUL) {
565 if (status!=RTEMS_SUCCESSFUL) {
553 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
566 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
554 }
567 }
555 }
568 }
556 if (status == RTEMS_SUCCESSFUL) // PRC1
569 if (status == RTEMS_SUCCESSFUL) // PRC1
557 {
570 {
558 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
571 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
559 if (status!=RTEMS_SUCCESSFUL) {
572 if (status!=RTEMS_SUCCESSFUL) {
560 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
573 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
561 }
574 }
562 }
575 }
563 if (status == RTEMS_SUCCESSFUL) // AVF2
576 if (status == RTEMS_SUCCESSFUL) // AVF2
564 {
577 {
565 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
578 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
566 if (status!=RTEMS_SUCCESSFUL) {
579 if (status!=RTEMS_SUCCESSFUL) {
567 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
580 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
568 }
581 }
569 }
582 }
570 if (status == RTEMS_SUCCESSFUL) // PRC2
583 if (status == RTEMS_SUCCESSFUL) // PRC2
571 {
584 {
572 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
585 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
573 if (status!=RTEMS_SUCCESSFUL) {
586 if (status!=RTEMS_SUCCESSFUL) {
574 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
587 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
575 }
588 }
576 }
589 }
577
590
578 //****************
591 //****************
579 // WAVEFORM PICKER
592 // WAVEFORM PICKER
580 if (status == RTEMS_SUCCESSFUL) // WFRM
593 if (status == RTEMS_SUCCESSFUL) // WFRM
581 {
594 {
582 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
595 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
583 if (status!=RTEMS_SUCCESSFUL) {
596 if (status!=RTEMS_SUCCESSFUL) {
584 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
597 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
585 }
598 }
586 }
599 }
587 if (status == RTEMS_SUCCESSFUL) // CWF3
600 if (status == RTEMS_SUCCESSFUL) // CWF3
588 {
601 {
589 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
602 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
590 if (status!=RTEMS_SUCCESSFUL) {
603 if (status!=RTEMS_SUCCESSFUL) {
591 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
604 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
592 }
605 }
593 }
606 }
594 if (status == RTEMS_SUCCESSFUL) // CWF2
607 if (status == RTEMS_SUCCESSFUL) // CWF2
595 {
608 {
596 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
609 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
597 if (status!=RTEMS_SUCCESSFUL) {
610 if (status!=RTEMS_SUCCESSFUL) {
598 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
611 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
599 }
612 }
600 }
613 }
601 if (status == RTEMS_SUCCESSFUL) // CWF1
614 if (status == RTEMS_SUCCESSFUL) // CWF1
602 {
615 {
603 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
616 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
604 if (status!=RTEMS_SUCCESSFUL) {
617 if (status!=RTEMS_SUCCESSFUL) {
605 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
618 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
606 }
619 }
607 }
620 }
608 if (status == RTEMS_SUCCESSFUL) // SWBD
621 if (status == RTEMS_SUCCESSFUL) // SWBD
609 {
622 {
610 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
623 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
611 if (status!=RTEMS_SUCCESSFUL) {
624 if (status!=RTEMS_SUCCESSFUL) {
612 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
625 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
613 }
626 }
614 }
627 }
615
628
616 //*****
629 //*****
617 // MISC
630 // MISC
618 if (status == RTEMS_SUCCESSFUL) // HOUS
631 if (status == RTEMS_SUCCESSFUL) // HOUS
619 {
632 {
620 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
633 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
621 if (status!=RTEMS_SUCCESSFUL) {
634 if (status!=RTEMS_SUCCESSFUL) {
622 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
635 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
623 }
636 }
624 }
637 }
625 if (status == RTEMS_SUCCESSFUL) // DUMB
638 if (status == RTEMS_SUCCESSFUL) // DUMB
626 {
639 {
627 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
640 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
628 if (status!=RTEMS_SUCCESSFUL) {
641 if (status!=RTEMS_SUCCESSFUL) {
629 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
642 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
630 }
643 }
631 }
644 }
632 if (status == RTEMS_SUCCESSFUL) // STAT
645 if (status == RTEMS_SUCCESSFUL) // STAT
633 {
646 {
634 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
647 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
635 if (status!=RTEMS_SUCCESSFUL) {
648 if (status!=RTEMS_SUCCESSFUL) {
636 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
649 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
637 }
650 }
638 }
651 }
652 if (status == RTEMS_SUCCESSFUL) // SPOO
653 {
654 status = rtems_task_start( Task_id[TASKID_SPOO], spoo_task, 1 );
655 if (status!=RTEMS_SUCCESSFUL) {
656 BOOT_PRINTF("in INIT *** Error starting TASK_SPOO\n")
657 }
658 }
639
659
640 return status;
660 return status;
641 }
661 }
642
662
643 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
663 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
644 {
664 {
645 rtems_status_code status_recv;
665 rtems_status_code status_recv;
646 rtems_status_code status_send;
666 rtems_status_code status_send;
647 rtems_status_code status_q_p0;
667 rtems_status_code status_q_p0;
648 rtems_status_code status_q_p1;
668 rtems_status_code status_q_p1;
649 rtems_status_code status_q_p2;
669 rtems_status_code status_q_p2;
650 rtems_status_code ret;
670 rtems_status_code ret;
651 rtems_id queue_id;
671 rtems_id queue_id;
652
672
653 //****************************************
673 //****************************************
654 // create the queue for handling valid TCs
674 // create the queue for handling valid TCs
655 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
675 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
656 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
676 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
657 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
677 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
658 if ( status_recv != RTEMS_SUCCESSFUL ) {
678 if ( status_recv != RTEMS_SUCCESSFUL ) {
659 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
679 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
660 }
680 }
661
681
662 //************************************************
682 //************************************************
663 // create the queue for handling TM packet sending
683 // create the queue for handling TM packet sending
664 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
684 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
665 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
685 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
666 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
686 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
667 if ( status_send != RTEMS_SUCCESSFUL ) {
687 if ( status_send != RTEMS_SUCCESSFUL ) {
668 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
688 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
669 }
689 }
670
690
671 //*****************************************************************************
691 //*****************************************************************************
672 // create the queue for handling averaged spectral matrices for processing @ f0
692 // create the queue for handling averaged spectral matrices for processing @ f0
673 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
693 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
674 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
694 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
675 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
695 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
676 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
696 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
677 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
697 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
678 }
698 }
679
699
680 //*****************************************************************************
700 //*****************************************************************************
681 // create the queue for handling averaged spectral matrices for processing @ f1
701 // create the queue for handling averaged spectral matrices for processing @ f1
682 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
702 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
683 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
703 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
684 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
704 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
685 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
705 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
686 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
706 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
687 }
707 }
688
708
689 //*****************************************************************************
709 //*****************************************************************************
690 // create the queue for handling averaged spectral matrices for processing @ f2
710 // create the queue for handling averaged spectral matrices for processing @ f2
691 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
711 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
692 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
712 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
693 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
713 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
694 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
714 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
695 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
715 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
696 }
716 }
697
717
698 if ( status_recv != RTEMS_SUCCESSFUL )
718 if ( status_recv != RTEMS_SUCCESSFUL )
699 {
719 {
700 ret = status_recv;
720 ret = status_recv;
701 }
721 }
702 else if( status_send != RTEMS_SUCCESSFUL )
722 else if( status_send != RTEMS_SUCCESSFUL )
703 {
723 {
704 ret = status_send;
724 ret = status_send;
705 }
725 }
706 else if( status_q_p0 != RTEMS_SUCCESSFUL )
726 else if( status_q_p0 != RTEMS_SUCCESSFUL )
707 {
727 {
708 ret = status_q_p0;
728 ret = status_q_p0;
709 }
729 }
710 else if( status_q_p1 != RTEMS_SUCCESSFUL )
730 else if( status_q_p1 != RTEMS_SUCCESSFUL )
711 {
731 {
712 ret = status_q_p1;
732 ret = status_q_p1;
713 }
733 }
714 else
734 else
715 {
735 {
716 ret = status_q_p2;
736 ret = status_q_p2;
717 }
737 }
718
738
719 return ret;
739 return ret;
720 }
740 }
721
741
722 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
742 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
723 {
743 {
724 rtems_status_code status;
744 rtems_status_code status;
725 rtems_name queue_name;
745 rtems_name queue_name;
726
746
727 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
747 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
728
748
729 status = rtems_message_queue_ident( queue_name, 0, queue_id );
749 status = rtems_message_queue_ident( queue_name, 0, queue_id );
730
750
731 return status;
751 return status;
732 }
752 }
733
753
734 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
754 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
735 {
755 {
736 rtems_status_code status;
756 rtems_status_code status;
737 rtems_name queue_name;
757 rtems_name queue_name;
738
758
739 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
759 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
740
760
741 status = rtems_message_queue_ident( queue_name, 0, queue_id );
761 status = rtems_message_queue_ident( queue_name, 0, queue_id );
742
762
743 return status;
763 return status;
744 }
764 }
745
765
746 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
766 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
747 {
767 {
748 rtems_status_code status;
768 rtems_status_code status;
749 rtems_name queue_name;
769 rtems_name queue_name;
750
770
751 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
771 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
752
772
753 status = rtems_message_queue_ident( queue_name, 0, queue_id );
773 status = rtems_message_queue_ident( queue_name, 0, queue_id );
754
774
755 return status;
775 return status;
756 }
776 }
757
777
758 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
778 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
759 {
779 {
760 rtems_status_code status;
780 rtems_status_code status;
761 rtems_name queue_name;
781 rtems_name queue_name;
762
782
763 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
783 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
764
784
765 status = rtems_message_queue_ident( queue_name, 0, queue_id );
785 status = rtems_message_queue_ident( queue_name, 0, queue_id );
766
786
767 return status;
787 return status;
768 }
788 }
769
789
770 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
790 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
771 {
791 {
772 rtems_status_code status;
792 rtems_status_code status;
773 rtems_name queue_name;
793 rtems_name queue_name;
774
794
775 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
795 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
776
796
777 status = rtems_message_queue_ident( queue_name, 0, queue_id );
797 status = rtems_message_queue_ident( queue_name, 0, queue_id );
778
798
779 return status;
799 return status;
780 }
800 }
@@ -1,529 +1,526
1 /** General usage functions and RTEMS tasks.
1 /** General usage functions and RTEMS tasks.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 */
6 */
7
7
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9
9
10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 {
12 {
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 *
14 *
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 * @param interrupt_level is the interrupt level that the timer drives.
18 * @param interrupt_level is the interrupt level that the timer drives.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 *
20 *
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 *
22 *
23 */
23 */
24
24
25 rtems_status_code status;
25 rtems_status_code status;
26 rtems_isr_entry old_isr_handler;
26 rtems_isr_entry old_isr_handler;
27
27
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29
29
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 if (status!=RTEMS_SUCCESSFUL)
31 if (status!=RTEMS_SUCCESSFUL)
32 {
32 {
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 }
34 }
35
35
36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 }
37 }
38
38
39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 {
40 {
41 /** This function starts a GPTIMER timer.
41 /** This function starts a GPTIMER timer.
42 *
42 *
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 *
45 *
46 */
46 */
47
47
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 }
53 }
54
54
55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 {
56 {
57 /** This function stops a GPTIMER timer.
57 /** This function stops a GPTIMER timer.
58 *
58 *
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 *
61 *
62 */
62 */
63
63
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 }
67 }
68
68
69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 {
70 {
71 /** This function sets the clock divider of a GPTIMER timer.
71 /** This function sets the clock divider of a GPTIMER timer.
72 *
72 *
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 *
76 *
77 */
77 */
78
78
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 }
80 }
81
81
82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 {
83 {
84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85
85
86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87
87
88 return 0;
88 return 0;
89 }
89 }
90
90
91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 {
92 {
93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94
94
95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96
96
97 return 0;
97 return 0;
98 }
98 }
99
99
100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 {
101 {
102 /** This function sets the scaler reload register of the apbuart module
102 /** This function sets the scaler reload register of the apbuart module
103 *
103 *
104 * @param regs is the address of the apbuart registers in memory
104 * @param regs is the address of the apbuart registers in memory
105 * @param value is the value that will be stored in the scaler register
105 * @param value is the value that will be stored in the scaler register
106 *
106 *
107 * The value shall be set by the software to get data on the serial interface.
107 * The value shall be set by the software to get data on the serial interface.
108 *
108 *
109 */
109 */
110
110
111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112
112
113 apbuart_regs->scaler = value;
113 apbuart_regs->scaler = value;
114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 }
115 }
116
116
117 //************
117 //************
118 // RTEMS TASKS
118 // RTEMS TASKS
119
119
120 rtems_task stat_task(rtems_task_argument argument)
120 rtems_task stat_task(rtems_task_argument argument)
121 {
121 {
122 int i;
122 int i;
123 int j;
123 int j;
124 i = 0;
124 i = 0;
125 j = 0;
125 j = 0;
126 BOOT_PRINTF("in STAT *** \n")
126 BOOT_PRINTF("in STAT *** \n")
127 while(1){
127 while(1){
128 rtems_task_wake_after(1000);
128 rtems_task_wake_after(STAT_TASK_PERIOD);
129 PRINTF1("%d\n", j)
129 PRINTF1("%d\n", j)
130 if (i == CPU_USAGE_REPORT_PERIOD) {
130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 // #ifdef PRINT_TASK_STATISTICS
131 // #ifdef PRINT_TASK_STATISTICS
132 // rtems_cpu_usage_report();
132 // rtems_cpu_usage_report();
133 // rtems_cpu_usage_reset();
133 // rtems_cpu_usage_reset();
134 // #endif
134 // #endif
135 i = 0;
135 i = 0;
136 }
136 }
137 else i++;
137 else i++;
138 j++;
138 j++;
139 }
139 }
140 }
140 }
141
141
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_id queue_id;
145 rtems_id queue_id;
146 rtems_rate_monotonic_period_status period_status;
146 rtems_rate_monotonic_period_status period_status;
147
147
148 status = get_message_queue_id_send( &queue_id );
148 status = get_message_queue_id_send( &queue_id );
149 if (status != RTEMS_SUCCESSFUL)
149 if (status != RTEMS_SUCCESSFUL)
150 {
150 {
151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 }
152 }
153
153
154 BOOT_PRINTF("in HOUS ***\n")
154 BOOT_PRINTF("in HOUS ***\n")
155
155
156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 if( status != RTEMS_SUCCESSFUL ) {
158 if( status != RTEMS_SUCCESSFUL ) {
159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
159 PRINTF1( "in HOUS *** rtems_rate_monotonic_create failed with status of %d\n", status )
160 }
160 }
161 }
161 }
162
162
163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 housekeeping_packet.reserved = DEFAULT_RESERVED;
165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 housekeeping_packet.userApplication = CCSDS_USER_APP;
166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 housekeeping_packet.serviceType = TM_TYPE_HK;
174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 housekeeping_packet.sid = SID_HK;
177 housekeeping_packet.sid = SID_HK;
178
178
179 status = rtems_rate_monotonic_cancel(HK_id);
179 status = rtems_rate_monotonic_cancel(HK_id);
180 if( status != RTEMS_SUCCESSFUL ) {
180 if( status != RTEMS_SUCCESSFUL ) {
181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 }
182 }
183 else {
183 else {
184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 }
185 }
186
186
187 // startup phase
187 // startup phase
188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 {
192 {
193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 {
194 {
195 break; // break if LFR is synchronized
195 break; // break if LFR is synchronized
196 }
196 }
197 else
197 else
198 {
198 {
199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 // sched_yield();
200 // sched_yield();
201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
202 }
202 }
203 }
203 }
204 status = rtems_rate_monotonic_cancel(HK_id);
204 status = rtems_rate_monotonic_cancel(HK_id);
205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
206
206
207 while(1){ // launch the rate monotonic task
207 while(1){ // launch the rate monotonic task
208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 if ( status != RTEMS_SUCCESSFUL ) {
209 if ( status != RTEMS_SUCCESSFUL ) {
210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 }
212 }
213 else {
213 else {
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
216 increment_seq_counter( &sequenceCounterHK );
216 increment_seq_counter( &sequenceCounterHK );
217
217
218 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
218 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
219 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
219 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
220 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
220 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
222 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
222 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
224
224
225 spacewire_update_statistics();
225 spacewire_update_statistics();
226
226
227 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
227 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
229
229
230 // SEND PACKET
230 // SEND PACKET
231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
232 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
232 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
233 if (status != RTEMS_SUCCESSFUL) {
233 if (status != RTEMS_SUCCESSFUL) {
234 PRINTF1("in HOUS *** ERR send: %d\n", status)
234 PRINTF1("in HOUS *** ERR send: %d\n", status)
235 }
235 }
236 }
236 }
237 }
237 }
238
238
239 PRINTF("in HOUS *** deleting task\n")
239 PRINTF("in HOUS *** deleting task\n")
240
240
241 status = rtems_task_delete( RTEMS_SELF ); // should not return
241 status = rtems_task_delete( RTEMS_SELF ); // should not return
242 printf( "rtems_task_delete returned with status of %d.\n", status );
242 printf( "rtems_task_delete returned with status of %d.\n", status );
243 return;
243 return;
244 }
244 }
245
245
246 rtems_task dumb_task( rtems_task_argument unused )
246 rtems_task dumb_task( rtems_task_argument unused )
247 {
247 {
248 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
248 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
249 *
249 *
250 * @param unused is the starting argument of the RTEMS task
250 * @param unused is the starting argument of the RTEMS task
251 *
251 *
252 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
252 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
253 *
253 *
254 */
254 */
255
255
256 unsigned int i;
256 unsigned int i;
257 unsigned int intEventOut;
257 unsigned int intEventOut;
258 unsigned int coarse_time = 0;
258 unsigned int coarse_time = 0;
259 unsigned int fine_time = 0;
259 unsigned int fine_time = 0;
260 rtems_event_set event_out;
260 rtems_event_set event_out;
261
261
262 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
262 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
266 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
266 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
268 "ERR HK", // RTEMS_EVENT_6
268 "ERR HK", // RTEMS_EVENT_6
269 "ready for dump", // RTEMS_EVENT_7
269 "ready for dump", // RTEMS_EVENT_7
270 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
270 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
271 "tick", // RTEMS_EVENT_9
271 "tick", // RTEMS_EVENT_9
272 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
272 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
273 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
273 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
274 };
274 };
275
275
276 BOOT_PRINTF("in DUMB *** \n")
276 BOOT_PRINTF("in DUMB *** \n")
277
277
278 while(1){
278 while(1){
279 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
279 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
280 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
280 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
281 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
281 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
282 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
282 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
283 intEventOut = (unsigned int) event_out;
283 intEventOut = (unsigned int) event_out;
284 for ( i=0; i<32; i++)
284 for ( i=0; i<32; i++)
285 {
285 {
286 if ( ((intEventOut >> i) & 0x0001) != 0)
286 if ( ((intEventOut >> i) & 0x0001) != 0)
287 {
287 {
288 coarse_time = time_management_regs->coarse_time;
288 coarse_time = time_management_regs->coarse_time;
289 fine_time = time_management_regs->fine_time;
289 fine_time = time_management_regs->fine_time;
290 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
290 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
291 if (i==8)
291 if (i==8)
292 {
292 {
293 PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status)
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)
297 PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status)
298 }
298 }
299 }
299 }
300 }
300 }
301 }
301 }
302 }
302 }
303
303
304 //*****************************
304 //*****************************
305 // init housekeeping parameters
305 // init housekeeping parameters
306
306
307 void init_housekeeping_parameters( void )
307 void init_housekeeping_parameters( void )
308 {
308 {
309 /** This function initialize the housekeeping_packet global variable with default values.
309 /** This function initialize the housekeeping_packet global variable with default values.
310 *
310 *
311 */
311 */
312
312
313 unsigned int i = 0;
313 unsigned int i = 0;
314 unsigned char *parameters;
314 unsigned char *parameters;
315
315
316 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
316 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
317 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
317 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
318 {
318 {
319 parameters[i] = 0x00;
319 parameters[i] = 0x00;
320 }
320 }
321 // init status word
321 // init status word
322 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
322 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
323 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
323 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
324 // init software version
324 // init software version
325 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
325 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
326 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
326 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
327 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
327 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
328 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
328 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
329 // init fpga version
329 // init fpga version
330 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
330 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
331 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
331 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
332 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
332 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
333 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
333 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
334 }
334 }
335
335
336 void increment_seq_counter( unsigned short *packetSequenceControl )
336 void increment_seq_counter( unsigned short *packetSequenceControl )
337 {
337 {
338 /** This function increment the sequence counter psased in argument.
338 /** This function increment the sequence counter psased in argument.
339 *
339 *
340 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
340 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
341 *
341 *
342 */
342 */
343
343
344 unsigned short segmentation_grouping_flag;
344 unsigned short segmentation_grouping_flag;
345 unsigned short sequence_cnt;
345 unsigned short sequence_cnt;
346
346
347 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
347 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
348 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
348 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
349
349
350 if ( sequence_cnt < SEQ_CNT_MAX)
350 if ( sequence_cnt < SEQ_CNT_MAX)
351 {
351 {
352 sequence_cnt = sequence_cnt + 1;
352 sequence_cnt = sequence_cnt + 1;
353 }
353 }
354 else
354 else
355 {
355 {
356 sequence_cnt = 0;
356 sequence_cnt = 0;
357 }
357 }
358
358
359 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
359 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
360 }
360 }
361
361
362 void getTime( unsigned char *time)
362 void getTime( unsigned char *time)
363 {
363 {
364 /** This function write the current local time in the time buffer passed in argument.
364 /** This function write the current local time in the time buffer passed in argument.
365 *
365 *
366 */
366 */
367
367
368 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
368 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
369 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
369 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
370 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
370 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
371 time[3] = (unsigned char) (time_management_regs->coarse_time);
371 time[3] = (unsigned char) (time_management_regs->coarse_time);
372 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
372 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
373 time[5] = (unsigned char) (time_management_regs->fine_time);
373 time[5] = (unsigned char) (time_management_regs->fine_time);
374 }
374 }
375
375
376 unsigned long long int getTimeAsUnsignedLongLongInt( )
376 unsigned long long int getTimeAsUnsignedLongLongInt( )
377 {
377 {
378 /** This function write the current local time in the time buffer passed in argument.
378 /** This function write the current local time in the time buffer passed in argument.
379 *
379 *
380 */
380 */
381 unsigned long long int time;
381 unsigned long long int time;
382
382
383 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
383 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
384 + time_management_regs->fine_time;
384 + time_management_regs->fine_time;
385
385
386 return time;
386 return time;
387 }
387 }
388
388
389 void send_dumb_hk( void )
389 void send_dumb_hk( void )
390 {
390 {
391 Packet_TM_LFR_HK_t dummy_hk_packet;
391 Packet_TM_LFR_HK_t dummy_hk_packet;
392 unsigned char *parameters;
392 unsigned char *parameters;
393 unsigned int i;
393 unsigned int i;
394 rtems_id queue_id;
394 rtems_id queue_id;
395
395
396 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
396 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
397 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
397 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
398 dummy_hk_packet.reserved = DEFAULT_RESERVED;
398 dummy_hk_packet.reserved = DEFAULT_RESERVED;
399 dummy_hk_packet.userApplication = CCSDS_USER_APP;
399 dummy_hk_packet.userApplication = CCSDS_USER_APP;
400 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
400 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
401 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
401 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
402 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
402 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
403 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
403 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
404 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
404 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
405 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
405 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
406 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
406 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
407 dummy_hk_packet.serviceType = TM_TYPE_HK;
407 dummy_hk_packet.serviceType = TM_TYPE_HK;
408 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
408 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
409 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
409 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
410 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
410 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
411 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
411 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
412 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
412 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
413 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
413 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
414 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
414 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
415 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
415 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
416 dummy_hk_packet.sid = SID_HK;
416 dummy_hk_packet.sid = SID_HK;
417
417
418 // init status word
418 // init status word
419 dummy_hk_packet.lfr_status_word[0] = 0xff;
419 dummy_hk_packet.lfr_status_word[0] = 0xff;
420 dummy_hk_packet.lfr_status_word[1] = 0xff;
420 dummy_hk_packet.lfr_status_word[1] = 0xff;
421 // init software version
421 // init software version
422 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
422 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
423 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
423 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
424 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
424 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
425 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
425 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
426 // init fpga version
426 // init fpga version
427 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
427 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
428 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
428 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
429 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
429 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
430 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
430 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
431
431
432 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
432 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
433
433
434 for (i=0; i<100; i++)
434 for (i=0; i<100; i++)
435 {
435 {
436 parameters[i] = 0xff;
436 parameters[i] = 0xff;
437 }
437 }
438
438
439 get_message_queue_id_send( &queue_id );
439 get_message_queue_id_send( &queue_id );
440
440
441 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
441 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
442 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
442 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
443 }
443 }
444
444
445 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
445 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
446 {
446 {
447 unsigned int coarseTime;
447 unsigned int coarseTime;
448 unsigned int acquisitionTime;
448 unsigned int acquisitionTime;
449 unsigned int deltaT = 0;
449 unsigned int deltaT = 0;
450 unsigned char *bufferPtr;
450 unsigned char *bufferPtr;
451
451
452 unsigned int offset_in_samples;
452 unsigned int offset_in_samples;
453 unsigned int offset_in_bytes;
453 unsigned int offset_in_bytes;
454 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
454 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
455
455
456 if (lfrCurrentMode == LFR_MODE_STANDBY)
456 if (lfrCurrentMode == LFR_MODE_STANDBY)
457 {
457 {
458 spacecraft_potential[0] = 0x00;
458 spacecraft_potential[0] = 0x00;
459 spacecraft_potential[1] = 0x00;
459 spacecraft_potential[1] = 0x00;
460 spacecraft_potential[2] = 0x00;
460 spacecraft_potential[2] = 0x00;
461 spacecraft_potential[3] = 0x00;
461 spacecraft_potential[3] = 0x00;
462 spacecraft_potential[4] = 0x00;
462 spacecraft_potential[4] = 0x00;
463 spacecraft_potential[5] = 0x00;
463 spacecraft_potential[5] = 0x00;
464 }
464 }
465 else
465 else
466 {
466 {
467 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
467 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
468 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
468 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
469 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
469 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
470 + (unsigned int) ( bufferPtr[1] << 16 )
470 + (unsigned int) ( bufferPtr[1] << 16 )
471 + (unsigned int) ( bufferPtr[2] << 8 )
471 + (unsigned int) ( bufferPtr[2] << 8 )
472 + (unsigned int) ( bufferPtr[3] );
472 + (unsigned int) ( bufferPtr[3] );
473 if ( coarseTime > acquisitionTime )
473 if ( coarseTime > acquisitionTime )
474 {
474 {
475 deltaT = coarseTime - acquisitionTime;
475 deltaT = coarseTime - acquisitionTime;
476 offset_in_samples = (deltaT-1) * f3 ;
476 offset_in_samples = (deltaT-1) * f3 ;
477 }
477 }
478 else if( coarseTime == acquisitionTime )
478 else if( coarseTime == acquisitionTime )
479 {
479 {
480 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
480 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
481 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
481 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
482 }
482 }
483 else
483 else
484 {
484 {
485 offset_in_samples = 0;
485 offset_in_samples = 0;
486 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
486 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
487 }
487 }
488
488
489 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
489 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
490 {
490 {
491 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
491 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
492 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
492 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
493 }
493 }
494 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
494 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
495 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
495 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
496 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
496 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
497 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
497 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
498 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
498 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
499 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
499 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
500 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
500 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
501 }
501 }
502 }
502 }
503
503
504 void get_cpu_load( unsigned char *resource_statistics )
504 void get_cpu_load( unsigned char *resource_statistics )
505 {
505 {
506 unsigned char cpu_load;
506 unsigned char cpu_load;
507
507
508 cpu_load = lfr_rtems_cpu_usage_report();
508 cpu_load = lfr_rtems_cpu_usage_report();
509
509
510 // HK_LFR_CPU_LOAD
510 // HK_LFR_CPU_LOAD
511 resource_statistics[0] = cpu_load;
511 resource_statistics[0] = cpu_load;
512
512
513 // HK_LFR_CPU_LOAD_MAX
513 // HK_LFR_CPU_LOAD_MAX
514 if (cpu_load > resource_statistics[1])
514 if (cpu_load > resource_statistics[1])
515 {
515 {
516 resource_statistics[1] = cpu_load;
516 resource_statistics[1] = cpu_load;
517 }
517 }
518
518
519 // CPU_LOAD_AVE
519 // CPU_LOAD_AVE
520 resource_statistics[2] = 0;
520 resource_statistics[2] = 0;
521
521
522 #ifndef PRINT_TASK_STATISTICS
522 #ifndef PRINT_TASK_STATISTICS
523 rtems_cpu_usage_reset();
523 rtems_cpu_usage_reset();
524 #endif
524 #endif
525
525
526 }
526 }
527
528
529
@@ -1,610 +1,613
1 /** Functions related to the SpaceWire interface.
1 /** Functions related to the SpaceWire interface.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle SpaceWire transmissions:
6 * A group of functions to handle SpaceWire transmissions:
7 * - configuration of the SpaceWire link
7 * - configuration of the SpaceWire link
8 * - SpaceWire related interruption requests processing
8 * - SpaceWire related interruption requests processing
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
11 *
11 *
12 */
12 */
13
13
14 #include "fsw_spacewire.h"
14 #include "fsw_spacewire.h"
15
15
16 rtems_name semq_name;
16 rtems_name semq_name;
17 rtems_id semq_id;
17 rtems_id semq_id;
18
18
19 //***********
19 //***********
20 // RTEMS TASK
20 // RTEMS TASK
21 rtems_task spiq_task(rtems_task_argument unused)
21 rtems_task spiq_task(rtems_task_argument unused)
22 {
22 {
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
24 *
24 *
25 * @param unused is the starting argument of the RTEMS task
25 * @param unused is the starting argument of the RTEMS task
26 *
26 *
27 */
27 */
28
28
29 rtems_event_set event_out;
29 rtems_event_set event_out;
30 rtems_status_code status;
30 rtems_status_code status;
31 int linkStatus;
31 int linkStatus;
32
32
33 BOOT_PRINTF("in SPIQ *** \n")
33 BOOT_PRINTF("in SPIQ *** \n")
34
34
35 while(true){
35 while(true){
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
38
38
39 // [0] SUSPEND RECV AND SEND TASKS
39 // [0] SUSPEND RECV AND SEND TASKS
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 if ( status != RTEMS_SUCCESSFUL ) {
41 if ( status != RTEMS_SUCCESSFUL ) {
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 }
43 }
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 if ( status != RTEMS_SUCCESSFUL ) {
45 if ( status != RTEMS_SUCCESSFUL ) {
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 }
47 }
48
48
49 // [1] CHECK THE LINK
49 // [1] CHECK THE LINK
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
51 if ( linkStatus != 5) {
51 if ( linkStatus != 5) {
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
54 }
54 }
55
55
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
59 {
59 {
60 spacewire_compute_stats_offsets();
60 spacewire_compute_stats_offsets();
61 status = spacewire_reset_link( );
61 status = spacewire_reset_link( );
62 }
62 }
63 else // [2.b] in run state, start the link
63 else // [2.b] in run state, start the link
64 {
64 {
65 status = spacewire_stop_and_start_link( fdSPW ); // start the link
65 status = spacewire_stop_and_start_link( fdSPW ); // start the link
66 if ( status != RTEMS_SUCCESSFUL)
66 if ( status != RTEMS_SUCCESSFUL)
67 {
67 {
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
69 }
69 }
70 }
70 }
71
71
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
74 {
74 {
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
76 if ( status != RTEMS_SUCCESSFUL ) {
76 if ( status != RTEMS_SUCCESSFUL ) {
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
78 }
78 }
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
80 if ( status != RTEMS_SUCCESSFUL ) {
80 if ( status != RTEMS_SUCCESSFUL ) {
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
82 }
82 }
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();
86 status = stop_current_mode();
87 if ( status != RTEMS_SUCCESSFUL ) {
87 if ( status != RTEMS_SUCCESSFUL ) {
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 }
89 }
90 status = enter_mode( LFR_MODE_STANDBY, 0 );
90 status = enter_mode( LFR_MODE_STANDBY, 0 );
91 if ( status != RTEMS_SUCCESSFUL ) {
91 if ( status != RTEMS_SUCCESSFUL ) {
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 }
93 }
94 // wake the WTDG task up to wait for the link recovery
94 // wake the WTDG task up to wait for the link recovery
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 status = rtems_task_suspend( RTEMS_SELF );
96 status = rtems_task_suspend( RTEMS_SELF );
97 }
97 }
98 }
98 }
99 }
99 }
100
100
101 rtems_task recv_task( rtems_task_argument unused )
101 rtems_task recv_task( rtems_task_argument unused )
102 {
102 {
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 *
104 *
105 * @param unused is the starting argument of the RTEMS task
105 * @param unused is the starting argument of the RTEMS task
106 *
106 *
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
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.
108 * 1. It reads the incoming data.
109 * 2. Launches the acceptance procedure.
109 * 2. Launches the acceptance procedure.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 *
111 *
112 */
112 */
113
113
114 int len;
114 int len;
115 ccsdsTelecommandPacket_t currentTC;
115 ccsdsTelecommandPacket_t currentTC;
116 unsigned char computed_CRC[ 2 ];
116 unsigned char computed_CRC[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
118 unsigned char destinationID;
118 unsigned char destinationID;
119 unsigned int estimatedPacketLength;
119 unsigned int estimatedPacketLength;
120 unsigned int parserCode;
120 unsigned int parserCode;
121 rtems_status_code status;
121 rtems_status_code status;
122 rtems_id queue_recv_id;
122 rtems_id queue_recv_id;
123 rtems_id queue_send_id;
123 rtems_id queue_send_id;
124
124
125 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
125 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
126
126
127 status = get_message_queue_id_recv( &queue_recv_id );
127 status = get_message_queue_id_recv( &queue_recv_id );
128 if (status != RTEMS_SUCCESSFUL)
128 if (status != RTEMS_SUCCESSFUL)
129 {
129 {
130 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
130 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
131 }
131 }
132
132
133 status = get_message_queue_id_send( &queue_send_id );
133 status = get_message_queue_id_send( &queue_send_id );
134 if (status != RTEMS_SUCCESSFUL)
134 if (status != RTEMS_SUCCESSFUL)
135 {
135 {
136 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
136 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
137 }
137 }
138
138
139 BOOT_PRINTF("in RECV *** \n")
139 BOOT_PRINTF("in RECV *** \n")
140
140
141 while(1)
141 while(1)
142 {
142 {
143 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
143 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
144 if (len == -1){ // error during the read call
144 if (len == -1){ // error during the read call
145 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
145 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
146 }
146 }
147 else {
147 else {
148 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
148 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
149 PRINTF("in RECV *** packet lenght too short\n")
149 PRINTF("in RECV *** packet lenght too short\n")
150 }
150 }
151 else {
151 else {
152 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
152 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
155 // CHECK THE TC
155 // CHECK THE TC
156 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
156 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
160 || (parserCode == WRONG_SRC_ID) )
160 || (parserCode == WRONG_SRC_ID) )
161 { // send TM_LFR_TC_EXE_CORRUPTED
161 { // send TM_LFR_TC_EXE_CORRUPTED
162 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
162 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
164 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
166 )
167 {
167 {
168 if ( parserCode == WRONG_SRC_ID )
168 if ( parserCode == WRONG_SRC_ID )
169 {
169 {
170 destinationID = SID_TC_GROUND;
170 destinationID = SID_TC_GROUND;
171 }
171 }
172 else
172 else
173 {
173 {
174 destinationID = currentTC.sourceID;
174 destinationID = currentTC.sourceID;
175 }
175 }
176 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
176 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
177 computed_CRC, currentTC_LEN_RCV,
177 computed_CRC, currentTC_LEN_RCV,
178 destinationID );
178 destinationID );
179 }
179 }
180 }
180 }
181 else
181 else
182 { // send valid TC to the action launcher
182 { // send valid TC to the action launcher
183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
184 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
184 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
185 }
185 }
186 }
186 }
187 }
187 }
188 }
188 }
189 }
189 }
190
190
191 rtems_task send_task( rtems_task_argument argument)
191 rtems_task send_task( rtems_task_argument argument)
192 {
192 {
193 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
193 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
194 *
194 *
195 * @param unused is the starting argument of the RTEMS task
195 * @param unused is the starting argument of the RTEMS task
196 *
196 *
197 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
197 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
198 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
198 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
199 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
199 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
200 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
200 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
201 * data it contains.
201 * data it contains.
202 *
202 *
203 */
203 */
204
204
205 rtems_status_code status; // RTEMS status code
205 rtems_status_code status; // RTEMS status code
206 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
206 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
207 spw_ioctl_pkt_send *spw_ioctl_send;
207 spw_ioctl_pkt_send *spw_ioctl_send;
208 size_t size; // size of the incoming TC packet
208 size_t size; // size of the incoming TC packet
209 u_int32_t count;
209 u_int32_t count;
210 rtems_id queue_id;
210 rtems_id queue_id;
211 rtems_interrupt_level level;
211
212
212 status = get_message_queue_id_send( &queue_id );
213 status = get_message_queue_id_send( &queue_id );
213 if (status != RTEMS_SUCCESSFUL)
214 if (status != RTEMS_SUCCESSFUL)
214 {
215 {
215 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
216 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
216 }
217 }
217
218
218 BOOT_PRINTF("in SEND *** \n")
219 BOOT_PRINTF("in SEND *** \n")
219
220
220 while(1)
221 while(1)
221 {
222 {
222 status = rtems_message_queue_receive( queue_id, incomingData, &size,
223 status = rtems_message_queue_receive( queue_id, incomingData, &size,
223 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
224 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
224
225 rtems_interrupt_disable( level );
225 if (status!=RTEMS_SUCCESSFUL)
226 if (status!=RTEMS_SUCCESSFUL)
226 {
227 {
227 PRINTF1("in SEND *** (1) ERR = %d\n", status)
228 PRINTF1("in SEND *** (1) ERR = %d\n", status)
228 }
229 }
229 else
230 else
230 {
231 {
231 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
232 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
232 {
233 {
233 status = write( fdSPW, incomingData, size );
234 status = write( fdSPW, incomingData, size );
234 if (status == -1){
235 if (status == -1){
235 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
236 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
236 }
237 }
237 }
238 }
238 else // the incoming message is a spw_ioctl_pkt_send structure
239 else // the incoming message is a spw_ioctl_pkt_send structure
239 {
240 {
240 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
241 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
241 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
242 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
242 if (status == -1){
243 if (status == -1){
243 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
244 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
244 }
245 }
245 }
246 }
246 }
247 }
247
248
248 status = rtems_message_queue_get_number_pending( queue_id, &count );
249 status = rtems_message_queue_get_number_pending( queue_id, &count );
249 if (status != RTEMS_SUCCESSFUL)
250 if (status != RTEMS_SUCCESSFUL)
250 {
251 {
251 PRINTF1("in SEND *** (3) ERR = %d\n", status)
252 PRINTF1("in SEND *** (3) ERR = %d\n", status)
252 }
253 }
253 else
254 else
254 {
255 {
255 if (count > maxCount)
256 if (count > maxCount)
256 {
257 {
257 maxCount = count;
258 maxCount = count;
258 }
259 }
259 }
260 }
261
262 rtems_interrupt_enable( level );
260 }
263 }
261 }
264 }
262
265
263 rtems_task wtdg_task( rtems_task_argument argument )
266 rtems_task wtdg_task( rtems_task_argument argument )
264 {
267 {
265 rtems_event_set event_out;
268 rtems_event_set event_out;
266 rtems_status_code status;
269 rtems_status_code status;
267 int linkStatus;
270 int linkStatus;
268
271
269 BOOT_PRINTF("in WTDG ***\n")
272 BOOT_PRINTF("in WTDG ***\n")
270
273
271 while(1)
274 while(1)
272 {
275 {
273 // wait for an RTEMS_EVENT
276 // wait for an RTEMS_EVENT
274 rtems_event_receive( RTEMS_EVENT_0,
277 rtems_event_receive( RTEMS_EVENT_0,
275 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
278 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
276 PRINTF("in WTDG *** wait for the link\n")
279 PRINTF("in WTDG *** wait for the link\n")
277 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
280 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
278 while( linkStatus != 5) // wait for the link
281 while( linkStatus != 5) // wait for the link
279 {
282 {
280 rtems_task_wake_after( 10 );
283 rtems_task_wake_after( 10 );
281 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
284 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
282 }
285 }
283
286
284 status = spacewire_stop_and_start_link( fdSPW );
287 status = spacewire_stop_and_start_link( fdSPW );
285
288
286 if (status != RTEMS_SUCCESSFUL)
289 if (status != RTEMS_SUCCESSFUL)
287 {
290 {
288 PRINTF1("in WTDG *** ERR link not started %d\n", status)
291 PRINTF1("in WTDG *** ERR link not started %d\n", status)
289 }
292 }
290 else
293 else
291 {
294 {
292 PRINTF("in WTDG *** OK link started\n")
295 PRINTF("in WTDG *** OK link started\n")
293 }
296 }
294
297
295 // restart the SPIQ task
298 // restart the SPIQ task
296 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
299 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
297 if ( status != RTEMS_SUCCESSFUL ) {
300 if ( status != RTEMS_SUCCESSFUL ) {
298 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
301 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
299 }
302 }
300
303
301 // restart RECV and SEND
304 // restart RECV and SEND
302 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
305 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
303 if ( status != RTEMS_SUCCESSFUL ) {
306 if ( status != RTEMS_SUCCESSFUL ) {
304 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
307 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
305 }
308 }
306 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
309 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
307 if ( status != RTEMS_SUCCESSFUL ) {
310 if ( status != RTEMS_SUCCESSFUL ) {
308 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
311 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
309 }
312 }
310 }
313 }
311 }
314 }
312
315
313 //****************
316 //****************
314 // OTHER FUNCTIONS
317 // OTHER FUNCTIONS
315 int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);]
318 int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);]
316 {
319 {
317 /** This function opens the SpaceWire link.
320 /** This function opens the SpaceWire link.
318 *
321 *
319 * @return a valid file descriptor in case of success, -1 in case of a failure
322 * @return a valid file descriptor in case of success, -1 in case of a failure
320 *
323 *
321 */
324 */
322 rtems_status_code status;
325 rtems_status_code status;
323
326
324 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
327 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
325 if ( fdSPW < 0 ) {
328 if ( fdSPW < 0 ) {
326 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
329 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
327 }
330 }
328 else
331 else
329 {
332 {
330 status = RTEMS_SUCCESSFUL;
333 status = RTEMS_SUCCESSFUL;
331 }
334 }
332
335
333 return status;
336 return status;
334 }
337 }
335
338
336 int spacewire_start_link( int fd )
339 int spacewire_start_link( int fd )
337 {
340 {
338 rtems_status_code status;
341 rtems_status_code status;
339
342
340 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
343 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
341 // -1 default hardcoded driver timeout
344 // -1 default hardcoded driver timeout
342
345
343 return status;
346 return status;
344 }
347 }
345
348
346 int spacewire_stop_and_start_link( int fd )
349 int spacewire_stop_and_start_link( int fd )
347 {
350 {
348 rtems_status_code status;
351 rtems_status_code status;
349
352
350 status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
353 status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
351 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
354 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
352 // -1 default hardcoded driver timeout
355 // -1 default hardcoded driver timeout
353
356
354 return status;
357 return status;
355 }
358 }
356
359
357 int spacewire_configure_link( int fd )
360 int spacewire_configure_link( int fd )
358 {
361 {
359 /** This function configures the SpaceWire link.
362 /** This function configures the SpaceWire link.
360 *
363 *
361 * @return GR-RTEMS-DRIVER directive status codes:
364 * @return GR-RTEMS-DRIVER directive status codes:
362 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
365 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
363 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
366 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
364 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
367 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
365 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
368 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
366 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
369 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
367 * - 5 EIO - Error when writing to grswp hardware registers.
370 * - 5 EIO - Error when writing to grswp hardware registers.
368 * - 2 ENOENT - No such file or directory
371 * - 2 ENOENT - No such file or directory
369 */
372 */
370
373
371 rtems_status_code status;
374 rtems_status_code status;
372
375
373 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
376 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
377 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
375
378
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
379 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")
380 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
378 //
381 //
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
382 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
383 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
381 //
384 //
382 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
385 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")
386 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
384 //
387 //
385 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
388 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")
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
387 //
390 //
388 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
392 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
390 //
393 //
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
394 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")
395 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
393 //
396 //
394 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
397 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")
398 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
396
399
397 return status;
400 return status;
398 }
401 }
399
402
400 int spacewire_reset_link( void )
403 int spacewire_reset_link( void )
401 {
404 {
402 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
405 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
403 *
406 *
404 * @return RTEMS directive status code:
407 * @return RTEMS directive status code:
405 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
408 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
406 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
409 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
407 *
410 *
408 */
411 */
409
412
410 rtems_status_code status_spw;
413 rtems_status_code status_spw;
411 int i;
414 int i;
412
415
413 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
416 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
414 {
417 {
415 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
418 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
416
419
417 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
420 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
418
421
419 status_spw = spacewire_stop_and_start_link( fdSPW );
422 status_spw = spacewire_stop_and_start_link( fdSPW );
420 if ( status_spw != RTEMS_SUCCESSFUL )
423 if ( status_spw != RTEMS_SUCCESSFUL )
421 {
424 {
422 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
425 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
423 }
426 }
424
427
425 if ( status_spw == RTEMS_SUCCESSFUL)
428 if ( status_spw == RTEMS_SUCCESSFUL)
426 {
429 {
427 break;
430 break;
428 }
431 }
429 }
432 }
430
433
431 return status_spw;
434 return status_spw;
432 }
435 }
433
436
434 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
437 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
435 {
438 {
436 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
439 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
437 *
440 *
438 * @param val is the value, 0 or 1, used to set the value of the NP bit.
441 * @param val is the value, 0 or 1, used to set the value of the NP bit.
439 * @param regAddr is the address of the GRSPW control register.
442 * @param regAddr is the address of the GRSPW control register.
440 *
443 *
441 * NP is the bit 20 of the GRSPW control register.
444 * NP is the bit 20 of the GRSPW control register.
442 *
445 *
443 */
446 */
444
447
445 unsigned int *spwptr = (unsigned int*) regAddr;
448 unsigned int *spwptr = (unsigned int*) regAddr;
446
449
447 if (val == 1) {
450 if (val == 1) {
448 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
451 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
449 }
452 }
450 if (val== 0) {
453 if (val== 0) {
451 *spwptr = *spwptr & 0xffdfffff;
454 *spwptr = *spwptr & 0xffdfffff;
452 }
455 }
453 }
456 }
454
457
455 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
458 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
456 {
459 {
457 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
460 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
458 *
461 *
459 * @param val is the value, 0 or 1, used to set the value of the RE bit.
462 * @param val is the value, 0 or 1, used to set the value of the RE bit.
460 * @param regAddr is the address of the GRSPW control register.
463 * @param regAddr is the address of the GRSPW control register.
461 *
464 *
462 * RE is the bit 16 of the GRSPW control register.
465 * RE is the bit 16 of the GRSPW control register.
463 *
466 *
464 */
467 */
465
468
466 unsigned int *spwptr = (unsigned int*) regAddr;
469 unsigned int *spwptr = (unsigned int*) regAddr;
467
470
468 if (val == 1)
471 if (val == 1)
469 {
472 {
470 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
473 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
471 }
474 }
472 if (val== 0)
475 if (val== 0)
473 {
476 {
474 *spwptr = *spwptr & 0xfffdffff;
477 *spwptr = *spwptr & 0xfffdffff;
475 }
478 }
476 }
479 }
477
480
478 void spacewire_compute_stats_offsets( void )
481 void spacewire_compute_stats_offsets( void )
479 {
482 {
480 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
483 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
481 *
484 *
482 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
485 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
483 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
486 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
484 * during the open systel call).
487 * during the open systel call).
485 *
488 *
486 */
489 */
487
490
488 spw_stats spacewire_stats_grspw;
491 spw_stats spacewire_stats_grspw;
489 rtems_status_code status;
492 rtems_status_code status;
490
493
491 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
494 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
492
495
493 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
496 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
494 + spacewire_stats.packets_received;
497 + spacewire_stats.packets_received;
495 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
498 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
496 + spacewire_stats.packets_sent;
499 + spacewire_stats.packets_sent;
497 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
500 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
498 + spacewire_stats.parity_err;
501 + spacewire_stats.parity_err;
499 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
502 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
500 + spacewire_stats.disconnect_err;
503 + spacewire_stats.disconnect_err;
501 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
504 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
502 + spacewire_stats.escape_err;
505 + spacewire_stats.escape_err;
503 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
506 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
504 + spacewire_stats.credit_err;
507 + spacewire_stats.credit_err;
505 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
508 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
506 + spacewire_stats.write_sync_err;
509 + spacewire_stats.write_sync_err;
507 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
510 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
508 + spacewire_stats.rx_rmap_header_crc_err;
511 + spacewire_stats.rx_rmap_header_crc_err;
509 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
512 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
510 + spacewire_stats.rx_rmap_data_crc_err;
513 + spacewire_stats.rx_rmap_data_crc_err;
511 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
514 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
512 + spacewire_stats.early_ep;
515 + spacewire_stats.early_ep;
513 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
516 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
514 + spacewire_stats.invalid_address;
517 + spacewire_stats.invalid_address;
515 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
518 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
516 + spacewire_stats.rx_eep_err;
519 + spacewire_stats.rx_eep_err;
517 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
520 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
518 + spacewire_stats.rx_truncated;
521 + spacewire_stats.rx_truncated;
519 }
522 }
520
523
521 void spacewire_update_statistics( void )
524 void spacewire_update_statistics( void )
522 {
525 {
523 rtems_status_code status;
526 rtems_status_code status;
524 spw_stats spacewire_stats_grspw;
527 spw_stats spacewire_stats_grspw;
525
528
526 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
529 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
527
530
528 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
531 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
529 + spacewire_stats_grspw.packets_received;
532 + spacewire_stats_grspw.packets_received;
530 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
533 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
531 + spacewire_stats_grspw.packets_sent;
534 + spacewire_stats_grspw.packets_sent;
532 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
535 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
533 + spacewire_stats_grspw.parity_err;
536 + spacewire_stats_grspw.parity_err;
534 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
537 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
535 + spacewire_stats_grspw.disconnect_err;
538 + spacewire_stats_grspw.disconnect_err;
536 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
539 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
537 + spacewire_stats_grspw.escape_err;
540 + spacewire_stats_grspw.escape_err;
538 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
541 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
539 + spacewire_stats_grspw.credit_err;
542 + spacewire_stats_grspw.credit_err;
540 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
543 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
541 + spacewire_stats_grspw.write_sync_err;
544 + spacewire_stats_grspw.write_sync_err;
542 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
545 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
543 + spacewire_stats_grspw.rx_rmap_header_crc_err;
546 + spacewire_stats_grspw.rx_rmap_header_crc_err;
544 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
547 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
545 + spacewire_stats_grspw.rx_rmap_data_crc_err;
548 + spacewire_stats_grspw.rx_rmap_data_crc_err;
546 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
549 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
547 + spacewire_stats_grspw.early_ep;
550 + spacewire_stats_grspw.early_ep;
548 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
551 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
549 + spacewire_stats_grspw.invalid_address;
552 + spacewire_stats_grspw.invalid_address;
550 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
553 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
551 + spacewire_stats_grspw.rx_eep_err;
554 + spacewire_stats_grspw.rx_eep_err;
552 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
555 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
553 + spacewire_stats_grspw.rx_truncated;
556 + spacewire_stats_grspw.rx_truncated;
554 //spacewire_stats.tx_link_err;
557 //spacewire_stats.tx_link_err;
555
558
556 //****************************
559 //****************************
557 // DPU_SPACEWIRE_IF_STATISTICS
560 // DPU_SPACEWIRE_IF_STATISTICS
558 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
559 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
562 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
560 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
563 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
564 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
562 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
565 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
563 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
566 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
564
567
565 //******************************************
568 //******************************************
566 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
569 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
567 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
570 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
568 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
571 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
569 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
572 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
570 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
573 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
571 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
574 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
572
575
573 //*********************************************
576 //*********************************************
574 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
577 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
575 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
578 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
576 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
579 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
577 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
580 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
578 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
581 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
579 }
582 }
580
583
581 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
584 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
582 {
585 {
583 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 );
586 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 );
584 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
587 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
585
588
586 grgpio_regs->io_port_direction_register =
589 grgpio_regs->io_port_direction_register =
587 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
590 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
588
591
589 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
592 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
590 {
593 {
591 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
594 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
592 }
595 }
593 else
596 else
594 {
597 {
595 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
598 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
596 }
599 }
597 }
600 }
598
601
599 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
602 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
600 {
603 {
601 int linkStatus;
604 int linkStatus;
602 rtems_status_code status;
605 rtems_status_code status;
603
606
604 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
607 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
605
608
606 if ( linkStatus == 5) {
609 if ( linkStatus == 5) {
607 PRINTF("in spacewire_reset_link *** link is running\n")
610 PRINTF("in spacewire_reset_link *** link is running\n")
608 status = RTEMS_SUCCESSFUL;
611 status = RTEMS_SUCCESSFUL;
609 }
612 }
610 }
613 }
@@ -1,689 +1,691
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "fsw_processing.h"
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
11 #include "fsw_processing_globals.c"
12
12
13 unsigned int nb_sm_f0;
13 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0_aux_f1;
14 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f1;
15 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f0_aux_f2;
16 unsigned int nb_sm_f0_aux_f2;
17
17
18 //************************
18 //************************
19 // spectral matrices rings
19 // spectral matrices rings
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 ring_node_sm *current_ring_node_sm_f0;
23 ring_node_sm *current_ring_node_sm_f0;
24 ring_node_sm *current_ring_node_sm_f1;
24 ring_node_sm *current_ring_node_sm_f1;
25 ring_node_sm *current_ring_node_sm_f2;
25 ring_node_sm *current_ring_node_sm_f2;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
29
29
30 //***********************************************************
30 //***********************************************************
31 // Interrupt Service Routine for spectral matrices processing
31 // Interrupt Service Routine for spectral matrices processing
32
32
33 void spectral_matrices_isr_f0( void )
33 void spectral_matrices_isr_f0( void )
34 {
34 {
35 unsigned char status;
35 unsigned char status;
36 unsigned long long int time_0;
36 unsigned long long int time_0;
37 unsigned long long int time_1;
37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
39 unsigned long long int syncBit1;
40
40
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
42
42
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47
47
48 switch(status)
48 switch(status)
49 {
49 {
50 case 0:
50 case 0:
51 break;
51 break;
52 case 3:
52 case 3:
53 if ( time_0 < time_1 )
53 if ( time_0 < time_1 )
54 {
54 {
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
58 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
58 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
63 }
63 }
64 else
64 else
65 {
65 {
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
74 }
74 }
75 spectral_matrix_regs->status = 0x03; // [0011]
75 spectral_matrix_regs->status = 0x03; // [0011]
76 break;
76 break;
77 case 1:
77 case 1:
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
82 spectral_matrix_regs->status = 0x01; // [0001]
82 spectral_matrix_regs->status = 0x01; // [0001]
83 break;
83 break;
84 case 2:
84 case 2:
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
89 spectral_matrix_regs->status = 0x02; // [0010]
89 spectral_matrix_regs->status = 0x02; // [0010]
90 break;
90 break;
91 }
91 }
92 }
92 }
93
93
94 void spectral_matrices_isr_f1( void )
94 void spectral_matrices_isr_f1( void )
95 {
95 {
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
99
100 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
100 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
101
101
102 switch(status)
102 switch(status)
103 {
103 {
104 case 0:
104 case 0:
105 break;
105 break;
106 case 3:
106 case 3:
107 // UNEXPECTED VALUE
107 // UNEXPECTED VALUE
108 spectral_matrix_regs->status = 0xc0; // [1100]
108 spectral_matrix_regs->status = 0xc0; // [1100]
109 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
109 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
110 break;
110 break;
111 case 1:
111 case 1:
112 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
112 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
113 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
113 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
114 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
114 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
115 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
115 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
116 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
116 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
117 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
117 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
118 spectral_matrix_regs->status = 0x04; // [0100]
118 spectral_matrix_regs->status = 0x04; // [0100]
119 break;
119 break;
120 case 2:
120 case 2:
121 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
121 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
122 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
122 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
123 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
123 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
124 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
124 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
125 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
125 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
126 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
126 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
127 spectral_matrix_regs->status = 0x08; // [1000]
127 spectral_matrix_regs->status = 0x08; // [1000]
128 break;
128 break;
129 }
129 }
130 }
130 }
131
131
132 void spectral_matrices_isr_f2( void )
132 void spectral_matrices_isr_f2( void )
133 {
133 {
134 unsigned char status;
134 unsigned char status;
135
135
136 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
136 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
137
137
138 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
138 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
139
139
140 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
140 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
141
141
142 switch(status)
142 switch(status)
143 {
143 {
144 case 0:
144 case 0:
145 break;
145 break;
146 case 3:
146 case 3:
147 // UNEXPECTED VALUE
147 // UNEXPECTED VALUE
148 spectral_matrix_regs->status = 0x30; // [0011 0000]
148 spectral_matrix_regs->status = 0x30; // [0011 0000]
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
150 break;
150 break;
151 case 1:
151 case 1:
152 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
152 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
153 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
153 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
154 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
154 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
155 spectral_matrix_regs->status = 0x10; // [0001 0000]
155 spectral_matrix_regs->status = 0x10; // [0001 0000]
156 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
156 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
157 {
157 {
158 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
158 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
159 }
159 }
160 break;
160 break;
161 case 2:
161 case 2:
162 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
162 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
163 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
163 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
167 {
167 {
168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
169 }
169 }
170 break;
170 break;
171 }
171 }
172 }
172 }
173
173
174 void spectral_matrix_isr_error_handler( void )
174 void spectral_matrix_isr_error_handler( void )
175 {
175 {
176 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
176 // if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
177 {
177 // {
178 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
178 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
179 }
179 // }
180
181 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x83f;
180 }
182 }
181
183
182 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
184 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
183 {
185 {
184 // STATUS REGISTER
186 // STATUS REGISTER
185 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
187 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
186 // 10 9 8
188 // 10 9 8
187 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
189 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
188 // 7 6 5 4 3 2 1 0
190 // 7 6 5 4 3 2 1 0
189
191
190 spectral_matrices_isr_f0();
192 spectral_matrices_isr_f0();
191
193
192 spectral_matrices_isr_f1();
194 spectral_matrices_isr_f1();
193
195
194 spectral_matrices_isr_f2();
196 spectral_matrices_isr_f2();
195
197
196 // spectral_matrix_isr_error_handler();
198 // spectral_matrix_isr_error_handler();
197 }
199 }
198
200
199 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
201 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
200 {
202 {
201 //***
203 //***
202 // F0
204 // F0
203 nb_sm_f0 = nb_sm_f0 + 1;
205 nb_sm_f0 = nb_sm_f0 + 1;
204 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
206 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
205 {
207 {
206 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
208 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)
209 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
208 {
210 {
209 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
210 }
212 }
211 nb_sm_f0 = 0;
213 nb_sm_f0 = 0;
212 }
214 }
213
215
214 //***
216 //***
215 // F1
217 // F1
216 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
218 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
217 if (nb_sm_f0_aux_f1 == 6)
219 if (nb_sm_f0_aux_f1 == 6)
218 {
220 {
219 nb_sm_f0_aux_f1 = 0;
221 nb_sm_f0_aux_f1 = 0;
220 nb_sm_f1 = nb_sm_f1 + 1;
222 nb_sm_f1 = nb_sm_f1 + 1;
221 }
223 }
222 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
224 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
223 {
225 {
224 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
226 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)
227 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
226 {
228 {
227 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
229 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
228 }
230 }
229 nb_sm_f1 = 0;
231 nb_sm_f1 = 0;
230 }
232 }
231
233
232 //***
234 //***
233 // F2
235 // F2
234 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
236 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
235 if (nb_sm_f0_aux_f2 == 96)
237 if (nb_sm_f0_aux_f2 == 96)
236 {
238 {
237 nb_sm_f0_aux_f2 = 0;
239 nb_sm_f0_aux_f2 = 0;
238 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
240 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)
241 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
240 {
242 {
241 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
243 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
242 }
244 }
243 }
245 }
244 }
246 }
245
247
246 //******************
248 //******************
247 // Spectral Matrices
249 // Spectral Matrices
248
250
249 void reset_nb_sm( void )
251 void reset_nb_sm( void )
250 {
252 {
251 nb_sm_f0 = 0;
253 nb_sm_f0 = 0;
252 nb_sm_f0_aux_f1 = 0;
254 nb_sm_f0_aux_f1 = 0;
253 nb_sm_f0_aux_f2 = 0;
255 nb_sm_f0_aux_f2 = 0;
254
256
255 nb_sm_f1 = 0;
257 nb_sm_f1 = 0;
256 }
258 }
257
259
258 void SM_init_rings( void )
260 void SM_init_rings( void )
259 {
261 {
260 unsigned char i;
262 unsigned char i;
261
263
262 // F0 RING
264 // F0 RING
263 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
265 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
264 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
266 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
265 sm_ring_f0[0].buffer_address =
267 sm_ring_f0[0].buffer_address =
266 (int) &sm_f0[ 0 ];
268 (int) &sm_f0[ 0 ];
267
269
268 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
270 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
269 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
271 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
270 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
272 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
271 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
273 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
272
274
273 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
275 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
274 {
276 {
275 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
277 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
276 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
278 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
277 sm_ring_f0[i].buffer_address =
279 sm_ring_f0[i].buffer_address =
278 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
280 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
279 }
281 }
280
282
281 // F1 RING
283 // F1 RING
282 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
284 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
283 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
285 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
284 sm_ring_f1[0].buffer_address =
286 sm_ring_f1[0].buffer_address =
285 (int) &sm_f1[ 0 ];
287 (int) &sm_f1[ 0 ];
286
288
287 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
289 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
288 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
290 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
289 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
291 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
290 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
292 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
291
293
292 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
294 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
293 {
295 {
294 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
296 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
295 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
297 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
296 sm_ring_f1[i].buffer_address =
298 sm_ring_f1[i].buffer_address =
297 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
299 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
298 }
300 }
299
301
300 // F2 RING
302 // F2 RING
301 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
303 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
302 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
304 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
303 sm_ring_f2[0].buffer_address =
305 sm_ring_f2[0].buffer_address =
304 (int) &sm_f2[ 0 ];
306 (int) &sm_f2[ 0 ];
305
307
306 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
308 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
307 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
309 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
308 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
310 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
309 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
311 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
310
312
311 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
313 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
312 {
314 {
313 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
315 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
314 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
316 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
315 sm_ring_f2[i].buffer_address =
317 sm_ring_f2[i].buffer_address =
316 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
318 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
317 }
319 }
318
320
319 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
321 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
320 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
322 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
321 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
323 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
322
324
323 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
325 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
324 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
326 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
325 }
327 }
326
328
327 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
329 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
328 {
330 {
329 unsigned char i;
331 unsigned char i;
330
332
331 //***************
333 //***************
332 // BUFFER ADDRESS
334 // BUFFER ADDRESS
333 for(i=0; i<nbNodes; i++)
335 for(i=0; i<nbNodes; i++)
334 {
336 {
335 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
337 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
336 }
338 }
337
339
338 //*****
340 //*****
339 // NEXT
341 // NEXT
340 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
342 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
341 for(i=0; i<nbNodes-1; i++)
343 for(i=0; i<nbNodes-1; i++)
342 {
344 {
343 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
345 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
344 }
346 }
345
347
346 //*********
348 //*********
347 // PREVIOUS
349 // PREVIOUS
348 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
350 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
349 for(i=1; i<nbNodes; i++)
351 for(i=1; i<nbNodes; i++)
350 {
352 {
351 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
353 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
352 }
354 }
353 }
355 }
354
356
355 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
357 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
356 {
358 {
357 unsigned char i;
359 unsigned char i;
358
360
359 ring[ nbNodes - 1 ].next
361 ring[ nbNodes - 1 ].next
360 = (ring_node_asm*) &ring[ 0 ];
362 = (ring_node_asm*) &ring[ 0 ];
361
363
362 for(i=0; i<nbNodes-1; i++)
364 for(i=0; i<nbNodes-1; i++)
363 {
365 {
364 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
366 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
365 }
367 }
366 }
368 }
367
369
368 void SM_reset_current_ring_nodes( void )
370 void SM_reset_current_ring_nodes( void )
369 {
371 {
370 current_ring_node_sm_f0 = sm_ring_f0[0].next;
372 current_ring_node_sm_f0 = sm_ring_f0[0].next;
371 current_ring_node_sm_f1 = sm_ring_f1[0].next;
373 current_ring_node_sm_f1 = sm_ring_f1[0].next;
372 current_ring_node_sm_f2 = sm_ring_f2[0].next;
374 current_ring_node_sm_f2 = sm_ring_f2[0].next;
373
375
374 ring_node_for_averaging_sm_f0 = sm_ring_f0;
376 ring_node_for_averaging_sm_f0 = sm_ring_f0;
375 ring_node_for_averaging_sm_f1 = sm_ring_f1;
377 ring_node_for_averaging_sm_f1 = sm_ring_f1;
376 ring_node_for_averaging_sm_f2 = sm_ring_f2;
378 ring_node_for_averaging_sm_f2 = sm_ring_f2;
377 }
379 }
378
380
379 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
381 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
380 {
382 {
381 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
383 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
382 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
384 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
383 header->reserved = 0x00;
385 header->reserved = 0x00;
384 header->userApplication = CCSDS_USER_APP;
386 header->userApplication = CCSDS_USER_APP;
385 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
387 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
386 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
388 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
387 header->packetSequenceControl[0] = 0xc0;
389 header->packetSequenceControl[0] = 0xc0;
388 header->packetSequenceControl[1] = 0x00;
390 header->packetSequenceControl[1] = 0x00;
389 header->packetLength[0] = 0x00;
391 header->packetLength[0] = 0x00;
390 header->packetLength[1] = 0x00;
392 header->packetLength[1] = 0x00;
391 // DATA FIELD HEADER
393 // DATA FIELD HEADER
392 header->spare1_pusVersion_spare2 = 0x10;
394 header->spare1_pusVersion_spare2 = 0x10;
393 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
395 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
394 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
396 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
395 header->destinationID = TM_DESTINATION_ID_GROUND;
397 header->destinationID = TM_DESTINATION_ID_GROUND;
396 // AUXILIARY DATA HEADER
398 // AUXILIARY DATA HEADER
397 header->sid = 0x00;
399 header->sid = 0x00;
398 header->biaStatusInfo = 0x00;
400 header->biaStatusInfo = 0x00;
399 header->pa_lfr_pkt_cnt_asm = 0x00;
401 header->pa_lfr_pkt_cnt_asm = 0x00;
400 header->pa_lfr_pkt_nr_asm = 0x00;
402 header->pa_lfr_pkt_nr_asm = 0x00;
401 header->time[0] = 0x00;
403 header->time[0] = 0x00;
402 header->time[0] = 0x00;
404 header->time[0] = 0x00;
403 header->time[0] = 0x00;
405 header->time[0] = 0x00;
404 header->time[0] = 0x00;
406 header->time[0] = 0x00;
405 header->time[0] = 0x00;
407 header->time[0] = 0x00;
406 header->time[0] = 0x00;
408 header->time[0] = 0x00;
407 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
409 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
408 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
410 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
409 }
411 }
410
412
411 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
413 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
412 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
414 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
413 {
415 {
414 unsigned int i;
416 unsigned int i;
415 unsigned int length = 0;
417 unsigned int length = 0;
416 rtems_status_code status;
418 rtems_status_code status;
417
419
418 for (i=0; i<2; i++)
420 for (i=0; i<2; i++)
419 {
421 {
420 // (1) BUILD THE DATA
422 // (1) BUILD THE DATA
421 switch(sid)
423 switch(sid)
422 {
424 {
423 case SID_NORM_ASM_F0:
425 case SID_NORM_ASM_F0:
424 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
426 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
425 spw_ioctl_send->data = &spectral_matrix[
427 spw_ioctl_send->data = &spectral_matrix[
426 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
428 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
427 ];
429 ];
428 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
430 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
429 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
431 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
430 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
432 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
431 break;
433 break;
432 case SID_NORM_ASM_F1:
434 case SID_NORM_ASM_F1:
433 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
435 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
434 spw_ioctl_send->data = &spectral_matrix[
436 spw_ioctl_send->data = &spectral_matrix[
435 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
437 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
436 ];
438 ];
437 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
439 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
438 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
440 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
439 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
441 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
440 break;
442 break;
441 case SID_NORM_ASM_F2:
443 case SID_NORM_ASM_F2:
442 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
444 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
443 spw_ioctl_send->data = &spectral_matrix[
445 spw_ioctl_send->data = &spectral_matrix[
444 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
446 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
445 ];
447 ];
446 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
448 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
447 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
449 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
448 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
450 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
449 break;
451 break;
450 default:
452 default:
451 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
453 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
452 break;
454 break;
453 }
455 }
454 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
456 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
455 spw_ioctl_send->hdr = (char *) header;
457 spw_ioctl_send->hdr = (char *) header;
456 spw_ioctl_send->options = 0;
458 spw_ioctl_send->options = 0;
457
459
458 // (2) BUILD THE HEADER
460 // (2) BUILD THE HEADER
459 increment_seq_counter_source_id( header->packetSequenceControl, sid );
461 increment_seq_counter_source_id( header->packetSequenceControl, sid );
460 header->packetLength[0] = (unsigned char) (length>>8);
462 header->packetLength[0] = (unsigned char) (length>>8);
461 header->packetLength[1] = (unsigned char) (length);
463 header->packetLength[1] = (unsigned char) (length);
462 header->sid = (unsigned char) sid; // SID
464 header->sid = (unsigned char) sid; // SID
463 header->pa_lfr_pkt_cnt_asm = 2;
465 header->pa_lfr_pkt_cnt_asm = 2;
464 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
466 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
465
467
466 // (3) SET PACKET TIME
468 // (3) SET PACKET TIME
467 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
469 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
468 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
470 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
469 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
471 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
470 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
472 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
471 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
473 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
472 header->time[5] = (unsigned char) (time_management_regs->fine_time);
474 header->time[5] = (unsigned char) (time_management_regs->fine_time);
473 //
475 //
474 header->acquisitionTime[0] = header->time[0];
476 header->acquisitionTime[0] = header->time[0];
475 header->acquisitionTime[1] = header->time[1];
477 header->acquisitionTime[1] = header->time[1];
476 header->acquisitionTime[2] = header->time[2];
478 header->acquisitionTime[2] = header->time[2];
477 header->acquisitionTime[3] = header->time[3];
479 header->acquisitionTime[3] = header->time[3];
478 header->acquisitionTime[4] = header->time[4];
480 header->acquisitionTime[4] = header->time[4];
479 header->acquisitionTime[5] = header->time[5];
481 header->acquisitionTime[5] = header->time[5];
480
482
481 // (4) SEND PACKET
483 // (4) SEND PACKET
482 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
484 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
483 if (status != RTEMS_SUCCESSFUL) {
485 if (status != RTEMS_SUCCESSFUL) {
484 printf("in ASM_send *** ERR %d\n", (int) status);
486 printf("in ASM_send *** ERR %d\n", (int) status);
485 }
487 }
486 }
488 }
487 }
489 }
488
490
489 //*****************
491 //*****************
490 // Basic Parameters
492 // Basic Parameters
491
493
492 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
494 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
493 unsigned int apid, unsigned char sid,
495 unsigned int apid, unsigned char sid,
494 unsigned int packetLength, unsigned char blkNr )
496 unsigned int packetLength, unsigned char blkNr )
495 {
497 {
496 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
498 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
497 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
499 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
498 header->reserved = 0x00;
500 header->reserved = 0x00;
499 header->userApplication = CCSDS_USER_APP;
501 header->userApplication = CCSDS_USER_APP;
500 header->packetID[0] = (unsigned char) (apid >> 8);
502 header->packetID[0] = (unsigned char) (apid >> 8);
501 header->packetID[1] = (unsigned char) (apid);
503 header->packetID[1] = (unsigned char) (apid);
502 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
504 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
503 header->packetSequenceControl[1] = 0x00;
505 header->packetSequenceControl[1] = 0x00;
504 header->packetLength[0] = (unsigned char) (packetLength >> 8);
506 header->packetLength[0] = (unsigned char) (packetLength >> 8);
505 header->packetLength[1] = (unsigned char) (packetLength);
507 header->packetLength[1] = (unsigned char) (packetLength);
506 // DATA FIELD HEADER
508 // DATA FIELD HEADER
507 header->spare1_pusVersion_spare2 = 0x10;
509 header->spare1_pusVersion_spare2 = 0x10;
508 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
510 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
509 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
511 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
510 header->destinationID = TM_DESTINATION_ID_GROUND;
512 header->destinationID = TM_DESTINATION_ID_GROUND;
511 // AUXILIARY DATA HEADER
513 // AUXILIARY DATA HEADER
512 header->sid = sid;
514 header->sid = sid;
513 header->biaStatusInfo = 0x00;
515 header->biaStatusInfo = 0x00;
514 header->time[0] = 0x00;
516 header->time[0] = 0x00;
515 header->time[0] = 0x00;
517 header->time[0] = 0x00;
516 header->time[0] = 0x00;
518 header->time[0] = 0x00;
517 header->time[0] = 0x00;
519 header->time[0] = 0x00;
518 header->time[0] = 0x00;
520 header->time[0] = 0x00;
519 header->time[0] = 0x00;
521 header->time[0] = 0x00;
520 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
522 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
521 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
523 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
522 }
524 }
523
525
524 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
526 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
525 unsigned int apid, unsigned char sid,
527 unsigned int apid, unsigned char sid,
526 unsigned int packetLength , unsigned char blkNr)
528 unsigned int packetLength , unsigned char blkNr)
527 {
529 {
528 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
530 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
529 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
531 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
530 header->reserved = 0x00;
532 header->reserved = 0x00;
531 header->userApplication = CCSDS_USER_APP;
533 header->userApplication = CCSDS_USER_APP;
532 header->packetID[0] = (unsigned char) (apid >> 8);
534 header->packetID[0] = (unsigned char) (apid >> 8);
533 header->packetID[1] = (unsigned char) (apid);
535 header->packetID[1] = (unsigned char) (apid);
534 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
536 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
535 header->packetSequenceControl[1] = 0x00;
537 header->packetSequenceControl[1] = 0x00;
536 header->packetLength[0] = (unsigned char) (packetLength >> 8);
538 header->packetLength[0] = (unsigned char) (packetLength >> 8);
537 header->packetLength[1] = (unsigned char) (packetLength);
539 header->packetLength[1] = (unsigned char) (packetLength);
538 // DATA FIELD HEADER
540 // DATA FIELD HEADER
539 header->spare1_pusVersion_spare2 = 0x10;
541 header->spare1_pusVersion_spare2 = 0x10;
540 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
542 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
541 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
543 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
542 header->destinationID = TM_DESTINATION_ID_GROUND;
544 header->destinationID = TM_DESTINATION_ID_GROUND;
543 // AUXILIARY DATA HEADER
545 // AUXILIARY DATA HEADER
544 header->sid = sid;
546 header->sid = sid;
545 header->biaStatusInfo = 0x00;
547 header->biaStatusInfo = 0x00;
546 header->time[0] = 0x00;
548 header->time[0] = 0x00;
547 header->time[0] = 0x00;
549 header->time[0] = 0x00;
548 header->time[0] = 0x00;
550 header->time[0] = 0x00;
549 header->time[0] = 0x00;
551 header->time[0] = 0x00;
550 header->time[0] = 0x00;
552 header->time[0] = 0x00;
551 header->time[0] = 0x00;
553 header->time[0] = 0x00;
552 header->source_data_spare = 0x00;
554 header->source_data_spare = 0x00;
553 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
555 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
554 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
556 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
555 }
557 }
556
558
557 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
559 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
558 {
560 {
559 rtems_status_code status;
561 rtems_status_code status;
560
562
561 // SET THE SEQUENCE_CNT PARAMETER
563 // SET THE SEQUENCE_CNT PARAMETER
562 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
564 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
563 // SEND PACKET
565 // SEND PACKET
564 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
566 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
565 if (status != RTEMS_SUCCESSFUL)
567 if (status != RTEMS_SUCCESSFUL)
566 {
568 {
567 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
569 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
568 }
570 }
569 }
571 }
570
572
571 //******************
573 //******************
572 // general functions
574 // general functions
573
575
574 void reset_spectral_matrix_regs( void )
576 void reset_spectral_matrix_regs( void )
575 {
577 {
576 /** This function resets the spectral matrices module registers.
578 /** This function resets the spectral matrices module registers.
577 *
579 *
578 * The registers affected by this function are located at the following offset addresses:
580 * The registers affected by this function are located at the following offset addresses:
579 *
581 *
580 * - 0x00 config
582 * - 0x00 config
581 * - 0x04 status
583 * - 0x04 status
582 * - 0x08 matrixF0_Address0
584 * - 0x08 matrixF0_Address0
583 * - 0x10 matrixFO_Address1
585 * - 0x10 matrixFO_Address1
584 * - 0x14 matrixF1_Address
586 * - 0x14 matrixF1_Address
585 * - 0x18 matrixF2_Address
587 * - 0x18 matrixF2_Address
586 *
588 *
587 */
589 */
588
590
589 spectral_matrix_regs->config = 0x00;
591 spectral_matrix_regs->config = 0x00;
590 spectral_matrix_regs->status = 0x00;
592 spectral_matrix_regs->status = 0x00;
591
593
592 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
594 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
593 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
595 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
594 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
596 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
595 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
597 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
596 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
598 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
597 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
599 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
598 }
600 }
599
601
600 void set_time( unsigned char *time, unsigned char * timeInBuffer )
602 void set_time( unsigned char *time, unsigned char * timeInBuffer )
601 {
603 {
602 time[0] = timeInBuffer[0];
604 time[0] = timeInBuffer[0];
603 time[1] = timeInBuffer[1];
605 time[1] = timeInBuffer[1];
604 time[2] = timeInBuffer[2];
606 time[2] = timeInBuffer[2];
605 time[3] = timeInBuffer[3];
607 time[3] = timeInBuffer[3];
606 time[4] = timeInBuffer[6];
608 time[4] = timeInBuffer[6];
607 time[5] = timeInBuffer[7];
609 time[5] = timeInBuffer[7];
608 }
610 }
609
611
610 unsigned long long int get_acquisition_time( unsigned char *timePtr )
612 unsigned long long int get_acquisition_time( unsigned char *timePtr )
611 {
613 {
612 unsigned long long int acquisitionTimeAslong;
614 unsigned long long int acquisitionTimeAslong;
613 acquisitionTimeAslong = 0x00;
615 acquisitionTimeAslong = 0x00;
614 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
616 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
615 + ( (unsigned long long int) timePtr[1] << 32 )
617 + ( (unsigned long long int) timePtr[1] << 32 )
616 + ( (unsigned long long int) timePtr[2] << 24 )
618 + ( (unsigned long long int) timePtr[2] << 24 )
617 + ( (unsigned long long int) timePtr[3] << 16 )
619 + ( (unsigned long long int) timePtr[3] << 16 )
618 + ( (unsigned long long int) timePtr[6] << 8 )
620 + ( (unsigned long long int) timePtr[6] << 8 )
619 + ( (unsigned long long int) timePtr[7] );
621 + ( (unsigned long long int) timePtr[7] );
620 return acquisitionTimeAslong;
622 return acquisitionTimeAslong;
621 }
623 }
622
624
623 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
625 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
624 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
626 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
625 unsigned long long int time )
627 unsigned long long int time )
626 {
628 {
627 unsigned char *timePtr;
629 unsigned char *timePtr;
628 unsigned char *coarseTimePtr;
630 unsigned char *coarseTimePtr;
629 unsigned char *fineTimePtr;
631 unsigned char *fineTimePtr;
630
632
631 timePtr = (unsigned char *) &time;
633 timePtr = (unsigned char *) &time;
632 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
634 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
633 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
635 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
634
636
635 *nb_sm = *nb_sm + 1;
637 *nb_sm = *nb_sm + 1;
636 if (*nb_sm == nb_sm_before_avf)
638 if (*nb_sm == nb_sm_before_avf)
637 {
639 {
638 node_for_averaging = ringNode;
640 node_for_averaging = ringNode;
639 coarseTimePtr[0] = timePtr[2];
641 coarseTimePtr[0] = timePtr[2];
640 coarseTimePtr[1] = timePtr[3];
642 coarseTimePtr[1] = timePtr[3];
641 coarseTimePtr[2] = timePtr[4];
643 coarseTimePtr[2] = timePtr[4];
642 coarseTimePtr[3] = timePtr[5];
644 coarseTimePtr[3] = timePtr[5];
643 fineTimePtr[2] = timePtr[6];
645 fineTimePtr[2] = timePtr[6];
644 fineTimePtr[3] = timePtr[7];
646 fineTimePtr[3] = timePtr[7];
645 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
647 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
646 {
648 {
647 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
649 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
648 }
650 }
649 *nb_sm = 0;
651 *nb_sm = 0;
650 }
652 }
651 }
653 }
652
654
653 unsigned char getSID( rtems_event_set event )
655 unsigned char getSID( rtems_event_set event )
654 {
656 {
655 unsigned char sid;
657 unsigned char sid;
656
658
657 rtems_event_set eventSetBURST;
659 rtems_event_set eventSetBURST;
658 rtems_event_set eventSetSBM;
660 rtems_event_set eventSetSBM;
659
661
660 //******
662 //******
661 // BURST
663 // BURST
662 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
664 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
663 | RTEMS_EVENT_BURST_BP1_F1
665 | RTEMS_EVENT_BURST_BP1_F1
664 | RTEMS_EVENT_BURST_BP2_F0
666 | RTEMS_EVENT_BURST_BP2_F0
665 | RTEMS_EVENT_BURST_BP2_F1;
667 | RTEMS_EVENT_BURST_BP2_F1;
666
668
667 //****
669 //****
668 // SBM
670 // SBM
669 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
671 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
670 | RTEMS_EVENT_SBM_BP1_F1
672 | RTEMS_EVENT_SBM_BP1_F1
671 | RTEMS_EVENT_SBM_BP2_F0
673 | RTEMS_EVENT_SBM_BP2_F0
672 | RTEMS_EVENT_SBM_BP2_F1;
674 | RTEMS_EVENT_SBM_BP2_F1;
673
675
674 if (event & eventSetBURST)
676 if (event & eventSetBURST)
675 {
677 {
676 sid = SID_BURST_BP1_F0;
678 sid = SID_BURST_BP1_F0;
677 }
679 }
678 else if (event & eventSetSBM)
680 else if (event & eventSetSBM)
679 {
681 {
680 sid = SID_SBM1_BP1_F0;
682 sid = SID_SBM1_BP1_F0;
681 }
683 }
682 else
684 else
683 {
685 {
684 sid = 0;
686 sid = 0;
685 }
687 }
686
688
687 return sid;
689 return sid;
688 }
690 }
689
691
@@ -1,948 +1,1002
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14
14
15 //***********
15 //***********
16 // RTEMS TASK
16 // RTEMS TASK
17
17
18 rtems_task actn_task( rtems_task_argument unused )
18 rtems_task actn_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 *
22 * @param unused is the starting argument of the RTEMS task
22 * @param unused is the starting argument of the RTEMS task
23 *
23 *
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * on the incoming TeleCommand.
25 * on the incoming TeleCommand.
26 *
26 *
27 */
27 */
28
28
29 int result;
29 int result;
30 rtems_status_code status; // RTEMS status code
30 rtems_status_code status; // RTEMS status code
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 size_t size; // size of the incoming TC packet
32 size_t size; // size of the incoming TC packet
33 unsigned char subtype; // subtype of the current TC packet
33 unsigned char subtype; // subtype of the current TC packet
34 unsigned char time[6];
34 unsigned char time[6];
35 rtems_id queue_rcv_id;
35 rtems_id queue_rcv_id;
36 rtems_id queue_snd_id;
36 rtems_id queue_snd_id;
37
37
38 status = get_message_queue_id_recv( &queue_rcv_id );
38 status = get_message_queue_id_recv( &queue_rcv_id );
39 if (status != RTEMS_SUCCESSFUL)
39 if (status != RTEMS_SUCCESSFUL)
40 {
40 {
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 }
42 }
43
43
44 status = get_message_queue_id_send( &queue_snd_id );
44 status = get_message_queue_id_send( &queue_snd_id );
45 if (status != RTEMS_SUCCESSFUL)
45 if (status != RTEMS_SUCCESSFUL)
46 {
46 {
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 }
48 }
49
49
50 result = LFR_SUCCESSFUL;
50 result = LFR_SUCCESSFUL;
51 subtype = 0; // subtype of the current TC packet
51 subtype = 0; // subtype of the current TC packet
52
52
53 BOOT_PRINTF("in ACTN *** \n")
53 BOOT_PRINTF("in ACTN *** \n")
54
54
55 while(1)
55 while(1)
56 {
56 {
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 getTime( time ); // set time to the current time
59 getTime( time ); // set time to the current time
60 if (status!=RTEMS_SUCCESSFUL)
60 if (status!=RTEMS_SUCCESSFUL)
61 {
61 {
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 }
63 }
64 else
64 else
65 {
65 {
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_RESET:
70 result = action_reset( &TC, queue_snd_id, time );
70 result = action_reset( &TC, queue_snd_id, time );
71 close_action( &TC, result, queue_snd_id );
71 close_action( &TC, result, queue_snd_id );
72 break;
72 break;
73 //
73 //
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 //
78 //
79 case TC_SUBTYPE_LOAD_NORM:
79 case TC_SUBTYPE_LOAD_NORM:
80 result = action_load_normal_par( &TC, queue_snd_id, time );
80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 close_action( &TC, result, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 break;
82 break;
83 //
83 //
84 case TC_SUBTYPE_LOAD_BURST:
84 case TC_SUBTYPE_LOAD_BURST:
85 result = action_load_burst_par( &TC, queue_snd_id, time );
85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 close_action( &TC, result, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
87 break;
87 break;
88 //
88 //
89 case TC_SUBTYPE_LOAD_SBM1:
89 case TC_SUBTYPE_LOAD_SBM1:
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 close_action( &TC, result, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
92 break;
92 break;
93 //
93 //
94 case TC_SUBTYPE_LOAD_SBM2:
94 case TC_SUBTYPE_LOAD_SBM2:
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 //
98 //
99 case TC_SUBTYPE_DUMP:
99 case TC_SUBTYPE_DUMP:
100 result = action_dump_par( queue_snd_id );
100 result = action_dump_par( queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
102 break;
103 //
103 //
104 case TC_SUBTYPE_ENTER:
104 case TC_SUBTYPE_ENTER:
105 result = action_enter_mode( &TC, queue_snd_id );
105 result = action_enter_mode( &TC, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
107 break;
107 break;
108 //
108 //
109 case TC_SUBTYPE_UPDT_INFO:
109 case TC_SUBTYPE_UPDT_INFO:
110 result = action_update_info( &TC, queue_snd_id );
110 result = action_update_info( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
112 break;
113 //
113 //
114 case TC_SUBTYPE_EN_CAL:
114 case TC_SUBTYPE_EN_CAL:
115 result = action_enable_calibration( &TC, queue_snd_id, time );
115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 //
118 //
119 case TC_SUBTYPE_DIS_CAL:
119 case TC_SUBTYPE_DIS_CAL:
120 result = action_disable_calibration( &TC, queue_snd_id, time );
120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
121 close_action( &TC, result, queue_snd_id );
122 break;
122 break;
123 //
123 //
124 case TC_SUBTYPE_UPDT_TIME:
124 case TC_SUBTYPE_UPDT_TIME:
125 result = action_update_time( &TC );
125 result = action_update_time( &TC );
126 close_action( &TC, result, queue_snd_id );
126 close_action( &TC, result, queue_snd_id );
127 break;
127 break;
128 //
128 //
129 default:
129 default:
130 break;
130 break;
131 }
131 }
132 }
132 }
133 }
133 }
134 }
134 }
135
135
136 //***********
136 //***********
137 // TC ACTIONS
137 // TC ACTIONS
138
138
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
140 {
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 *
142 *
143 * @param TC points to the TeleCommand packet that is being processed
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
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 *
145 *
146 */
146 */
147
147
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 return LFR_DEFAULT;
149 return LFR_DEFAULT;
150 }
150 }
151
151
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
153 {
153 {
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 *
155 *
156 * @param TC points to the TeleCommand packet that is being processed
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
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 *
158 *
159 */
159 */
160
160
161 rtems_status_code status;
161 rtems_status_code status;
162 unsigned char requestedMode;
162 unsigned char requestedMode;
163 unsigned int *transitionCoarseTime_ptr;
163 unsigned int *transitionCoarseTime_ptr;
164 unsigned int transitionCoarseTime;
164 unsigned int transitionCoarseTime;
165 unsigned char * bytePosPtr;
165 unsigned char * bytePosPtr;
166
166
167 bytePosPtr = (unsigned char *) &TC->packetID;
167 bytePosPtr = (unsigned char *) &TC->packetID;
168
168
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
172
172
173 status = check_mode_value( requestedMode );
173 status = check_mode_value( requestedMode );
174
174
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
176 {
176 {
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
178 }
178 }
179 else // the mode value is consistent, check the transition
179 else // the mode value is consistent, check the transition
180 {
180 {
181 status = check_mode_transition(requestedMode);
181 status = check_mode_transition(requestedMode);
182 if (status != LFR_SUCCESSFUL)
182 if (status != LFR_SUCCESSFUL)
183 {
183 {
184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
186 }
186 }
187 }
187 }
188
188
189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
190 {
190 {
191 status = check_transition_date( transitionCoarseTime );
191 status = check_transition_date( transitionCoarseTime );
192 if (status != LFR_SUCCESSFUL)
192 if (status != LFR_SUCCESSFUL)
193 {
193 {
194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
198 }
198 }
199 }
199 }
200
200
201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
202 {
202 {
203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
204 status = enter_mode( requestedMode, transitionCoarseTime );
204 status = enter_mode( requestedMode, transitionCoarseTime );
205 }
205 }
206
206
207 return status;
207 return status;
208 }
208 }
209
209
210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
211 {
211 {
212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
213 *
213 *
214 * @param TC points to the TeleCommand packet that is being processed
214 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
216 *
216 *
217 * @return LFR directive status code:
217 * @return LFR directive status code:
218 * - LFR_DEFAULT
218 * - LFR_DEFAULT
219 * - LFR_SUCCESSFUL
219 * - LFR_SUCCESSFUL
220 *
220 *
221 */
221 */
222
222
223 unsigned int val;
223 unsigned int val;
224 int result;
224 int result;
225 unsigned int status;
225 unsigned int status;
226 unsigned char mode;
226 unsigned char mode;
227 unsigned char * bytePosPtr;
227 unsigned char * bytePosPtr;
228
228
229 bytePosPtr = (unsigned char *) &TC->packetID;
229 bytePosPtr = (unsigned char *) &TC->packetID;
230
230
231 // check LFR mode
231 // check LFR mode
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
233 status = check_update_info_hk_lfr_mode( mode );
233 status = check_update_info_hk_lfr_mode( mode );
234 if (status == LFR_SUCCESSFUL) // check TDS mode
234 if (status == LFR_SUCCESSFUL) // check TDS mode
235 {
235 {
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
237 status = check_update_info_hk_tds_mode( mode );
237 status = check_update_info_hk_tds_mode( mode );
238 }
238 }
239 if (status == LFR_SUCCESSFUL) // check THR mode
239 if (status == LFR_SUCCESSFUL) // check THR mode
240 {
240 {
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
242 status = check_update_info_hk_thr_mode( mode );
242 status = check_update_info_hk_thr_mode( mode );
243 }
243 }
244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
245 {
245 {
246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
248 val++;
248 val++;
249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
251 }
251 }
252
252
253 result = status;
253 result = status;
254
254
255 return result;
255 return result;
256 }
256 }
257
257
258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 {
259 {
260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
261 *
261 *
262 * @param TC points to the TeleCommand packet that is being processed
262 * @param TC points to the TeleCommand packet that is being processed
263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
264 *
264 *
265 */
265 */
266
266
267 int result;
267 int result;
268 unsigned char lfrMode;
268 unsigned char lfrMode;
269
269
270 result = LFR_DEFAULT;
270 result = LFR_DEFAULT;
271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272
272
273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
274 result = LFR_DEFAULT;
274 result = LFR_DEFAULT;
275
275
276 return result;
276 return result;
277 }
277 }
278
278
279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 {
280 {
281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
282 *
282 *
283 * @param TC points to the TeleCommand packet that is being processed
283 * @param TC points to the TeleCommand packet that is being processed
284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
285 *
285 *
286 */
286 */
287
287
288 int result;
288 int result;
289 unsigned char lfrMode;
289 unsigned char lfrMode;
290
290
291 result = LFR_DEFAULT;
291 result = LFR_DEFAULT;
292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
293
293
294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
295 result = LFR_DEFAULT;
295 result = LFR_DEFAULT;
296
296
297 return result;
297 return result;
298 }
298 }
299
299
300 int action_update_time(ccsdsTelecommandPacket_t *TC)
300 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 {
301 {
302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 *
303 *
304 * @param TC points to the TeleCommand packet that is being processed
304 * @param TC points to the TeleCommand packet that is being processed
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 *
306 *
307 * @return LFR_SUCCESSFUL
307 * @return LFR_SUCCESSFUL
308 *
308 *
309 */
309 */
310
310
311 unsigned int val;
311 unsigned int val;
312
312
313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 + (TC->dataAndCRC[1] << 16)
314 + (TC->dataAndCRC[1] << 16)
315 + (TC->dataAndCRC[2] << 8)
315 + (TC->dataAndCRC[2] << 8)
316 + TC->dataAndCRC[3];
316 + TC->dataAndCRC[3];
317
317
318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
319
319
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
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
325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326
326
327 return LFR_SUCCESSFUL;
327 return LFR_SUCCESSFUL;
328 }
328 }
329
329
330 //*******************
330 //*******************
331 // ENTERING THE MODES
331 // ENTERING THE MODES
332 int check_mode_value( unsigned char requestedMode )
332 int check_mode_value( unsigned char requestedMode )
333 {
333 {
334 int status;
334 int status;
335
335
336 if ( (requestedMode != LFR_MODE_STANDBY)
336 if ( (requestedMode != LFR_MODE_STANDBY)
337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
339 {
339 {
340 status = LFR_DEFAULT;
340 status = LFR_DEFAULT;
341 }
341 }
342 else
342 else
343 {
343 {
344 status = LFR_SUCCESSFUL;
344 status = LFR_SUCCESSFUL;
345 }
345 }
346
346
347 return status;
347 return status;
348 }
348 }
349
349
350 int check_mode_transition( unsigned char requestedMode )
350 int check_mode_transition( unsigned char requestedMode )
351 {
351 {
352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
353 *
353 *
354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
355 *
355 *
356 * @return LFR directive status codes:
356 * @return LFR directive status codes:
357 * - LFR_SUCCESSFUL - the transition is authorized
357 * - LFR_SUCCESSFUL - the transition is authorized
358 * - LFR_DEFAULT - the transition is not authorized
358 * - LFR_DEFAULT - the transition is not authorized
359 *
359 *
360 */
360 */
361
361
362 int status;
362 int status;
363
363
364 switch (requestedMode)
364 switch (requestedMode)
365 {
365 {
366 case LFR_MODE_STANDBY:
366 case LFR_MODE_STANDBY:
367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
368 status = LFR_DEFAULT;
368 status = LFR_DEFAULT;
369 }
369 }
370 else
370 else
371 {
371 {
372 status = LFR_SUCCESSFUL;
372 status = LFR_SUCCESSFUL;
373 }
373 }
374 break;
374 break;
375 case LFR_MODE_NORMAL:
375 case LFR_MODE_NORMAL:
376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
377 status = LFR_DEFAULT;
377 status = LFR_DEFAULT;
378 }
378 }
379 else {
379 else {
380 status = LFR_SUCCESSFUL;
380 status = LFR_SUCCESSFUL;
381 }
381 }
382 break;
382 break;
383 case LFR_MODE_BURST:
383 case LFR_MODE_BURST:
384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
385 status = LFR_DEFAULT;
385 status = LFR_DEFAULT;
386 }
386 }
387 else {
387 else {
388 status = LFR_SUCCESSFUL;
388 status = LFR_SUCCESSFUL;
389 }
389 }
390 break;
390 break;
391 case LFR_MODE_SBM1:
391 case LFR_MODE_SBM1:
392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
393 status = LFR_DEFAULT;
393 status = LFR_DEFAULT;
394 }
394 }
395 else {
395 else {
396 status = LFR_SUCCESSFUL;
396 status = LFR_SUCCESSFUL;
397 }
397 }
398 break;
398 break;
399 case LFR_MODE_SBM2:
399 case LFR_MODE_SBM2:
400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
401 status = LFR_DEFAULT;
401 status = LFR_DEFAULT;
402 }
402 }
403 else {
403 else {
404 status = LFR_SUCCESSFUL;
404 status = LFR_SUCCESSFUL;
405 }
405 }
406 break;
406 break;
407 default:
407 default:
408 status = LFR_DEFAULT;
408 status = LFR_DEFAULT;
409 break;
409 break;
410 }
410 }
411
411
412 return status;
412 return status;
413 }
413 }
414
414
415 int check_transition_date( unsigned int transitionCoarseTime )
415 int check_transition_date( unsigned int transitionCoarseTime )
416 {
416 {
417 int status;
417 int status;
418 unsigned int localCoarseTime;
418 unsigned int localCoarseTime;
419 unsigned int deltaCoarseTime;
419 unsigned int deltaCoarseTime;
420
420
421 status = LFR_SUCCESSFUL;
421 status = LFR_SUCCESSFUL;
422
422
423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
424 {
424 {
425 status = LFR_SUCCESSFUL;
425 status = LFR_SUCCESSFUL;
426 }
426 }
427 else
427 else
428 {
428 {
429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
430
430
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
432 {
432 {
433 status = LFR_DEFAULT;
433 status = LFR_DEFAULT;
434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
435 }
435 }
436
436
437 if (status == LFR_SUCCESSFUL)
437 if (status == LFR_SUCCESSFUL)
438 {
438 {
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
441 {
441 {
442 status = LFR_DEFAULT;
442 status = LFR_DEFAULT;
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
444 }
444 }
445 }
445 }
446 }
446 }
447
447
448 return status;
448 return status;
449 }
449 }
450
450
451 int stop_current_mode( void )
451 int stop_current_mode( void )
452 {
452 {
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
454 *
454 *
455 * @return RTEMS directive status codes:
455 * @return RTEMS directive status codes:
456 * - RTEMS_SUCCESSFUL - task restarted successfully
456 * - RTEMS_SUCCESSFUL - task restarted successfully
457 * - RTEMS_INVALID_ID - task id invalid
457 * - RTEMS_INVALID_ID - task id invalid
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
459 *
459 *
460 */
460 */
461
461
462 rtems_status_code status;
462 rtems_status_code status;
463
463
464 status = RTEMS_SUCCESSFUL;
464 status = RTEMS_SUCCESSFUL;
465
465
466 // (1) mask interruptions
466 // (1) mask interruptions
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469
469
470 // (2) clear interruptions
470 // (2) clear interruptions
471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
473
473
474 // (3) reset waveform picker registers
474 // (3) reset waveform picker registers
475 reset_wfp_burst_enable(); // reset burst and enable bits
475 reset_wfp_burst_enable(); // reset burst and enable bits
476 reset_wfp_status(); // reset all the status bits
476 reset_wfp_status(); // reset all the status bits
477
477
478 // (4) reset spectral matrices registers
478 // (4) reset spectral matrices registers
479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
481 reset_extractSWF(); // reset the extractSWF flag to false
481 reset_extractSWF(); // reset the extractSWF flag to false
482
482
483 // <Spectral Matrices simulator>
483 // <Spectral Matrices simulator>
484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
487 // </Spectral Matrices simulator>
487 // </Spectral Matrices simulator>
488
488
489 // suspend several tasks
489 // suspend several tasks
490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
491 status = suspend_science_tasks();
491 status = suspend_science_tasks();
492 }
492 }
493
493
494 if (status != RTEMS_SUCCESSFUL)
494 if (status != RTEMS_SUCCESSFUL)
495 {
495 {
496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
497 }
497 }
498
498
499 return status;
499 return status;
500 }
500 }
501
501
502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
503 {
503 {
504 /** This function is launched after a mode transition validation.
504 /** This function is launched after a mode transition validation.
505 *
505 *
506 * @param mode is the mode in which LFR will be put.
506 * @param mode is the mode in which LFR will be put.
507 *
507 *
508 * @return RTEMS directive status codes:
508 * @return RTEMS directive status codes:
509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
511 *
511 *
512 */
512 */
513
513
514 rtems_status_code status;
514 rtems_status_code status;
515
515
516 //**********************
516 //**********************
517 // STOP THE CURRENT MODE
517 // STOP THE CURRENT MODE
518 status = stop_current_mode();
518 status = stop_current_mode();
519 if (status != RTEMS_SUCCESSFUL)
519 if (status != RTEMS_SUCCESSFUL)
520 {
520 {
521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
522 }
522 }
523
523
524 //*************************
524 //*************************
525 // ENTER THE REQUESTED MODE
525 // ENTER THE REQUESTED MODE
526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
528 {
528 {
529 #ifdef PRINT_TASK_STATISTICS
529 #ifdef PRINT_TASK_STATISTICS
530 rtems_cpu_usage_reset();
530 rtems_cpu_usage_reset();
531 maxCount = 0;
531 maxCount = 0;
532 #endif
532 #endif
533 status = restart_science_tasks( mode );
533 status = restart_science_tasks( mode );
534 //****************
535 // WAVEFORM PICKER
534 launch_waveform_picker( mode, transitionCoarseTime );
536 launch_waveform_picker( mode, transitionCoarseTime );
535 launch_spectral_matrix( );
537 // launch_waveform_picker_spool( mode, transitionCoarseTime );
538
539 //******************
540 // SPECTRAL MATRICES
541 // launch_spectral_matrix( );
536 // launch_spectral_matrix_simu( );
542 // launch_spectral_matrix_simu( );
543 launch_spectral_matrix_spool( );
537 }
544 }
538 else if ( mode == LFR_MODE_STANDBY )
545 else if ( mode == LFR_MODE_STANDBY )
539 {
546 {
540 #ifdef PRINT_TASK_STATISTICS
547 #ifdef PRINT_TASK_STATISTICS
541 rtems_cpu_usage_report();
548 rtems_cpu_usage_report();
542 #endif
549 #endif
543
550
544 #ifdef PRINT_STACK_REPORT
551 #ifdef PRINT_STACK_REPORT
545 PRINTF("stack report selected\n")
552 PRINTF("stack report selected\n")
546 rtems_stack_checker_report_usage();
553 rtems_stack_checker_report_usage();
547 #endif
554 #endif
548 PRINTF1("maxCount = %d\n", maxCount)
555 PRINTF1("maxCount = %d\n", maxCount)
549 }
556 }
550 else
557 else
551 {
558 {
552 status = RTEMS_UNSATISFIED;
559 status = RTEMS_UNSATISFIED;
553 }
560 }
554
561
555 if (status != RTEMS_SUCCESSFUL)
562 if (status != RTEMS_SUCCESSFUL)
556 {
563 {
557 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
564 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
558 status = RTEMS_UNSATISFIED;
565 status = RTEMS_UNSATISFIED;
559 }
566 }
560
567
561 return status;
568 return status;
562 }
569 }
563
570
564 int restart_science_tasks(unsigned char lfrRequestedMode )
571 int restart_science_tasks(unsigned char lfrRequestedMode )
565 {
572 {
566 /** This function is used to restart all science tasks.
573 /** This function is used to restart all science tasks.
567 *
574 *
568 * @return RTEMS directive status codes:
575 * @return RTEMS directive status codes:
569 * - RTEMS_SUCCESSFUL - task restarted successfully
576 * - RTEMS_SUCCESSFUL - task restarted successfully
570 * - RTEMS_INVALID_ID - task id invalid
577 * - RTEMS_INVALID_ID - task id invalid
571 * - RTEMS_INCORRECT_STATE - task never started
578 * - RTEMS_INCORRECT_STATE - task never started
572 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
579 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
573 *
580 *
574 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
581 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
575 *
582 *
576 */
583 */
577
584
578 rtems_status_code status[10];
585 rtems_status_code status[11];
579 rtems_status_code ret;
586 rtems_status_code ret;
580
587
581 ret = RTEMS_SUCCESSFUL;
588 ret = RTEMS_SUCCESSFUL;
582
589
583 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
590 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
584 if (status[0] != RTEMS_SUCCESSFUL)
591 if (status[0] != RTEMS_SUCCESSFUL)
585 {
592 {
586 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
593 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
587 }
594 }
588
595
589 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
596 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
590 if (status[1] != RTEMS_SUCCESSFUL)
597 if (status[1] != RTEMS_SUCCESSFUL)
591 {
598 {
592 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
599 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
593 }
600 }
594
601
595 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
602 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
596 if (status[2] != RTEMS_SUCCESSFUL)
603 if (status[2] != RTEMS_SUCCESSFUL)
597 {
604 {
598 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
605 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
599 }
606 }
600
607
601 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
608 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
602 if (status[3] != RTEMS_SUCCESSFUL)
609 if (status[3] != RTEMS_SUCCESSFUL)
603 {
610 {
604 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
611 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
605 }
612 }
606
613
607 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
614 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
608 if (status[4] != RTEMS_SUCCESSFUL)
615 if (status[4] != RTEMS_SUCCESSFUL)
609 {
616 {
610 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
617 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
611 }
618 }
612
619
613 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
620 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
614 if (status[5] != RTEMS_SUCCESSFUL)
621 if (status[5] != RTEMS_SUCCESSFUL)
615 {
622 {
616 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
623 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
617 }
624 }
618
625
619 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
626 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
620 if (status[6] != RTEMS_SUCCESSFUL)
627 if (status[6] != RTEMS_SUCCESSFUL)
621 {
628 {
622 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
629 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
623 }
630 }
624
631
625 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
632 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
626 if (status[7] != RTEMS_SUCCESSFUL)
633 if (status[7] != RTEMS_SUCCESSFUL)
627 {
634 {
628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
635 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
629 }
636 }
630
637
631 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
638 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
632 if (status[8] != RTEMS_SUCCESSFUL)
639 if (status[8] != RTEMS_SUCCESSFUL)
633 {
640 {
634 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
641 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
635 }
642 }
636
643
637 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
644 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
638 if (status[9] != RTEMS_SUCCESSFUL)
645 if (status[9] != RTEMS_SUCCESSFUL)
639 {
646 {
640 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
647 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
641 }
648 }
642
649
650 status[10] = rtems_task_restart( Task_id[TASKID_SPOO], 1 );
651 if (status[10] != RTEMS_SUCCESSFUL)
652 {
653 PRINTF1("in restart_science_task *** SPOO ERR %d\n", status[10])
654 }
655
656
643 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
657 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
644 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
658 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
645 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
659 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
646 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
660 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
647 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
661 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ||
662 (status[10]!= RTEMS_SUCCESSFUL) )
648 {
663 {
649 ret = RTEMS_UNSATISFIED;
664 ret = RTEMS_UNSATISFIED;
650 }
665 }
651
666
652 return ret;
667 return ret;
653 }
668 }
654
669
655 int suspend_science_tasks()
670 int suspend_science_tasks()
656 {
671 {
657 /** This function suspends the science tasks.
672 /** This function suspends the science tasks.
658 *
673 *
659 * @return RTEMS directive status codes:
674 * @return RTEMS directive status codes:
660 * - RTEMS_SUCCESSFUL - task restarted successfully
675 * - RTEMS_SUCCESSFUL - task restarted successfully
661 * - RTEMS_INVALID_ID - task id invalid
676 * - RTEMS_INVALID_ID - task id invalid
662 * - RTEMS_ALREADY_SUSPENDED - task already suspended
677 * - RTEMS_ALREADY_SUSPENDED - task already suspended
663 *
678 *
664 */
679 */
665
680
666 rtems_status_code status;
681 rtems_status_code status;
667
682
668 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
683 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
669 if (status != RTEMS_SUCCESSFUL)
684 if (status != RTEMS_SUCCESSFUL)
670 {
685 {
671 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
686 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
672 }
687 }
673 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
688 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
674 {
689 {
675 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
690 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
676 if (status != RTEMS_SUCCESSFUL)
691 if (status != RTEMS_SUCCESSFUL)
677 {
692 {
678 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
693 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
679 }
694 }
680 }
695 }
681 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
696 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
682 {
697 {
683 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
698 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
684 if (status != RTEMS_SUCCESSFUL)
699 if (status != RTEMS_SUCCESSFUL)
685 {
700 {
686 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
701 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
687 }
702 }
688 }
703 }
689 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
704 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
690 {
705 {
691 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
706 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
692 if (status != RTEMS_SUCCESSFUL)
707 if (status != RTEMS_SUCCESSFUL)
693 {
708 {
694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
709 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
695 }
710 }
696 }
711 }
697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
712 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
698 {
713 {
699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
714 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
700 if (status != RTEMS_SUCCESSFUL)
715 if (status != RTEMS_SUCCESSFUL)
701 {
716 {
702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
717 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
703 }
718 }
704 }
719 }
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
720 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
706 {
721 {
707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
722 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
708 if (status != RTEMS_SUCCESSFUL)
723 if (status != RTEMS_SUCCESSFUL)
709 {
724 {
710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
725 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
711 }
726 }
712 }
727 }
713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
728 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
714 {
729 {
715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
730 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
716 if (status != RTEMS_SUCCESSFUL)
731 if (status != RTEMS_SUCCESSFUL)
717 {
732 {
718 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
733 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
719 }
734 }
720 }
735 }
721 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
736 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
722 {
737 {
723 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
738 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
724 if (status != RTEMS_SUCCESSFUL)
739 if (status != RTEMS_SUCCESSFUL)
725 {
740 {
726 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
741 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
727 }
742 }
728 }
743 }
729 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
744 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
730 {
745 {
731 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
746 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
732 if (status != RTEMS_SUCCESSFUL)
747 if (status != RTEMS_SUCCESSFUL)
733 {
748 {
734 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
749 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
735 }
750 }
736 }
751 }
737 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
752 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
738 {
753 {
739 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
754 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
740 if (status != RTEMS_SUCCESSFUL)
755 if (status != RTEMS_SUCCESSFUL)
741 {
756 {
742 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
757 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
743 }
758 }
744 }
759 }
760 if (status == RTEMS_SUCCESSFUL) // suspend SPOO
761 {
762 status = rtems_task_suspend( Task_id[TASKID_SPOO] );
763 if (status != RTEMS_SUCCESSFUL)
764 {
765 PRINTF1("in suspend_science_task *** SPOO ERR %d\n", status)
766 }
767 }
745
768
746 return status;
769 return status;
747 }
770 }
748
771
772 void launch_waveform_picker_spool( unsigned char mode, unsigned int transitionCoarseTime )
773 {
774 WFP_reset_current_ring_nodes();
775 reset_waveform_picker_regs();
776 set_wfp_burst_enable_register( mode );
777
778 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
779 if (transitionCoarseTime == 0)
780 {
781 waveform_picker_regs->start_date = time_management_regs->coarse_time;
782 }
783 else
784 {
785 waveform_picker_regs->start_date = transitionCoarseTime;
786 }
787 }
788
749 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
789 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
750 {
790 {
751 WFP_reset_current_ring_nodes();
791 WFP_reset_current_ring_nodes();
752 reset_waveform_picker_regs();
792 reset_waveform_picker_regs();
753 set_wfp_burst_enable_register( mode );
793 set_wfp_burst_enable_register( mode );
754
794
755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
795 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
796 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
757
797
758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
798 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
759 if (transitionCoarseTime == 0)
799 if (transitionCoarseTime == 0)
760 {
800 {
761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
801 waveform_picker_regs->start_date = time_management_regs->coarse_time;
762 }
802 }
763 else
803 else
764 {
804 {
765 waveform_picker_regs->start_date = transitionCoarseTime;
805 waveform_picker_regs->start_date = transitionCoarseTime;
766 }
806 }
767 }
807 }
768
808
809 void launch_spectral_matrix_spool( void )
810 {
811 SM_reset_current_ring_nodes();
812 reset_spectral_matrix_regs();
813 reset_nb_sm();
814
815 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
816 grgpio_regs->io_port_direction_register =
817 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
818 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
819 set_irq_on_new_ready_matrix( 0 );
820 set_run_matrix_spectral( 1 );
821 }
822
769 void launch_spectral_matrix( void )
823 void launch_spectral_matrix( void )
770 {
824 {
771 SM_reset_current_ring_nodes();
825 SM_reset_current_ring_nodes();
772 reset_spectral_matrix_regs();
826 reset_spectral_matrix_regs();
773 reset_nb_sm();
827 reset_nb_sm();
774
828
775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
829 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
776 grgpio_regs->io_port_direction_register =
830 grgpio_regs->io_port_direction_register =
777 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
831 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
778 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
832 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
779 set_irq_on_new_ready_matrix( 1 );
833 set_irq_on_new_ready_matrix( 1 );
780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
834 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
835 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
782 set_run_matrix_spectral( 1 );
836 set_run_matrix_spectral( 1 );
783 }
837 }
784
838
785 void launch_spectral_matrix_simu( void )
839 void launch_spectral_matrix_simu( void )
786 {
840 {
787 SM_reset_current_ring_nodes();
841 SM_reset_current_ring_nodes();
788 reset_spectral_matrix_regs();
842 reset_spectral_matrix_regs();
789 reset_nb_sm();
843 reset_nb_sm();
790
844
791 // Spectral Matrices simulator
845 // Spectral Matrices simulator
792 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
846 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
793 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
847 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
794 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
848 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
795 }
849 }
796
850
797 void set_irq_on_new_ready_matrix( unsigned char value )
851 void set_irq_on_new_ready_matrix( unsigned char value )
798 {
852 {
799 if (value == 1)
853 if (value == 1)
800 {
854 {
801 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
855 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
802 }
856 }
803 else
857 else
804 {
858 {
805 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
859 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
806 }
860 }
807 }
861 }
808
862
809 void set_run_matrix_spectral( unsigned char value )
863 void set_run_matrix_spectral( unsigned char value )
810 {
864 {
811 if (value == 1)
865 if (value == 1)
812 {
866 {
813 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
867 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
814 }
868 }
815 else
869 else
816 {
870 {
817 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
871 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
818 }
872 }
819 }
873 }
820
874
821 //****************
875 //****************
822 // CLOSING ACTIONS
876 // CLOSING ACTIONS
823 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
877 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
824 {
878 {
825 /** This function is used to update the HK packets statistics after a successful TC execution.
879 /** This function is used to update the HK packets statistics after a successful TC execution.
826 *
880 *
827 * @param TC points to the TC being processed
881 * @param TC points to the TC being processed
828 * @param time is the time used to date the TC execution
882 * @param time is the time used to date the TC execution
829 *
883 *
830 */
884 */
831
885
832 unsigned int val;
886 unsigned int val;
833
887
834 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
888 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
835 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
889 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
836 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
890 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
837 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
891 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
838 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
892 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
893 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
840 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
894 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
841 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
895 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
842 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
896 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
843 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
897 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
844 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
898 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
845 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
899 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
846
900
847 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
901 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
848 val++;
902 val++;
849 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
903 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
850 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
904 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
851 }
905 }
852
906
853 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
907 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
854 {
908 {
855 /** This function is used to update the HK packets statistics after a TC rejection.
909 /** This function is used to update the HK packets statistics after a TC rejection.
856 *
910 *
857 * @param TC points to the TC being processed
911 * @param TC points to the TC being processed
858 * @param time is the time used to date the TC rejection
912 * @param time is the time used to date the TC rejection
859 *
913 *
860 */
914 */
861
915
862 unsigned int val;
916 unsigned int val;
863
917
864 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
918 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
865 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
919 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
866 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
920 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
867 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
921 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
868 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
922 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
923 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
870 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
924 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
871 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
925 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
872 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
926 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
873 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
927 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
874 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
928 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
875 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
929 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
876
930
877 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
931 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
878 val++;
932 val++;
879 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
933 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
880 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
934 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
881 }
935 }
882
936
883 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
937 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
884 {
938 {
885 /** This function is the last step of the TC execution workflow.
939 /** This function is the last step of the TC execution workflow.
886 *
940 *
887 * @param TC points to the TC being processed
941 * @param TC points to the TC being processed
888 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
942 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
889 * @param queue_id is the id of the RTEMS message queue used to send TM packets
943 * @param queue_id is the id of the RTEMS message queue used to send TM packets
890 * @param time is the time used to date the TC execution
944 * @param time is the time used to date the TC execution
891 *
945 *
892 */
946 */
893
947
894 unsigned char requestedMode;
948 unsigned char requestedMode;
895
949
896 if (result == LFR_SUCCESSFUL)
950 if (result == LFR_SUCCESSFUL)
897 {
951 {
898 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
952 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
899 &
953 &
900 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
954 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
901 )
955 )
902 {
956 {
903 send_tm_lfr_tc_exe_success( TC, queue_id );
957 send_tm_lfr_tc_exe_success( TC, queue_id );
904 }
958 }
905 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
959 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
906 {
960 {
907 //**********************************
961 //**********************************
908 // UPDATE THE LFRMODE LOCAL VARIABLE
962 // UPDATE THE LFRMODE LOCAL VARIABLE
909 requestedMode = TC->dataAndCRC[1];
963 requestedMode = TC->dataAndCRC[1];
910 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
964 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
911 updateLFRCurrentMode();
965 updateLFRCurrentMode();
912 }
966 }
913 }
967 }
914 else if (result == LFR_EXE_ERROR)
968 else if (result == LFR_EXE_ERROR)
915 {
969 {
916 send_tm_lfr_tc_exe_error( TC, queue_id );
970 send_tm_lfr_tc_exe_error( TC, queue_id );
917 }
971 }
918 }
972 }
919
973
920 //***************************
974 //***************************
921 // Interrupt Service Routines
975 // Interrupt Service Routines
922 rtems_isr commutation_isr1( rtems_vector_number vector )
976 rtems_isr commutation_isr1( rtems_vector_number vector )
923 {
977 {
924 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
978 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
925 printf("In commutation_isr1 *** Error sending event to DUMB\n");
979 printf("In commutation_isr1 *** Error sending event to DUMB\n");
926 }
980 }
927 }
981 }
928
982
929 rtems_isr commutation_isr2( rtems_vector_number vector )
983 rtems_isr commutation_isr2( rtems_vector_number vector )
930 {
984 {
931 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
985 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
932 printf("In commutation_isr2 *** Error sending event to DUMB\n");
986 printf("In commutation_isr2 *** Error sending event to DUMB\n");
933 }
987 }
934 }
988 }
935
989
936 //****************
990 //****************
937 // OTHER FUNCTIONS
991 // OTHER FUNCTIONS
938 void updateLFRCurrentMode()
992 void updateLFRCurrentMode()
939 {
993 {
940 /** This function updates the value of the global variable lfrCurrentMode.
994 /** This function updates the value of the global variable lfrCurrentMode.
941 *
995 *
942 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
996 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
943 *
997 *
944 */
998 */
945 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
999 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
946 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
1000 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
947 }
1001 }
948
1002
@@ -1,1310 +1,1457
1 /** Functions and tasks related to waveform packet generation.
1 /** Functions and tasks related to waveform packet generation.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
7 *
8 */
8 */
9
9
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 //*****************
12 //*****************
13 // waveform headers
13 // waveform headers
14 // SWF
14 // SWF
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 // CWF
18 // CWF
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24
24
25 //**************
25 //**************
26 // waveform ring
26 // waveform ring
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 ring_node waveform_ring_f3[NB_RING_NODES_F3];
30 ring_node waveform_ring_f3[NB_RING_NODES_F3];
31 ring_node *current_ring_node_f0;
31 ring_node *current_ring_node_f0;
32 ring_node *ring_node_to_send_swf_f0;
32 ring_node *ring_node_to_send_swf_f0;
33 ring_node *current_ring_node_f1;
33 ring_node *current_ring_node_f1;
34 ring_node *ring_node_to_send_swf_f1;
34 ring_node *ring_node_to_send_swf_f1;
35 ring_node *ring_node_to_send_cwf_f1;
35 ring_node *ring_node_to_send_cwf_f1;
36 ring_node *current_ring_node_f2;
36 ring_node *current_ring_node_f2;
37 ring_node *ring_node_to_send_swf_f2;
37 ring_node *ring_node_to_send_swf_f2;
38 ring_node *ring_node_to_send_cwf_f2;
38 ring_node *ring_node_to_send_cwf_f2;
39 ring_node *current_ring_node_f3;
39 ring_node *current_ring_node_f3;
40 ring_node *ring_node_to_send_cwf_f3;
40 ring_node *ring_node_to_send_cwf_f3;
41
41
42 bool extractSWF = false;
42 bool extractSWF = false;
43 bool swf_f0_ready = false;
43 bool swf_f0_ready = false;
44 bool swf_f1_ready = false;
44 bool swf_f1_ready = false;
45 bool swf_f2_ready = false;
45 bool swf_f2_ready = false;
46
46
47 bool wake_up_task_wfrm = false;
48 bool wake_up_task_cwf_f1 = false;
49 bool wake_up_task_cwf_f2_burst = false;
50 bool wake_up_task_cwf_f2_sbm2 = false;
51 bool wake_up_task_cwf_f3 = false;
52
47 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
53 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
48
54
49 //*********************
55 //*********************
50 // Interrupt SubRoutine
56 // Interrupt SubRoutine
51
57
52 void reset_extractSWF( void )
58 void reset_extractSWF( void )
53 {
59 {
54 extractSWF = false;
60 extractSWF = false;
55 swf_f0_ready = false;
61 swf_f0_ready = false;
56 swf_f1_ready = false;
62 swf_f1_ready = false;
57 swf_f2_ready = false;
63 swf_f2_ready = false;
58 }
64 }
59
65
60 rtems_isr waveforms_isr( rtems_vector_number vector )
66 rtems_isr waveforms_isr( rtems_vector_number vector )
61 {
67 {
62 /** This is the interrupt sub routine called by the waveform picker core.
68 /** This is the interrupt sub routine called by the waveform picker core.
63 *
69 *
64 * This ISR launch different actions depending mainly on two pieces of information:
70 * This ISR launch different actions depending mainly on two pieces of information:
65 * 1. the values read in the registers of the waveform picker.
71 * 1. the values read in the registers of the waveform picker.
66 * 2. the current LFR mode.
72 * 2. the current LFR mode.
67 *
73 *
68 */
74 */
69
75
70 rtems_status_code status;
76 rtems_status_code status;
71
77
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
78 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) )
79 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
74 { // in modes other than STANDBY and BURST, send the CWF_F3 data
80 { // in modes other than STANDBY and BURST, send the CWF_F3 data
75 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
81 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
76 // (1) change the receiving buffer for the waveform picker
82 // (1) change the receiving buffer for the waveform picker
77 ring_node_to_send_cwf_f3 = current_ring_node_f3;
83 ring_node_to_send_cwf_f3 = current_ring_node_f3;
78 current_ring_node_f3 = current_ring_node_f3->next;
84 current_ring_node_f3 = current_ring_node_f3->next;
79 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
85 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
80 // (2) send an event for the waveforms transmission
86 // (2) send an event for the waveforms transmission
81 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
87 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
88 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 }
89 }
84 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
90 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]
91 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 }
92 }
87 }
93 }
88
94
89 switch(lfrCurrentMode)
95 switch(lfrCurrentMode)
90 {
96 {
91 //********
97 //********
92 // STANDBY
98 // STANDBY
93 case(LFR_MODE_STANDBY):
99 case(LFR_MODE_STANDBY):
94 break;
100 break;
95
101
96 //******
102 //******
97 // NORMAL
103 // NORMAL
98 case(LFR_MODE_NORMAL):
104 case(LFR_MODE_NORMAL):
99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
105 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 {
106 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
107 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 }
108 }
103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
109 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 {
110 {
105 // change F0 ring node
111 // change F0 ring node
106 ring_node_to_send_swf_f0 = current_ring_node_f0;
112 ring_node_to_send_swf_f0 = current_ring_node_f0;
107 current_ring_node_f0 = current_ring_node_f0->next;
113 current_ring_node_f0 = current_ring_node_f0->next;
108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
114 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
109 // change F1 ring node
115 // change F1 ring node
110 ring_node_to_send_swf_f1 = current_ring_node_f1;
116 ring_node_to_send_swf_f1 = current_ring_node_f1;
111 current_ring_node_f1 = current_ring_node_f1->next;
117 current_ring_node_f1 = current_ring_node_f1->next;
112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
118 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
113 // change F2 ring node
119 // change F2 ring node
114 ring_node_to_send_swf_f2 = current_ring_node_f2;
120 ring_node_to_send_swf_f2 = current_ring_node_f2;
115 current_ring_node_f2 = current_ring_node_f2->next;
121 current_ring_node_f2 = current_ring_node_f2->next;
116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
122 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
117 //
123 //
118 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
124 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
119 {
125 {
120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
126 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 }
127 }
122 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
128 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
123 }
129 }
124 break;
130 break;
125
131
126 //******
132 //******
127 // BURST
133 // BURST
128 case(LFR_MODE_BURST):
134 case(LFR_MODE_BURST):
129 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
135 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
130 // (1) change the receiving buffer for the waveform picker
136 // (1) change the receiving buffer for the waveform picker
131 ring_node_to_send_cwf_f2 = current_ring_node_f2;
137 ring_node_to_send_cwf_f2 = current_ring_node_f2;
132 current_ring_node_f2 = current_ring_node_f2->next;
138 current_ring_node_f2 = current_ring_node_f2->next;
133 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
139 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
134 // (2) send an event for the waveforms transmission
140 // (2) send an event for the waveforms transmission
135 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
141 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 );
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 }
143 }
138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
139 }
145 }
140 break;
146 break;
141
147
142 //*****
148 //*****
143 // SBM1
149 // SBM1
144 case(LFR_MODE_SBM1):
150 case(LFR_MODE_SBM1):
145 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
151 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
146 // (1) change the receiving buffer for the waveform picker
152 // (1) change the receiving buffer for the waveform picker
147 ring_node_to_send_cwf_f1 = current_ring_node_f1;
153 ring_node_to_send_cwf_f1 = current_ring_node_f1;
148 current_ring_node_f1 = current_ring_node_f1->next;
154 current_ring_node_f1 = current_ring_node_f1->next;
149 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
155 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
150 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
156 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
151 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
157 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
152 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
158 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
153 }
159 }
154 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
160 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
155 swf_f0_ready = true;
161 swf_f0_ready = true;
156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
162 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
157 }
163 }
158 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
164 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
159 swf_f2_ready = true;
165 swf_f2_ready = true;
160 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
166 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
161 }
167 }
162 break;
168 break;
163
169
164 //*****
170 //*****
165 // SBM2
171 // SBM2
166 case(LFR_MODE_SBM2):
172 case(LFR_MODE_SBM2):
167 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
173 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
168 // (1) change the receiving buffer for the waveform picker
174 // (1) change the receiving buffer for the waveform picker
169 ring_node_to_send_cwf_f2 = current_ring_node_f2;
175 ring_node_to_send_cwf_f2 = current_ring_node_f2;
170 current_ring_node_f2 = current_ring_node_f2->next;
176 current_ring_node_f2 = current_ring_node_f2->next;
171 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
177 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
172 // (2) send an event for the waveforms transmission
178 // (2) send an event for the waveforms transmission
173 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
179 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
174 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
180 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
175 }
181 }
176 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
182 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
177 swf_f0_ready = true;
183 swf_f0_ready = true;
178 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
184 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
179 }
185 }
180 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
186 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
181 swf_f1_ready = true;
187 swf_f1_ready = true;
182 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
188 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
183 }
189 }
184 break;
190 break;
185
191
186 //********
192 //********
187 // DEFAULT
193 // DEFAULT
188 default:
194 default:
189 break;
195 break;
190 }
196 }
191 }
197 }
192
198
199 rtems_isr waveforms_isr_alt( rtems_vector_number vector )
200 {
201 /** This is the interrupt sub routine called by the waveform picker core.
202 *
203 * This ISR launch different actions depending mainly on two pieces of information:
204 * 1. the values read in the registers of the waveform picker.
205 * 2. the current LFR mode.
206 *
207 */
208
209 rtems_interrupt_level level;
210
211 rtems_interrupt_disable( level );
212
213 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
214 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
215 { // in modes other than STANDBY and BURST, send the CWF_F3 data
216 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
217 // (1) change the receiving buffer for the waveform picker
218 ring_node_to_send_cwf_f3 = current_ring_node_f3;
219 current_ring_node_f3 = current_ring_node_f3->next;
220 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
221 // (2) send an event for the waveforms transmission
222 wake_up_task_cwf_f3 = true;
223 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
224 }
225 }
226
227 switch(lfrCurrentMode)
228 {
229 //********
230 // STANDBY
231 case(LFR_MODE_STANDBY):
232 break;
233
234 //******
235 // NORMAL
236 case(LFR_MODE_NORMAL):
237 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
238 {
239 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
240 }
241 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
242 {
243 // change F0 ring node
244 ring_node_to_send_swf_f0 = current_ring_node_f0;
245 current_ring_node_f0 = current_ring_node_f0->next;
246 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
247 // change F1 ring node
248 ring_node_to_send_swf_f1 = current_ring_node_f1;
249 current_ring_node_f1 = current_ring_node_f1->next;
250 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
251 // change F2 ring node
252 ring_node_to_send_swf_f2 = current_ring_node_f2;
253 current_ring_node_f2 = current_ring_node_f2->next;
254 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
255 //
256 wake_up_task_wfrm = true;
257 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
258 }
259 break;
260
261 //******
262 // BURST
263 case(LFR_MODE_BURST):
264 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
265 // (1) change the receiving buffer for the waveform picker
266 ring_node_to_send_cwf_f2 = current_ring_node_f2;
267 current_ring_node_f2 = current_ring_node_f2->next;
268 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
269 // (2) send an event for the waveforms transmission
270 wake_up_task_cwf_f2_burst = true;
271 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
272 }
273 break;
274
275 //*****
276 // SBM1
277 case(LFR_MODE_SBM1):
278 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
279 // (1) change the receiving buffer for the waveform picker
280 ring_node_to_send_cwf_f1 = current_ring_node_f1;
281 current_ring_node_f1 = current_ring_node_f1->next;
282 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
283 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
284 wake_up_task_cwf_f1 = true;
285 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
286 }
287 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
288 swf_f0_ready = true;
289 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
290 }
291 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
292 swf_f2_ready = true;
293 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
294 }
295 break;
296
297 //*****
298 // SBM2
299 case(LFR_MODE_SBM2):
300 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
301 // (1) change the receiving buffer for the waveform picker
302 ring_node_to_send_cwf_f2 = current_ring_node_f2;
303 current_ring_node_f2 = current_ring_node_f2->next;
304 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
305 // (2) send an event for the waveforms transmission
306 wake_up_task_cwf_f2_sbm2 = true;
307 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
308 }
309 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
310 swf_f0_ready = true;
311 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
312 }
313 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
314 swf_f1_ready = true;
315 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
316 }
317 break;
318
319 //********
320 // DEFAULT
321 default:
322 break;
323 }
324
325 rtems_interrupt_enable( level );
326 }
327
193 //************
328 //************
194 // RTEMS TASKS
329 // RTEMS TASKS
195
330
196 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
331 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
197 {
332 {
198 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
333 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
199 *
334 *
200 * @param unused is the starting argument of the RTEMS task
335 * @param unused is the starting argument of the RTEMS task
201 *
336 *
202 * The following data packets are sent by this task:
337 * The following data packets are sent by this task:
203 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
338 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
204 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
339 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
205 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
340 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
206 *
341 *
207 */
342 */
208
343
209 rtems_event_set event_out;
344 rtems_event_set event_out;
210 rtems_id queue_id;
345 rtems_id queue_id;
211 rtems_status_code status;
346 rtems_status_code status;
212
347
213 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
348 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
214 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
349 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
215 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
350 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
216
351
217 status = get_message_queue_id_send( &queue_id );
352 status = get_message_queue_id_send( &queue_id );
218 if (status != RTEMS_SUCCESSFUL)
353 if (status != RTEMS_SUCCESSFUL)
219 {
354 {
220 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
355 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
221 }
356 }
222
357
223 BOOT_PRINTF("in WFRM ***\n")
358 BOOT_PRINTF("in WFRM ***\n")
224
359
225 while(1){
360 while(1){
226 // wait for an RTEMS_EVENT
361 // wait for an RTEMS_EVENT
227 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
362 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
228 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
363 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
229 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
364 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
230 if (event_out == RTEMS_EVENT_MODE_NORMAL)
365 if (event_out == RTEMS_EVENT_MODE_NORMAL)
231 {
366 {
232 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
367 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
233 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
368 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
234 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
369 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
235 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
370 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
236 }
371 }
237 if (event_out == RTEMS_EVENT_MODE_SBM1)
372 if (event_out == RTEMS_EVENT_MODE_SBM1)
238 {
373 {
239 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
374 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
240 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
375 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
241 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
376 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
242 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
377 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
243 }
378 }
244 if (event_out == RTEMS_EVENT_MODE_SBM2)
379 if (event_out == RTEMS_EVENT_MODE_SBM2)
245 {
380 {
246 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
381 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
247 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
382 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
248 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
383 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
249 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
384 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
250 }
385 }
251 }
386 }
252 }
387 }
253
388
254 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
389 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
255 {
390 {
256 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
391 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
257 *
392 *
258 * @param unused is the starting argument of the RTEMS task
393 * @param unused is the starting argument of the RTEMS task
259 *
394 *
260 * The following data packet is sent by this task:
395 * The following data packet is sent by this task:
261 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
396 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
262 *
397 *
263 */
398 */
264
399
265 rtems_event_set event_out;
400 rtems_event_set event_out;
266 rtems_id queue_id;
401 rtems_id queue_id;
267 rtems_status_code status;
402 rtems_status_code status;
268
403
269 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
404 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
270 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
405 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
271
406
272 status = get_message_queue_id_send( &queue_id );
407 status = get_message_queue_id_send( &queue_id );
273 if (status != RTEMS_SUCCESSFUL)
408 if (status != RTEMS_SUCCESSFUL)
274 {
409 {
275 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
410 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
276 }
411 }
277
412
278 BOOT_PRINTF("in CWF3 ***\n")
413 BOOT_PRINTF("in CWF3 ***\n")
279
414
280 while(1){
415 while(1){
281 // wait for an RTEMS_EVENT
416 // wait for an RTEMS_EVENT
282 rtems_event_receive( RTEMS_EVENT_0,
417 rtems_event_receive( RTEMS_EVENT_0,
283 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
418 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
284 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
419 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
285 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
420 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
286 {
421 {
287 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
422 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
288 {
423 {
289 PRINTF("send CWF_LONG_F3\n")
424 PRINTF("send CWF_LONG_F3\n")
290 send_waveform_CWF(
425 send_waveform_CWF(
291 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
426 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
292 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
427 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
293 }
428 }
294 else
429 else
295 {
430 {
296 PRINTF("send CWF_F3 (light)\n")
431 PRINTF("send CWF_F3 (light)\n")
297 send_waveform_CWF3_light(
432 send_waveform_CWF3_light(
298 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
433 (volatile int*) ring_node_to_send_cwf_f3->buffer_address,
299 headerCWF_F3_light, queue_id );
434 headerCWF_F3_light, queue_id );
300 }
435 }
301
436
302 }
437 }
303 else
438 else
304 {
439 {
305 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
440 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
306 }
441 }
307 }
442 }
308 }
443 }
309
444
310 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
445 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
311 {
446 {
312 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
447 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
313 *
448 *
314 * @param unused is the starting argument of the RTEMS task
449 * @param unused is the starting argument of the RTEMS task
315 *
450 *
316 * The following data packet is sent by this function:
451 * The following data packet is sent by this function:
317 * - TM_LFR_SCIENCE_BURST_CWF_F2
452 * - TM_LFR_SCIENCE_BURST_CWF_F2
318 * - TM_LFR_SCIENCE_SBM2_CWF_F2
453 * - TM_LFR_SCIENCE_SBM2_CWF_F2
319 *
454 *
320 */
455 */
321
456
322 rtems_event_set event_out;
457 rtems_event_set event_out;
323 rtems_id queue_id;
458 rtems_id queue_id;
324 rtems_status_code status;
459 rtems_status_code status;
325
460
326 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
461 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
327 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
462 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
328
463
329 status = get_message_queue_id_send( &queue_id );
464 status = get_message_queue_id_send( &queue_id );
330 if (status != RTEMS_SUCCESSFUL)
465 if (status != RTEMS_SUCCESSFUL)
331 {
466 {
332 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
467 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
333 }
468 }
334
469
335 BOOT_PRINTF("in CWF2 ***\n")
470 BOOT_PRINTF("in CWF2 ***\n")
336
471
337 while(1){
472 while(1){
338 // wait for an RTEMS_EVENT
473 // wait for an RTEMS_EVENT
339 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
474 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
340 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
475 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
341 if (event_out == RTEMS_EVENT_MODE_BURST)
476 if (event_out == RTEMS_EVENT_MODE_BURST)
342 {
477 {
343 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
478 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
344 }
479 }
345 if (event_out == RTEMS_EVENT_MODE_SBM2)
480 if (event_out == RTEMS_EVENT_MODE_SBM2)
346 {
481 {
347 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
482 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
348 // launch snapshot extraction if needed
483 // launch snapshot extraction if needed
349 if (extractSWF == true)
484 if (extractSWF == true)
350 {
485 {
351 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
486 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
352 // extract the snapshot
487 // extract the snapshot
353 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
488 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
354 // send the snapshot when built
489 // send the snapshot when built
355 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
490 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
356 extractSWF = false;
491 extractSWF = false;
357 }
492 }
358 if (swf_f0_ready && swf_f1_ready)
493 if (swf_f0_ready && swf_f1_ready)
359 {
494 {
360 extractSWF = true;
495 extractSWF = true;
361 swf_f0_ready = false;
496 swf_f0_ready = false;
362 swf_f1_ready = false;
497 swf_f1_ready = false;
363 }
498 }
364 }
499 }
365 }
500 }
366 }
501 }
367
502
368 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
503 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
369 {
504 {
370 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
505 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
371 *
506 *
372 * @param unused is the starting argument of the RTEMS task
507 * @param unused is the starting argument of the RTEMS task
373 *
508 *
374 * The following data packet is sent by this function:
509 * The following data packet is sent by this function:
375 * - TM_LFR_SCIENCE_SBM1_CWF_F1
510 * - TM_LFR_SCIENCE_SBM1_CWF_F1
376 *
511 *
377 */
512 */
378
513
379 rtems_event_set event_out;
514 rtems_event_set event_out;
380 rtems_id queue_id;
515 rtems_id queue_id;
381 rtems_status_code status;
516 rtems_status_code status;
517 rtems_interrupt_level level = 0;
382
518
383 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
519 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
384
520
385 status = get_message_queue_id_send( &queue_id );
521 status = get_message_queue_id_send( &queue_id );
386 if (status != RTEMS_SUCCESSFUL)
522 if (status != RTEMS_SUCCESSFUL)
387 {
523 {
388 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
524 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
389 }
525 }
390
526
391 BOOT_PRINTF("in CWF1 ***\n")
527 BOOT_PRINTF("in CWF1 ***\n")
392
528
529 printf("(0) level = %x\n", (unsigned int) level);
530
393 while(1){
531 while(1){
394 // wait for an RTEMS_EVENT
532 // wait for an RTEMS_EVENT
395 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
533 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
396 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
534 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
535
536 rtems_interrupt_disable( level );
537
538 printf("(1) level = %x\n", (unsigned int) level);
539
397 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
540 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
398 // launch snapshot extraction if needed
541 // launch snapshot extraction if needed
399 if (extractSWF == true)
542 if (extractSWF == true)
400 {
543 {
401 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
544 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
402 // launch the snapshot extraction
545 // launch the snapshot extraction
403 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
546 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
404 extractSWF = false;
547 extractSWF = false;
405 }
548 }
406 if (swf_f0_ready == true)
549 if (swf_f0_ready == true)
407 {
550 {
408 extractSWF = true;
551 extractSWF = true;
409 swf_f0_ready = false; // this step shall be executed only one time
552 swf_f0_ready = false; // this step shall be executed only one time
410 }
553 }
411 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
554 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
412 {
555 {
413 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
556 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
414 swf_f1_ready = false;
557 swf_f1_ready = false;
415 swf_f2_ready = false;
558 swf_f2_ready = false;
416 }
559 }
560
561 rtems_interrupt_enable( level );
562
563 printf("(2) level = %x\n", (unsigned int) level);
417 }
564 }
418 }
565 }
419
566
420 rtems_task swbd_task(rtems_task_argument argument)
567 rtems_task swbd_task(rtems_task_argument argument)
421 {
568 {
422 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
569 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
423 *
570 *
424 * @param unused is the starting argument of the RTEMS task
571 * @param unused is the starting argument of the RTEMS task
425 *
572 *
426 */
573 */
427
574
428 rtems_event_set event_out;
575 rtems_event_set event_out;
429
576
430 BOOT_PRINTF("in SWBD ***\n")
577 BOOT_PRINTF("in SWBD ***\n")
431
578
432 while(1){
579 while(1){
433 // wait for an RTEMS_EVENT
580 // wait for an RTEMS_EVENT
434 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
581 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
435 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
582 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
436 if (event_out == RTEMS_EVENT_MODE_SBM1)
583 if (event_out == RTEMS_EVENT_MODE_SBM1)
437 {
584 {
438 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
585 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
439 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
586 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
440 }
587 }
441 else
588 else
442 {
589 {
443 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
590 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
444 }
591 }
445 }
592 }
446 }
593 }
447
594
448 //******************
595 //******************
449 // general functions
596 // general functions
450
597
451 void WFP_init_rings( void )
598 void WFP_init_rings( void )
452 {
599 {
453 // F0 RING
600 // F0 RING
454 init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 );
601 init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 );
455 // F1 RING
602 // F1 RING
456 init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 );
603 init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 );
457 // F2 RING
604 // F2 RING
458 init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 );
605 init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 );
459 // F3 RING
606 // F3 RING
460 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
607 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
461
608
462 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
609 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
463 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
610 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
464 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
611 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
465 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
612 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
466 }
613 }
467
614
468 void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] )
615 void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] )
469 {
616 {
470 unsigned char i;
617 unsigned char i;
471
618
472 waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ];
619 waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ];
473 waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ];
620 waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ];
474 waveform_ring[0].buffer_address = (int) &wfrm[0];
621 waveform_ring[0].buffer_address = (int) &wfrm[0];
475
622
476 waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ];
623 waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ];
477 waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ];
624 waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ];
478 waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ];
625 waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ];
479
626
480 for(i=1; i<nbNodes-1; i++)
627 for(i=1; i<nbNodes-1; i++)
481 {
628 {
482 waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ];
629 waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ];
483 waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ];
630 waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ];
484 waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ];
631 waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ];
485 }
632 }
486 }
633 }
487
634
488 void WFP_reset_current_ring_nodes( void )
635 void WFP_reset_current_ring_nodes( void )
489 {
636 {
490 current_ring_node_f0 = waveform_ring_f0;
637 current_ring_node_f0 = waveform_ring_f0;
491 ring_node_to_send_swf_f0 = waveform_ring_f0;
638 ring_node_to_send_swf_f0 = waveform_ring_f0;
492
639
493 current_ring_node_f1 = waveform_ring_f1;
640 current_ring_node_f1 = waveform_ring_f1;
494 ring_node_to_send_cwf_f1 = waveform_ring_f1;
641 ring_node_to_send_cwf_f1 = waveform_ring_f1;
495 ring_node_to_send_swf_f1 = waveform_ring_f1;
642 ring_node_to_send_swf_f1 = waveform_ring_f1;
496
643
497 current_ring_node_f2 = waveform_ring_f2;
644 current_ring_node_f2 = waveform_ring_f2;
498 ring_node_to_send_cwf_f2 = waveform_ring_f2;
645 ring_node_to_send_cwf_f2 = waveform_ring_f2;
499 ring_node_to_send_swf_f2 = waveform_ring_f2;
646 ring_node_to_send_swf_f2 = waveform_ring_f2;
500
647
501 current_ring_node_f3 = waveform_ring_f3;
648 current_ring_node_f3 = waveform_ring_f3;
502 ring_node_to_send_cwf_f3 = waveform_ring_f3;
649 ring_node_to_send_cwf_f3 = waveform_ring_f3;
503 }
650 }
504
651
505 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
652 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
506 {
653 {
507 unsigned char i;
654 unsigned char i;
508
655
509 for (i=0; i<7; i++)
656 for (i=0; i<7; i++)
510 {
657 {
511 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
658 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
512 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
659 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
513 headerSWF[ i ].reserved = DEFAULT_RESERVED;
660 headerSWF[ i ].reserved = DEFAULT_RESERVED;
514 headerSWF[ i ].userApplication = CCSDS_USER_APP;
661 headerSWF[ i ].userApplication = CCSDS_USER_APP;
515 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
662 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
516 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
663 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
517 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
664 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
518 if (i == 6)
665 if (i == 6)
519 {
666 {
520 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
667 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
521 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
668 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
522 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
669 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
523 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
670 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
524 }
671 }
525 else
672 else
526 {
673 {
527 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
674 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
528 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
675 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
529 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
676 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
530 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
677 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
531 }
678 }
532 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
679 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
533 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
680 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
534 headerSWF[ i ].pktNr = i+1; // PKT_NR
681 headerSWF[ i ].pktNr = i+1; // PKT_NR
535 // DATA FIELD HEADER
682 // DATA FIELD HEADER
536 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
683 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
537 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
684 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
538 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
685 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
539 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
686 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
540 // AUXILIARY DATA HEADER
687 // AUXILIARY DATA HEADER
541 headerSWF[ i ].time[0] = 0x00;
688 headerSWF[ i ].time[0] = 0x00;
542 headerSWF[ i ].time[0] = 0x00;
689 headerSWF[ i ].time[0] = 0x00;
543 headerSWF[ i ].time[0] = 0x00;
690 headerSWF[ i ].time[0] = 0x00;
544 headerSWF[ i ].time[0] = 0x00;
691 headerSWF[ i ].time[0] = 0x00;
545 headerSWF[ i ].time[0] = 0x00;
692 headerSWF[ i ].time[0] = 0x00;
546 headerSWF[ i ].time[0] = 0x00;
693 headerSWF[ i ].time[0] = 0x00;
547 headerSWF[ i ].sid = sid;
694 headerSWF[ i ].sid = sid;
548 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
695 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
549 }
696 }
550 return LFR_SUCCESSFUL;
697 return LFR_SUCCESSFUL;
551 }
698 }
552
699
553 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
700 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
554 {
701 {
555 unsigned int i;
702 unsigned int i;
556
703
557 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
704 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
558 {
705 {
559 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
706 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
560 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
707 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
561 headerCWF[ i ].reserved = DEFAULT_RESERVED;
708 headerCWF[ i ].reserved = DEFAULT_RESERVED;
562 headerCWF[ i ].userApplication = CCSDS_USER_APP;
709 headerCWF[ i ].userApplication = CCSDS_USER_APP;
563 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
710 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
564 {
711 {
565 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
712 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
566 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
713 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
567 }
714 }
568 else
715 else
569 {
716 {
570 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
717 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
571 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
718 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
572 }
719 }
573 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
720 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
574 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
721 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
575 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
722 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
576 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
723 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
577 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
724 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
578 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
725 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
579 // DATA FIELD HEADER
726 // DATA FIELD HEADER
580 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
727 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
581 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
728 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
582 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
729 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
583 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
730 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
584 // AUXILIARY DATA HEADER
731 // AUXILIARY DATA HEADER
585 headerCWF[ i ].sid = sid;
732 headerCWF[ i ].sid = sid;
586 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
733 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
587 headerCWF[ i ].time[0] = 0x00;
734 headerCWF[ i ].time[0] = 0x00;
588 headerCWF[ i ].time[0] = 0x00;
735 headerCWF[ i ].time[0] = 0x00;
589 headerCWF[ i ].time[0] = 0x00;
736 headerCWF[ i ].time[0] = 0x00;
590 headerCWF[ i ].time[0] = 0x00;
737 headerCWF[ i ].time[0] = 0x00;
591 headerCWF[ i ].time[0] = 0x00;
738 headerCWF[ i ].time[0] = 0x00;
592 headerCWF[ i ].time[0] = 0x00;
739 headerCWF[ i ].time[0] = 0x00;
593 }
740 }
594 return LFR_SUCCESSFUL;
741 return LFR_SUCCESSFUL;
595 }
742 }
596
743
597 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
744 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
598 {
745 {
599 unsigned int i;
746 unsigned int i;
600
747
601 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
748 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
602 {
749 {
603 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
750 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
604 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
751 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
605 headerCWF[ i ].reserved = DEFAULT_RESERVED;
752 headerCWF[ i ].reserved = DEFAULT_RESERVED;
606 headerCWF[ i ].userApplication = CCSDS_USER_APP;
753 headerCWF[ i ].userApplication = CCSDS_USER_APP;
607
754
608 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
755 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
609 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
756 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
610
757
611 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
758 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
612 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
759 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
613 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
760 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
614 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
761 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
615 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
762 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
616
763
617 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
764 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
618 // DATA FIELD HEADER
765 // DATA FIELD HEADER
619 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
766 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
620 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
767 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
621 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
768 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
622 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
769 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
623 // AUXILIARY DATA HEADER
770 // AUXILIARY DATA HEADER
624 headerCWF[ i ].sid = SID_NORM_CWF_F3;
771 headerCWF[ i ].sid = SID_NORM_CWF_F3;
625 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
772 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
626 headerCWF[ i ].time[0] = 0x00;
773 headerCWF[ i ].time[0] = 0x00;
627 headerCWF[ i ].time[0] = 0x00;
774 headerCWF[ i ].time[0] = 0x00;
628 headerCWF[ i ].time[0] = 0x00;
775 headerCWF[ i ].time[0] = 0x00;
629 headerCWF[ i ].time[0] = 0x00;
776 headerCWF[ i ].time[0] = 0x00;
630 headerCWF[ i ].time[0] = 0x00;
777 headerCWF[ i ].time[0] = 0x00;
631 headerCWF[ i ].time[0] = 0x00;
778 headerCWF[ i ].time[0] = 0x00;
632 }
779 }
633 return LFR_SUCCESSFUL;
780 return LFR_SUCCESSFUL;
634 }
781 }
635
782
636 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
783 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
637 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
784 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
638 {
785 {
639 /** This function sends SWF CCSDS packets (F2, F1 or F0).
786 /** This function sends SWF CCSDS packets (F2, F1 or F0).
640 *
787 *
641 * @param waveform points to the buffer containing the data that will be send.
788 * @param waveform points to the buffer containing the data that will be send.
642 * @param sid is the source identifier of the data that will be sent.
789 * @param sid is the source identifier of the data that will be sent.
643 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
790 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
644 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
791 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
645 * contain information to setup the transmission of the data packets.
792 * contain information to setup the transmission of the data packets.
646 *
793 *
647 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
794 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
648 *
795 *
649 */
796 */
650
797
651 unsigned int i;
798 unsigned int i;
652 int ret;
799 int ret;
653 unsigned int coarseTime;
800 unsigned int coarseTime;
654 unsigned int fineTime;
801 unsigned int fineTime;
655 rtems_status_code status;
802 rtems_status_code status;
656 spw_ioctl_pkt_send spw_ioctl_send_SWF;
803 spw_ioctl_pkt_send spw_ioctl_send_SWF;
657
804
658 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
805 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
659 spw_ioctl_send_SWF.options = 0;
806 spw_ioctl_send_SWF.options = 0;
660
807
661 ret = LFR_DEFAULT;
808 ret = LFR_DEFAULT;
662
809
663 coarseTime = waveform[0];
810 coarseTime = waveform[0];
664 fineTime = waveform[1];
811 fineTime = waveform[1];
665
812
666 for (i=0; i<7; i++) // send waveform
813 for (i=0; i<7; i++) // send waveform
667 {
814 {
668 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
815 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
669 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
816 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
670 // BUILD THE DATA
817 // BUILD THE DATA
671 if (i==6) {
818 if (i==6) {
672 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
819 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
673 }
820 }
674 else {
821 else {
675 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
822 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
676 }
823 }
677 // SET PACKET SEQUENCE COUNTER
824 // SET PACKET SEQUENCE COUNTER
678 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
825 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
679 // SET PACKET TIME
826 // SET PACKET TIME
680 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
827 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
681 //
828 //
682 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
829 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
683 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
830 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
684 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
831 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
685 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
832 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
686 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
833 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
687 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
834 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
688 // SEND PACKET
835 // SEND PACKET
689 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
836 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
690 if (status != RTEMS_SUCCESSFUL) {
837 if (status != RTEMS_SUCCESSFUL) {
691 printf("%d-%d, ERR %d\n", sid, i, (int) status);
838 printf("%d-%d, ERR %d\n", sid, i, (int) status);
692 ret = LFR_DEFAULT;
839 ret = LFR_DEFAULT;
693 }
840 }
694 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
841 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
695 }
842 }
696
843
697 return ret;
844 return ret;
698 }
845 }
699
846
700 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
847 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
701 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
848 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
702 {
849 {
703 /** This function sends CWF CCSDS packets (F2, F1 or F0).
850 /** This function sends CWF CCSDS packets (F2, F1 or F0).
704 *
851 *
705 * @param waveform points to the buffer containing the data that will be send.
852 * @param waveform points to the buffer containing the data that will be send.
706 * @param sid is the source identifier of the data that will be sent.
853 * @param sid is the source identifier of the data that will be sent.
707 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
854 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
708 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
855 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
709 * contain information to setup the transmission of the data packets.
856 * contain information to setup the transmission of the data packets.
710 *
857 *
711 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
858 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
712 *
859 *
713 */
860 */
714
861
715 unsigned int i;
862 unsigned int i;
716 int ret;
863 int ret;
717 unsigned int coarseTime;
864 unsigned int coarseTime;
718 unsigned int fineTime;
865 unsigned int fineTime;
719 rtems_status_code status;
866 rtems_status_code status;
720 spw_ioctl_pkt_send spw_ioctl_send_CWF;
867 spw_ioctl_pkt_send spw_ioctl_send_CWF;
721
868
722 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
869 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
723 spw_ioctl_send_CWF.options = 0;
870 spw_ioctl_send_CWF.options = 0;
724
871
725 ret = LFR_DEFAULT;
872 ret = LFR_DEFAULT;
726
873
727 coarseTime = waveform[0];
874 coarseTime = waveform[0];
728 fineTime = waveform[1];
875 fineTime = waveform[1];
729
876
730 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
877 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
731 {
878 {
732 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
879 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
733 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
880 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
734 // BUILD THE DATA
881 // BUILD THE DATA
735 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
882 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
736 // SET PACKET SEQUENCE COUNTER
883 // SET PACKET SEQUENCE COUNTER
737 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
884 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
738 // SET PACKET TIME
885 // SET PACKET TIME
739 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
886 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
740 //
887 //
741 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
888 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
742 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
889 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
743 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
890 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
744 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
891 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
745 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
892 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
746 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
893 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
747 // SEND PACKET
894 // SEND PACKET
748 if (sid == SID_NORM_CWF_LONG_F3)
895 if (sid == SID_NORM_CWF_LONG_F3)
749 {
896 {
750 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
897 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
751 if (status != RTEMS_SUCCESSFUL) {
898 if (status != RTEMS_SUCCESSFUL) {
752 printf("%d-%d, ERR %d\n", sid, i, (int) status);
899 printf("%d-%d, ERR %d\n", sid, i, (int) status);
753 ret = LFR_DEFAULT;
900 ret = LFR_DEFAULT;
754 }
901 }
755 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
902 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
756 }
903 }
757 else
904 else
758 {
905 {
759 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
906 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
760 if (status != RTEMS_SUCCESSFUL) {
907 if (status != RTEMS_SUCCESSFUL) {
761 printf("%d-%d, ERR %d\n", sid, i, (int) status);
908 printf("%d-%d, ERR %d\n", sid, i, (int) status);
762 ret = LFR_DEFAULT;
909 ret = LFR_DEFAULT;
763 }
910 }
764 }
911 }
765 }
912 }
766
913
767 return ret;
914 return ret;
768 }
915 }
769
916
770 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
917 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
771 {
918 {
772 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
919 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
773 *
920 *
774 * @param waveform points to the buffer containing the data that will be send.
921 * @param waveform points to the buffer containing the data that will be send.
775 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
922 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
776 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
923 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
777 * contain information to setup the transmission of the data packets.
924 * contain information to setup the transmission of the data packets.
778 *
925 *
779 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
926 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
780 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
927 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
781 *
928 *
782 */
929 */
783
930
784 unsigned int i;
931 unsigned int i;
785 int ret;
932 int ret;
786 unsigned int coarseTime;
933 unsigned int coarseTime;
787 unsigned int fineTime;
934 unsigned int fineTime;
788 rtems_status_code status;
935 rtems_status_code status;
789 spw_ioctl_pkt_send spw_ioctl_send_CWF;
936 spw_ioctl_pkt_send spw_ioctl_send_CWF;
790 char *sample;
937 char *sample;
791
938
792 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
939 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
793 spw_ioctl_send_CWF.options = 0;
940 spw_ioctl_send_CWF.options = 0;
794
941
795 ret = LFR_DEFAULT;
942 ret = LFR_DEFAULT;
796
943
797 //**********************
944 //**********************
798 // BUILD CWF3_light DATA
945 // BUILD CWF3_light DATA
799 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
946 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
800 {
947 {
801 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
948 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
802 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
949 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
803 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
950 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
804 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
951 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
805 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
952 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
806 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
953 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
807 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
954 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
808 }
955 }
809
956
810 coarseTime = waveform[0];
957 coarseTime = waveform[0];
811 fineTime = waveform[1];
958 fineTime = waveform[1];
812
959
813 //*********************
960 //*********************
814 // SEND CWF3_light DATA
961 // SEND CWF3_light DATA
815 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
962 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
816 {
963 {
817 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
964 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
818 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
965 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
819 // BUILD THE DATA
966 // BUILD THE DATA
820 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
967 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
821 // SET PACKET SEQUENCE COUNTER
968 // SET PACKET SEQUENCE COUNTER
822 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
969 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
823 // SET PACKET TIME
970 // SET PACKET TIME
824 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
971 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
825 //
972 //
826 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
973 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
827 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
974 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
828 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
975 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
829 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
976 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
830 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
977 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
831 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
978 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
832 // SEND PACKET
979 // SEND PACKET
833 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
980 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
834 if (status != RTEMS_SUCCESSFUL) {
981 if (status != RTEMS_SUCCESSFUL) {
835 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
982 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
836 ret = LFR_DEFAULT;
983 ret = LFR_DEFAULT;
837 }
984 }
838 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
985 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
839 }
986 }
840
987
841 return ret;
988 return ret;
842 }
989 }
843
990
844 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
991 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
845 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
992 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
846 {
993 {
847 unsigned long long int acquisitionTimeAsLong;
994 unsigned long long int acquisitionTimeAsLong;
848 unsigned char localAcquisitionTime[6];
995 unsigned char localAcquisitionTime[6];
849 double deltaT;
996 double deltaT;
850
997
851 deltaT = 0.;
998 deltaT = 0.;
852
999
853 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
1000 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
854 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
1001 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
855 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
1002 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
856 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
1003 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
857 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
1004 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
858 localAcquisitionTime[5] = (unsigned char) ( fineTime );
1005 localAcquisitionTime[5] = (unsigned char) ( fineTime );
859
1006
860 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
1007 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
861 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
1008 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
862 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
1009 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
863 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
1010 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
864 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
1011 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
865 + ( (unsigned long long int) localAcquisitionTime[5] );
1012 + ( (unsigned long long int) localAcquisitionTime[5] );
866
1013
867 switch( sid )
1014 switch( sid )
868 {
1015 {
869 case SID_NORM_SWF_F0:
1016 case SID_NORM_SWF_F0:
870 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
1017 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
871 break;
1018 break;
872
1019
873 case SID_NORM_SWF_F1:
1020 case SID_NORM_SWF_F1:
874 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
1021 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
875 break;
1022 break;
876
1023
877 case SID_NORM_SWF_F2:
1024 case SID_NORM_SWF_F2:
878 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
1025 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
879 break;
1026 break;
880
1027
881 case SID_SBM1_CWF_F1:
1028 case SID_SBM1_CWF_F1:
882 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
1029 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
883 break;
1030 break;
884
1031
885 case SID_SBM2_CWF_F2:
1032 case SID_SBM2_CWF_F2:
886 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
1033 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
887 break;
1034 break;
888
1035
889 case SID_BURST_CWF_F2:
1036 case SID_BURST_CWF_F2:
890 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
1037 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
891 break;
1038 break;
892
1039
893 case SID_NORM_CWF_F3:
1040 case SID_NORM_CWF_F3:
894 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
1041 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
895 break;
1042 break;
896
1043
897 case SID_NORM_CWF_LONG_F3:
1044 case SID_NORM_CWF_LONG_F3:
898 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
1045 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
899 break;
1046 break;
900
1047
901 default:
1048 default:
902 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
1049 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
903 deltaT = 0.;
1050 deltaT = 0.;
904 break;
1051 break;
905 }
1052 }
906
1053
907 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
1054 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
908 //
1055 //
909 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
1056 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
910 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
1057 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
911 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
1058 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
912 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
1059 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
913 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
1060 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
914 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
1061 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
915
1062
916 }
1063 }
917
1064
918 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
1065 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
919 {
1066 {
920 unsigned int i;
1067 unsigned int i;
921 unsigned long long int centerTime_asLong;
1068 unsigned long long int centerTime_asLong;
922 unsigned long long int acquisitionTimeF0_asLong;
1069 unsigned long long int acquisitionTimeF0_asLong;
923 unsigned long long int acquisitionTime_asLong;
1070 unsigned long long int acquisitionTime_asLong;
924 unsigned long long int bufferAcquisitionTime_asLong;
1071 unsigned long long int bufferAcquisitionTime_asLong;
925 unsigned char *ptr1;
1072 unsigned char *ptr1;
926 unsigned char *ptr2;
1073 unsigned char *ptr2;
927 unsigned char *timeCharPtr;
1074 unsigned char *timeCharPtr;
928 unsigned char nb_ring_nodes;
1075 unsigned char nb_ring_nodes;
929 unsigned long long int frequency_asLong;
1076 unsigned long long int frequency_asLong;
930 unsigned long long int nbTicksPerSample_asLong;
1077 unsigned long long int nbTicksPerSample_asLong;
931 unsigned long long int nbSamplesPart1_asLong;
1078 unsigned long long int nbSamplesPart1_asLong;
932 unsigned long long int sampleOffset_asLong;
1079 unsigned long long int sampleOffset_asLong;
933
1080
934 unsigned int deltaT_F0;
1081 unsigned int deltaT_F0;
935 unsigned int deltaT_F1;
1082 unsigned int deltaT_F1;
936 unsigned long long int deltaT_F2;
1083 unsigned long long int deltaT_F2;
937
1084
938 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1085 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
939 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1086 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
940 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1087 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
941 sampleOffset_asLong = 0x00;
1088 sampleOffset_asLong = 0x00;
942
1089
943 // (1) get the f0 acquisition time
1090 // (1) get the f0 acquisition time
944 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1091 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
945
1092
946 // (2) compute the central reference time
1093 // (2) compute the central reference time
947 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1094 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
948
1095
949 // (3) compute the acquisition time of the current snapshot
1096 // (3) compute the acquisition time of the current snapshot
950 switch(frequencyChannel)
1097 switch(frequencyChannel)
951 {
1098 {
952 case 1: // 1 is for F1 = 4096 Hz
1099 case 1: // 1 is for F1 = 4096 Hz
953 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1100 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
954 nb_ring_nodes = NB_RING_NODES_F1;
1101 nb_ring_nodes = NB_RING_NODES_F1;
955 frequency_asLong = 4096;
1102 frequency_asLong = 4096;
956 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1103 nbTicksPerSample_asLong = 16; // 65536 / 4096;
957 break;
1104 break;
958 case 2: // 2 is for F2 = 256 Hz
1105 case 2: // 2 is for F2 = 256 Hz
959 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1106 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
960 nb_ring_nodes = NB_RING_NODES_F2;
1107 nb_ring_nodes = NB_RING_NODES_F2;
961 frequency_asLong = 256;
1108 frequency_asLong = 256;
962 nbTicksPerSample_asLong = 256; // 65536 / 256;
1109 nbTicksPerSample_asLong = 256; // 65536 / 256;
963 break;
1110 break;
964 default:
1111 default:
965 acquisitionTime_asLong = centerTime_asLong;
1112 acquisitionTime_asLong = centerTime_asLong;
966 frequency_asLong = 256;
1113 frequency_asLong = 256;
967 nbTicksPerSample_asLong = 256;
1114 nbTicksPerSample_asLong = 256;
968 break;
1115 break;
969 }
1116 }
970
1117
971 //****************************************************************************
1118 //****************************************************************************
972 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1119 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
973 for (i=0; i<nb_ring_nodes; i++)
1120 for (i=0; i<nb_ring_nodes; i++)
974 {
1121 {
975 PRINTF1("%d ... ", i)
1122 PRINTF1("%d ... ", i)
976 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1123 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
977 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1124 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
978 {
1125 {
979 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1126 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
980 break;
1127 break;
981 }
1128 }
982 ring_node_to_send = ring_node_to_send->previous;
1129 ring_node_to_send = ring_node_to_send->previous;
983 }
1130 }
984
1131
985 // (5) compute the number of samples to take in the current buffer
1132 // (5) compute the number of samples to take in the current buffer
986 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1133 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
987 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1134 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
988 PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1135 PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong)
989
1136
990 // (6) compute the final acquisition time
1137 // (6) compute the final acquisition time
991 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1138 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
992 sampleOffset_asLong * nbTicksPerSample_asLong;
1139 sampleOffset_asLong * nbTicksPerSample_asLong;
993
1140
994 // (7) copy the acquisition time at the beginning of the extrated snapshot
1141 // (7) copy the acquisition time at the beginning of the extrated snapshot
995 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1142 ptr1 = (unsigned char*) &acquisitionTime_asLong;
996 ptr2 = (unsigned char*) wf_snap_extracted;
1143 ptr2 = (unsigned char*) wf_snap_extracted;
997 ptr2[0] = ptr1[ 0 + 2 ];
1144 ptr2[0] = ptr1[ 0 + 2 ];
998 ptr2[1] = ptr1[ 1 + 2 ];
1145 ptr2[1] = ptr1[ 1 + 2 ];
999 ptr2[2] = ptr1[ 2 + 2 ];
1146 ptr2[2] = ptr1[ 2 + 2 ];
1000 ptr2[3] = ptr1[ 3 + 2 ];
1147 ptr2[3] = ptr1[ 3 + 2 ];
1001 ptr2[6] = ptr1[ 4 + 2 ];
1148 ptr2[6] = ptr1[ 4 + 2 ];
1002 ptr2[7] = ptr1[ 5 + 2 ];
1149 ptr2[7] = ptr1[ 5 + 2 ];
1003
1150
1004 // re set the synchronization bit
1151 // re set the synchronization bit
1005 timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address;
1152 timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address;
1006 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
1153 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
1007
1154
1008 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
1155 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
1009 {
1156 {
1010 nbSamplesPart1_asLong = 0;
1157 nbSamplesPart1_asLong = 0;
1011 }
1158 }
1012 // copy the part 1 of the snapshot in the extracted buffer
1159 // copy the part 1 of the snapshot in the extracted buffer
1013 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1160 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1014 {
1161 {
1015 wf_snap_extracted[i + TIME_OFFSET] =
1162 wf_snap_extracted[i + TIME_OFFSET] =
1016 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1163 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1017 }
1164 }
1018 // copy the part 2 of the snapshot in the extracted buffer
1165 // copy the part 2 of the snapshot in the extracted buffer
1019 ring_node_to_send = ring_node_to_send->next;
1166 ring_node_to_send = ring_node_to_send->next;
1020 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1167 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1021 {
1168 {
1022 wf_snap_extracted[i + TIME_OFFSET] =
1169 wf_snap_extracted[i + TIME_OFFSET] =
1023 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1170 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1024 }
1171 }
1025 }
1172 }
1026
1173
1027 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1174 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1028 {
1175 {
1029 unsigned char *acquisitionTimeCharPtr;
1176 unsigned char *acquisitionTimeCharPtr;
1030
1177
1031 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1178 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1032
1179
1033 *acquisitionTimeAslong = 0x00;
1180 *acquisitionTimeAslong = 0x00;
1034 *acquisitionTimeAslong = ( (unsigned long long int) (acquisitionTimeCharPtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1181 *acquisitionTimeAslong = ( (unsigned long long int) (acquisitionTimeCharPtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1035 + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 )
1182 + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 )
1036 + ( (unsigned long long int) acquisitionTimeCharPtr[2] << 24 )
1183 + ( (unsigned long long int) acquisitionTimeCharPtr[2] << 24 )
1037 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 16 )
1184 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 16 )
1038 + ( (unsigned long long int) acquisitionTimeCharPtr[6] << 8 )
1185 + ( (unsigned long long int) acquisitionTimeCharPtr[6] << 8 )
1039 + ( (unsigned long long int) acquisitionTimeCharPtr[7] );
1186 + ( (unsigned long long int) acquisitionTimeCharPtr[7] );
1040 }
1187 }
1041
1188
1042 //**************
1189 //**************
1043 // wfp registers
1190 // wfp registers
1044 void reset_wfp_burst_enable(void)
1191 void reset_wfp_burst_enable(void)
1045 {
1192 {
1046 /** This function resets the waveform picker burst_enable register.
1193 /** This function resets the waveform picker burst_enable register.
1047 *
1194 *
1048 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1195 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1049 *
1196 *
1050 */
1197 */
1051
1198
1052 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1199 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1053 }
1200 }
1054
1201
1055 void reset_wfp_status( void )
1202 void reset_wfp_status( void )
1056 {
1203 {
1057 /** This function resets the waveform picker status register.
1204 /** This function resets the waveform picker status register.
1058 *
1205 *
1059 * All status bits are set to 0 [new_err full_err full].
1206 * All status bits are set to 0 [new_err full_err full].
1060 *
1207 *
1061 */
1208 */
1062
1209
1063 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1210 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1064 }
1211 }
1065
1212
1066 void reset_waveform_picker_regs(void)
1213 void reset_waveform_picker_regs(void)
1067 {
1214 {
1068 /** This function resets the waveform picker module registers.
1215 /** This function resets the waveform picker module registers.
1069 *
1216 *
1070 * The registers affected by this function are located at the following offset addresses:
1217 * The registers affected by this function are located at the following offset addresses:
1071 * - 0x00 data_shaping
1218 * - 0x00 data_shaping
1072 * - 0x04 run_burst_enable
1219 * - 0x04 run_burst_enable
1073 * - 0x08 addr_data_f0
1220 * - 0x08 addr_data_f0
1074 * - 0x0C addr_data_f1
1221 * - 0x0C addr_data_f1
1075 * - 0x10 addr_data_f2
1222 * - 0x10 addr_data_f2
1076 * - 0x14 addr_data_f3
1223 * - 0x14 addr_data_f3
1077 * - 0x18 status
1224 * - 0x18 status
1078 * - 0x1C delta_snapshot
1225 * - 0x1C delta_snapshot
1079 * - 0x20 delta_f0
1226 * - 0x20 delta_f0
1080 * - 0x24 delta_f0_2
1227 * - 0x24 delta_f0_2
1081 * - 0x28 delta_f1
1228 * - 0x28 delta_f1
1082 * - 0x2c delta_f2
1229 * - 0x2c delta_f2
1083 * - 0x30 nb_data_by_buffer
1230 * - 0x30 nb_data_by_buffer
1084 * - 0x34 nb_snapshot_param
1231 * - 0x34 nb_snapshot_param
1085 * - 0x38 start_date
1232 * - 0x38 start_date
1086 * - 0x3c nb_word_in_buffer
1233 * - 0x3c nb_word_in_buffer
1087 *
1234 *
1088 */
1235 */
1089
1236
1090 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1237 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1091 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1238 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1092 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1239 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1093 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1240 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1094 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1241 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1095 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14
1242 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14
1096 reset_wfp_status(); // 0x18
1243 reset_wfp_status(); // 0x18
1097 //
1244 //
1098 set_wfp_delta_snapshot(); // 0x1c
1245 set_wfp_delta_snapshot(); // 0x1c
1099 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1246 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1100 set_wfp_delta_f1(); // 0x28
1247 set_wfp_delta_f1(); // 0x28
1101 set_wfp_delta_f2(); // 0x2c
1248 set_wfp_delta_f2(); // 0x2c
1102 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1249 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1103 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1250 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1104 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1251 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1105 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1252 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1106 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1253 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1107 // 2688 = 8 * 336
1254 // 2688 = 8 * 336
1108 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1255 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1109 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1256 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1110 waveform_picker_regs->start_date = 0x00; // 0x38
1257 waveform_picker_regs->start_date = 0x00; // 0x38
1111 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1258 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1112 }
1259 }
1113
1260
1114 void set_wfp_data_shaping( void )
1261 void set_wfp_data_shaping( void )
1115 {
1262 {
1116 /** This function sets the data_shaping register of the waveform picker module.
1263 /** This function sets the data_shaping register of the waveform picker module.
1117 *
1264 *
1118 * The value is read from one field of the parameter_dump_packet structure:\n
1265 * The value is read from one field of the parameter_dump_packet structure:\n
1119 * bw_sp0_sp1_r0_r1
1266 * bw_sp0_sp1_r0_r1
1120 *
1267 *
1121 */
1268 */
1122
1269
1123 unsigned char data_shaping;
1270 unsigned char data_shaping;
1124
1271
1125 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1272 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1126 // waveform picker : [R1 R0 SP1 SP0 BW]
1273 // waveform picker : [R1 R0 SP1 SP0 BW]
1127
1274
1128 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1275 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1129
1276
1130 waveform_picker_regs->data_shaping =
1277 waveform_picker_regs->data_shaping =
1131 ( (data_shaping & 0x10) >> 4 ) // BW
1278 ( (data_shaping & 0x10) >> 4 ) // BW
1132 + ( (data_shaping & 0x08) >> 2 ) // SP0
1279 + ( (data_shaping & 0x08) >> 2 ) // SP0
1133 + ( (data_shaping & 0x04) ) // SP1
1280 + ( (data_shaping & 0x04) ) // SP1
1134 + ( (data_shaping & 0x02) << 2 ) // R0
1281 + ( (data_shaping & 0x02) << 2 ) // R0
1135 + ( (data_shaping & 0x01) << 4 ); // R1
1282 + ( (data_shaping & 0x01) << 4 ); // R1
1136 }
1283 }
1137
1284
1138 void set_wfp_burst_enable_register( unsigned char mode )
1285 void set_wfp_burst_enable_register( unsigned char mode )
1139 {
1286 {
1140 /** This function sets the waveform picker burst_enable register depending on the mode.
1287 /** This function sets the waveform picker burst_enable register depending on the mode.
1141 *
1288 *
1142 * @param mode is the LFR mode to launch.
1289 * @param mode is the LFR mode to launch.
1143 *
1290 *
1144 * The burst bits shall be before the enable bits.
1291 * The burst bits shall be before the enable bits.
1145 *
1292 *
1146 */
1293 */
1147
1294
1148 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1295 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1149 // the burst bits shall be set first, before the enable bits
1296 // the burst bits shall be set first, before the enable bits
1150 switch(mode) {
1297 switch(mode) {
1151 case(LFR_MODE_NORMAL):
1298 case(LFR_MODE_NORMAL):
1152 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1299 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1153 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1300 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1154 break;
1301 break;
1155 case(LFR_MODE_BURST):
1302 case(LFR_MODE_BURST):
1156 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1303 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1157 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1304 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1158 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1305 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1159 break;
1306 break;
1160 case(LFR_MODE_SBM1):
1307 case(LFR_MODE_SBM1):
1161 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1308 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1162 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1309 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1163 break;
1310 break;
1164 case(LFR_MODE_SBM2):
1311 case(LFR_MODE_SBM2):
1165 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1312 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1166 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1313 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1167 break;
1314 break;
1168 default:
1315 default:
1169 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1316 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1170 break;
1317 break;
1171 }
1318 }
1172 }
1319 }
1173
1320
1174 void set_wfp_delta_snapshot( void )
1321 void set_wfp_delta_snapshot( void )
1175 {
1322 {
1176 /** This function sets the delta_snapshot register of the waveform picker module.
1323 /** This function sets the delta_snapshot register of the waveform picker module.
1177 *
1324 *
1178 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1325 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1179 * - sy_lfr_n_swf_p[0]
1326 * - sy_lfr_n_swf_p[0]
1180 * - sy_lfr_n_swf_p[1]
1327 * - sy_lfr_n_swf_p[1]
1181 *
1328 *
1182 */
1329 */
1183
1330
1184 unsigned int delta_snapshot;
1331 unsigned int delta_snapshot;
1185 unsigned int delta_snapshot_in_T2;
1332 unsigned int delta_snapshot_in_T2;
1186
1333
1187 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1334 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1188 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1335 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1189
1336
1190 delta_snapshot_in_T2 = delta_snapshot * 256;
1337 delta_snapshot_in_T2 = delta_snapshot * 256;
1191 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1338 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1192 }
1339 }
1193
1340
1194 void set_wfp_delta_f0_f0_2( void )
1341 void set_wfp_delta_f0_f0_2( void )
1195 {
1342 {
1196 unsigned int delta_snapshot;
1343 unsigned int delta_snapshot;
1197 unsigned int nb_samples_per_snapshot;
1344 unsigned int nb_samples_per_snapshot;
1198 float delta_f0_in_float;
1345 float delta_f0_in_float;
1199
1346
1200 delta_snapshot = waveform_picker_regs->delta_snapshot;
1347 delta_snapshot = waveform_picker_regs->delta_snapshot;
1201 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1348 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1202 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1349 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1203
1350
1204 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1351 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1205 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1352 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1206 }
1353 }
1207
1354
1208 void set_wfp_delta_f1( void )
1355 void set_wfp_delta_f1( void )
1209 {
1356 {
1210 unsigned int delta_snapshot;
1357 unsigned int delta_snapshot;
1211 unsigned int nb_samples_per_snapshot;
1358 unsigned int nb_samples_per_snapshot;
1212 float delta_f1_in_float;
1359 float delta_f1_in_float;
1213
1360
1214 delta_snapshot = waveform_picker_regs->delta_snapshot;
1361 delta_snapshot = waveform_picker_regs->delta_snapshot;
1215 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1362 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1216 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1363 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1217
1364
1218 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1365 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1219 }
1366 }
1220
1367
1221 void set_wfp_delta_f2()
1368 void set_wfp_delta_f2()
1222 {
1369 {
1223 unsigned int delta_snapshot;
1370 unsigned int delta_snapshot;
1224 unsigned int nb_samples_per_snapshot;
1371 unsigned int nb_samples_per_snapshot;
1225
1372
1226 delta_snapshot = waveform_picker_regs->delta_snapshot;
1373 delta_snapshot = waveform_picker_regs->delta_snapshot;
1227 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1374 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1228
1375
1229 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1376 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1230 }
1377 }
1231
1378
1232 //*****************
1379 //*****************
1233 // local parameters
1380 // local parameters
1234
1381
1235 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1382 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1236 {
1383 {
1237 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1384 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1238 *
1385 *
1239 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1386 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1240 * @param sid is the source identifier of the packet being updated.
1387 * @param sid is the source identifier of the packet being updated.
1241 *
1388 *
1242 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1389 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1243 * The sequence counters shall wrap around from 2^14 to zero.
1390 * The sequence counters shall wrap around from 2^14 to zero.
1244 * The sequence counter shall start at zero at startup.
1391 * The sequence counter shall start at zero at startup.
1245 *
1392 *
1246 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1393 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1247 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1394 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1248 *
1395 *
1249 */
1396 */
1250
1397
1251 unsigned short *sequence_cnt;
1398 unsigned short *sequence_cnt;
1252 unsigned short segmentation_grouping_flag;
1399 unsigned short segmentation_grouping_flag;
1253 unsigned short new_packet_sequence_control;
1400 unsigned short new_packet_sequence_control;
1254 rtems_mode initial_mode_set;
1401 rtems_mode initial_mode_set;
1255 rtems_mode current_mode_set;
1402 rtems_mode current_mode_set;
1256 rtems_status_code status;
1403 rtems_status_code status;
1257
1404
1258 //******************************************
1405 //******************************************
1259 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1406 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1260 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1407 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1261
1408
1262 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1409 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1263 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1410 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1264 || (sid == SID_BURST_CWF_F2)
1411 || (sid == SID_BURST_CWF_F2)
1265 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1412 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1266 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1413 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1267 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1414 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1268 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1415 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1269 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1416 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1270 {
1417 {
1271 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1418 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1272 }
1419 }
1273 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1420 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1274 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1421 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1275 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1422 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1276 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1423 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1277 {
1424 {
1278 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1425 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1279 }
1426 }
1280 else
1427 else
1281 {
1428 {
1282 sequence_cnt = (unsigned short *) NULL;
1429 sequence_cnt = (unsigned short *) NULL;
1283 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1430 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1284 }
1431 }
1285
1432
1286 if (sequence_cnt != NULL)
1433 if (sequence_cnt != NULL)
1287 {
1434 {
1288 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1435 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1289 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1436 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1290
1437
1291 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1438 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1292
1439
1293 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1440 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1294 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1441 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1295
1442
1296 // increment the sequence counter
1443 // increment the sequence counter
1297 if ( *sequence_cnt < SEQ_CNT_MAX)
1444 if ( *sequence_cnt < SEQ_CNT_MAX)
1298 {
1445 {
1299 *sequence_cnt = *sequence_cnt + 1;
1446 *sequence_cnt = *sequence_cnt + 1;
1300 }
1447 }
1301 else
1448 else
1302 {
1449 {
1303 *sequence_cnt = 0;
1450 *sequence_cnt = 0;
1304 }
1451 }
1305 }
1452 }
1306
1453
1307 //***********************************
1454 //***********************************
1308 // RESET THE MODE OF THE CALLING TASK
1455 // RESET THE MODE OF THE CALLING TASK
1309 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1456 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1310 }
1457 }
General Comments 0
You need to be logged in to leave comments. Login now