@@ -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 | 2 | # Makefile for building: bin/fsw |
|
3 |
# Generated by qmake (2.01a) (Qt 4.8.6) on: Tu |
|
|
3 | # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Jul 17 15:49:45 2014 | |
|
4 | 4 | # Project: fsw-qt.pro |
|
5 | 5 | # Template: app |
|
6 | 6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
7 | 7 | ############################################################################# |
|
8 | 8 | |
|
9 | 9 | ####### Compiler, tools and options |
|
10 | 10 | |
|
11 | 11 | CC = sparc-rtems-gcc |
|
12 | 12 | CXX = sparc-rtems-g++ |
|
13 |
DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4= |
|
|
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 | 14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
15 | 15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
16 | 16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters |
|
17 | 17 | LINK = sparc-rtems-g++ |
|
18 | 18 | LFLAGS = |
|
19 | 19 | LIBS = $(SUBLIBS) |
|
20 | 20 | AR = sparc-rtems-ar rcs |
|
21 | 21 | RANLIB = |
|
22 | 22 | QMAKE = /usr/bin/qmake-qt4 |
|
23 | 23 | TAR = tar -cf |
|
24 | 24 | COMPRESS = gzip -9f |
|
25 | 25 | COPY = cp -f |
|
26 | 26 | SED = sed |
|
27 | 27 | COPY_FILE = $(COPY) |
|
28 | 28 | COPY_DIR = $(COPY) -r |
|
29 | 29 | STRIP = sparc-rtems-strip |
|
30 | 30 | INSTALL_FILE = install -m 644 -p |
|
31 | 31 | INSTALL_DIR = $(COPY_DIR) |
|
32 | 32 | INSTALL_PROGRAM = install -m 755 -p |
|
33 | 33 | DEL_FILE = rm -f |
|
34 | 34 | SYMLINK = ln -f -s |
|
35 | 35 | DEL_DIR = rmdir |
|
36 | 36 | MOVE = mv -f |
|
37 | 37 | CHK_DIR_EXISTS= test -d |
|
38 | 38 | MKDIR = mkdir -p |
|
39 | 39 | |
|
40 | 40 | ####### Output directory |
|
41 | 41 | |
|
42 | 42 | OBJECTS_DIR = obj/ |
|
43 | 43 | |
|
44 | 44 | ####### Files |
|
45 | 45 | |
|
46 | 46 | SOURCES = ../src/wf_handler.c \ |
|
47 | 47 | ../src/tc_handler.c \ |
|
48 | 48 | ../src/fsw_misc.c \ |
|
49 | 49 | ../src/fsw_init.c \ |
|
50 | 50 | ../src/fsw_globals.c \ |
|
51 | 51 | ../src/fsw_spacewire.c \ |
|
52 | 52 | ../src/tc_load_dump_parameters.c \ |
|
53 | 53 | ../src/tm_lfr_tc_exe.c \ |
|
54 | 54 | ../src/tc_acceptance.c \ |
|
55 | 55 | ../src/processing/fsw_processing.c \ |
|
56 | 56 | ../src/processing/avf0_prc0.c \ |
|
57 | 57 | ../src/processing/avf1_prc1.c \ |
|
58 | 58 | ../src/processing/avf2_prc2.c \ |
|
59 | 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 | 62 | OBJECTS = obj/wf_handler.o \ |
|
62 | 63 | obj/tc_handler.o \ |
|
63 | 64 | obj/fsw_misc.o \ |
|
64 | 65 | obj/fsw_init.o \ |
|
65 | 66 | obj/fsw_globals.o \ |
|
66 | 67 | obj/fsw_spacewire.o \ |
|
67 | 68 | obj/tc_load_dump_parameters.o \ |
|
68 | 69 | obj/tm_lfr_tc_exe.o \ |
|
69 | 70 | obj/tc_acceptance.o \ |
|
70 | 71 | obj/fsw_processing.o \ |
|
71 | 72 | obj/avf0_prc0.o \ |
|
72 | 73 | obj/avf1_prc1.o \ |
|
73 | 74 | obj/avf2_prc2.o \ |
|
74 | 75 | obj/lfr_cpu_usage_report.o \ |
|
75 | obj/basic_parameters.o | |
|
76 | obj/basic_parameters.o \ | |
|
77 | obj/fsw_spool.o | |
|
76 | 78 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
77 | 79 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
78 | 80 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
79 | 81 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
80 | 82 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
81 | 83 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
82 | 84 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
83 | 85 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
84 | 86 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
85 | 87 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
86 | 88 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
87 | 89 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
88 | 90 | sparc.pri \ |
|
89 | 91 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
90 | 92 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
91 | 93 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
92 | 94 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
93 | 95 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
94 | 96 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
95 | 97 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
96 | 98 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
97 | 99 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
98 | 100 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
99 | 101 | fsw-qt.pro |
|
100 | 102 | QMAKE_TARGET = fsw |
|
101 | 103 | DESTDIR = bin/ |
|
102 | 104 | TARGET = bin/fsw |
|
103 | 105 | |
|
104 | 106 | first: all |
|
105 | 107 | ####### Implicit rules |
|
106 | 108 | |
|
107 | 109 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
108 | 110 | |
|
109 | 111 | .cpp.o: |
|
110 | 112 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
111 | 113 | |
|
112 | 114 | .cc.o: |
|
113 | 115 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
114 | 116 | |
|
115 | 117 | .cxx.o: |
|
116 | 118 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
117 | 119 | |
|
118 | 120 | .C.o: |
|
119 | 121 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
120 | 122 | |
|
121 | 123 | .c.o: |
|
122 | 124 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
123 | 125 | |
|
124 | 126 | ####### Build rules |
|
125 | 127 | |
|
126 | 128 | all: Makefile $(TARGET) |
|
127 | 129 | |
|
128 | 130 | $(TARGET): $(OBJECTS) |
|
129 | 131 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
130 | 132 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
131 | 133 | |
|
132 | 134 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
133 | 135 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
134 | 136 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
135 | 137 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
136 | 138 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
137 | 139 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
138 | 140 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
139 | 141 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
140 | 142 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
141 | 143 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
142 | 144 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
143 | 145 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
144 | 146 | sparc.pri \ |
|
145 | 147 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
146 | 148 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
147 | 149 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
148 | 150 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
149 | 151 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
150 | 152 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
151 | 153 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
152 | 154 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
153 | 155 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
154 | 156 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
155 | 157 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
156 | 158 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
157 | 159 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
158 | 160 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
159 | 161 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
160 | 162 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
161 | 163 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
162 | 164 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
163 | 165 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
164 | 166 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
165 | 167 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
166 | 168 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
167 | 169 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
168 | 170 | sparc.pri: |
|
169 | 171 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
170 | 172 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
171 | 173 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
172 | 174 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
173 | 175 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
174 | 176 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
175 | 177 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
176 | 178 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
177 | 179 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
178 | 180 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
179 | 181 | qmake: FORCE |
|
180 | 182 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
181 | 183 | |
|
182 | 184 | dist: |
|
183 | 185 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 |
|
184 | 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 | 189 | clean:compiler_clean |
|
188 | 190 | -$(DEL_FILE) $(OBJECTS) |
|
189 | 191 | -$(DEL_FILE) *~ core *.core |
|
190 | 192 | |
|
191 | 193 | |
|
192 | 194 | ####### Sub-libraries |
|
193 | 195 | |
|
194 | 196 | distclean: clean |
|
195 | 197 | -$(DEL_FILE) $(TARGET) |
|
196 | 198 | -$(DEL_FILE) Makefile |
|
197 | 199 | |
|
198 | 200 | |
|
199 | 201 | grmon: |
|
200 | 202 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
201 | 203 | |
|
202 | 204 | check: first |
|
203 | 205 | |
|
204 | 206 | compiler_rcc_make_all: |
|
205 | 207 | compiler_rcc_clean: |
|
206 | 208 | compiler_uic_make_all: |
|
207 | 209 | compiler_uic_clean: |
|
208 | 210 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
209 | 211 | compiler_image_collection_clean: |
|
210 | 212 | -$(DEL_FILE) qmake_image_collection.cpp |
|
211 | 213 | compiler_yacc_decl_make_all: |
|
212 | 214 | compiler_yacc_decl_clean: |
|
213 | 215 | compiler_yacc_impl_make_all: |
|
214 | 216 | compiler_yacc_impl_clean: |
|
215 | 217 | compiler_lex_make_all: |
|
216 | 218 | compiler_lex_clean: |
|
217 | 219 | compiler_clean: |
|
218 | 220 | |
|
219 | 221 | ####### Compile |
|
220 | 222 | |
|
221 | 223 | obj/wf_handler.o: ../src/wf_handler.c |
|
222 | 224 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c |
|
223 | 225 | |
|
224 | 226 | obj/tc_handler.o: ../src/tc_handler.c |
|
225 | 227 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c |
|
226 | 228 | |
|
227 | 229 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
228 | 230 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
229 | 231 | |
|
230 | 232 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c |
|
231 | 233 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c |
|
232 | 234 | |
|
233 | 235 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
234 | 236 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
235 | 237 | |
|
236 | 238 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c |
|
237 | 239 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c |
|
238 | 240 | |
|
239 | 241 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c |
|
240 | 242 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c |
|
241 | 243 | |
|
242 | 244 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c |
|
243 | 245 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c |
|
244 | 246 | |
|
245 | 247 | obj/tc_acceptance.o: ../src/tc_acceptance.c |
|
246 | 248 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c |
|
247 | 249 | |
|
248 | 250 | obj/fsw_processing.o: ../src/processing/fsw_processing.c |
|
249 | 251 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c |
|
250 | 252 | |
|
251 | 253 | obj/avf0_prc0.o: ../src/processing/avf0_prc0.c |
|
252 | 254 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c |
|
253 | 255 | |
|
254 | 256 | obj/avf1_prc1.o: ../src/processing/avf1_prc1.c |
|
255 | 257 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c |
|
256 | 258 | |
|
257 | 259 | obj/avf2_prc2.o: ../src/processing/avf2_prc2.c |
|
258 | 260 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c |
|
259 | 261 | |
|
260 | 262 | obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c |
|
261 | 263 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c |
|
262 | 264 | |
|
263 | 265 | obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c |
|
264 | 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 | 271 | ####### Install |
|
267 | 272 | |
|
268 | 273 | install: FORCE |
|
269 | 274 | |
|
270 | 275 | uninstall: FORCE |
|
271 | 276 | |
|
272 | 277 | FORCE: |
|
273 | 278 |
@@ -1,21 +1,20 | |||
|
1 | 1 | SREC_PREFIX = RpwLfrApp |
|
2 |
SREC_COUNTER |
|
|
3 | SREC_COUNTER_DATA = 0004 | |
|
4 | SREC_FSW_REF = rev-1-0-0-7 | |
|
2 | SREC_COUNTER = 0003 | |
|
3 | SREC_FSW_REF = rev-2-0-1-0 | |
|
5 | 4 | SREC_SUFFIX = .srec |
|
6 |
SREC_TEXT = $(SREC_PREFIX)_$(SREC_COUNTER |
|
|
7 |
SREC_DATA = $(SREC_PREFIX)_$(SREC_COUNTER |
|
|
5 | SREC_TEXT = $(SREC_PREFIX)_$(SREC_COUNTER)_text_$(SREC_FSW_REF)$(SREC_SUFFIX) | |
|
6 | SREC_DATA = $(SREC_PREFIX)_$(SREC_COUNTER)_data_$(SREC_FSW_REF)$(SREC_SUFFIX) | |
|
8 | 7 | OBJCOPY = sparc-rtems-objcopy |
|
9 | 8 | OBJCOPY_OPT = -g -v |
|
10 | 9 | |
|
11 | 10 | all: text data |
|
12 | 11 | |
|
13 | 12 | text: fsw |
|
14 | 13 | $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_TEXT) -O srec -j .text |
|
15 | 14 | |
|
16 | 15 | data: fsw |
|
17 | 16 | $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_DATA) -O srec -j .data |
|
18 | 17 | |
|
19 | 18 | clean: |
|
20 | 19 | rm *.srec |
|
21 | 20 |
@@ -1,95 +1,101 | |||
|
1 | 1 | TEMPLATE = app |
|
2 | 2 | # CONFIG += console v8 sim |
|
3 | 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 | 5 | CONFIG -= qt |
|
6 | 6 | |
|
7 | 7 | include(./sparc.pri) |
|
8 | 8 | |
|
9 | 9 | # flight software version |
|
10 | 10 | SWVERSION=-1-0 |
|
11 | 11 | DEFINES += SW_VERSION_N1=2 # major |
|
12 | 12 | DEFINES += SW_VERSION_N2=0 # minor |
|
13 | 13 | DEFINES += SW_VERSION_N3=1 # patch |
|
14 |
DEFINES += SW_VERSION_N4= |
|
|
14 | DEFINES += SW_VERSION_N4=1 # internal | |
|
15 | 15 | |
|
16 | 16 | contains( CONFIG, debug_tch ) { |
|
17 | 17 | DEFINES += DEBUG_TCH |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | contains( CONFIG, vhdl_dev ) { |
|
21 | 21 | DEFINES += VHDL_DEV |
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 24 | contains( CONFIG, verbose ) { |
|
25 | 25 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | contains( CONFIG, debug_messages ) { |
|
29 | 29 | DEFINES += DEBUG_MESSAGES |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | contains( CONFIG, cpu_usage_report ) { |
|
33 | 33 | DEFINES += PRINT_TASK_STATISTICS |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | contains( CONFIG, stack_report ) { |
|
37 | 37 | DEFINES += PRINT_STACK_REPORT |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | contains( CONFIG, boot_messages ) { |
|
41 | 41 | DEFINES += BOOT_MESSAGES |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | contains( CONFIG, fast_scheduler ) { | |
|
45 | DEFINES += FAST_SCHEDULER | |
|
46 | } | |
|
47 | ||
|
44 | 48 | #doxygen.target = doxygen |
|
45 | 49 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
46 | 50 | #QMAKE_EXTRA_TARGETS += doxygen |
|
47 | 51 | |
|
48 | 52 | TARGET = fsw |
|
49 | 53 | |
|
50 | 54 | INCLUDEPATH += \ |
|
51 | 55 | ../src \ |
|
52 | 56 | ../header \ |
|
53 | 57 | ../header/processing \ |
|
54 | 58 | ../src/LFR_basic-parameters |
|
55 | 59 | |
|
56 | 60 | SOURCES += \ |
|
57 | 61 | ../src/wf_handler.c \ |
|
58 | 62 | ../src/tc_handler.c \ |
|
59 | 63 | ../src/fsw_misc.c \ |
|
60 | 64 | ../src/fsw_init.c \ |
|
61 | 65 | ../src/fsw_globals.c \ |
|
62 | 66 | ../src/fsw_spacewire.c \ |
|
63 | 67 | ../src/tc_load_dump_parameters.c \ |
|
64 | 68 | ../src/tm_lfr_tc_exe.c \ |
|
65 | 69 | ../src/tc_acceptance.c \ |
|
66 | 70 | ../src/processing/fsw_processing.c \ |
|
67 | 71 | ../src/processing/avf0_prc0.c \ |
|
68 | 72 | ../src/processing/avf1_prc1.c \ |
|
69 | 73 | ../src/processing/avf2_prc2.c \ |
|
70 | 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 | 78 | HEADERS += \ |
|
74 | 79 | ../header/wf_handler.h \ |
|
75 | 80 | ../header/tc_handler.h \ |
|
76 | 81 | ../header/grlib_regs.h \ |
|
77 | 82 | ../header/fsw_params.h \ |
|
78 | 83 | ../header/fsw_misc.h \ |
|
79 | 84 | ../header/fsw_init.h \ |
|
80 | 85 | ../header/ccsds_types.h \ |
|
81 | 86 | ../header/fsw_spacewire.h \ |
|
82 | 87 | ../header/tc_load_dump_parameters.h \ |
|
83 | 88 | ../header/tm_lfr_tc_exe.h \ |
|
84 | 89 | ../header/tc_acceptance.h \ |
|
85 | 90 | ../header/fsw_params_nb_bytes.h \ |
|
86 | 91 | ../header/fsw_params_processing.h \ |
|
87 | 92 | ../header/processing/fsw_processing.h \ |
|
88 | 93 | ../header/processing/avf0_prc0.h \ |
|
89 | 94 | ../header/processing/avf1_prc1.h \ |
|
90 | 95 | ../header/processing/avf2_prc2.h \ |
|
91 | 96 | ../header/fsw_params_wf_handler.h \ |
|
92 | 97 | ../header/lfr_cpu_usage_report.h \ |
|
93 | 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 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 3. |
|
|
3 | <!-- Written by QtCreator 3.1.2, 2014-08-28T14:53:30. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
7 | 7 | <value type="int">0</value> |
|
8 | 8 | </data> |
|
9 | 9 | <data> |
|
10 | 10 | <variable>ProjectExplorer.Project.EditorSettings</variable> |
|
11 | 11 | <valuemap type="QVariantMap"> |
|
12 | 12 | <value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|
13 | 13 | <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|
14 | 14 | <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|
15 | 15 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|
16 | 16 | <value type="QString" key="language">Cpp</value> |
|
17 | 17 | <valuemap type="QVariantMap" key="value"> |
|
18 | 18 | <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
|
19 | 19 | </valuemap> |
|
20 | 20 | </valuemap> |
|
21 | 21 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|
22 | 22 | <value type="QString" key="language">QmlJS</value> |
|
23 | 23 | <valuemap type="QVariantMap" key="value"> |
|
24 | 24 | <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
|
25 | 25 | </valuemap> |
|
26 | 26 | </valuemap> |
|
27 | 27 | <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|
28 | 28 | <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
|
29 | 29 | <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|
30 | 30 | <value type="int" key="EditorConfiguration.IndentSize">4</value> |
|
31 | 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 | 34 | <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|
33 | 35 | <value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|
34 | 36 | <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|
37 | <value type="bool" key="EditorConfiguration.ShowMargin">false</value> | |
|
35 | 38 | <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|
36 | 39 | <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|
37 | 40 | <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|
38 | 41 | <value type="int" key="EditorConfiguration.TabSize">8</value> |
|
39 | 42 | <value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|
40 | 43 | <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|
41 | 44 | <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|
42 | 45 | <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|
43 | 46 | <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|
44 | 47 | <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|
45 | 48 | </valuemap> |
|
46 | 49 | </data> |
|
47 | 50 | <data> |
|
48 | 51 | <variable>ProjectExplorer.Project.PluginSettings</variable> |
|
49 | 52 | <valuemap type="QVariantMap"/> |
|
50 | 53 | </data> |
|
51 | 54 | <data> |
|
52 | 55 | <variable>ProjectExplorer.Project.Target.0</variable> |
|
53 | 56 | <valuemap type="QVariantMap"> |
|
54 | 57 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
55 | 58 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
56 | 59 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
57 | 60 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
58 | 61 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
59 | 62 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
60 | 63 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
61 | 64 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
62 | 65 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
63 | 66 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
64 | 67 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
65 | 68 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
66 | 69 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
67 | 70 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
68 | 71 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
69 | 72 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
70 | 73 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
71 | 74 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
72 | 75 | </valuemap> |
|
73 | 76 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
74 | 77 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
75 | 78 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
76 | 79 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
77 | 80 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
78 | 81 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
79 | 82 | <value type="QString">-w</value> |
|
80 | 83 | <value type="QString">-r</value> |
|
81 | 84 | </valuelist> |
|
82 | 85 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
83 | 86 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
84 | 87 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
85 | 88 | </valuemap> |
|
86 | 89 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
87 | 90 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
88 | 91 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
89 | 92 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
90 | 93 | </valuemap> |
|
91 | 94 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
92 | 95 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
93 | 96 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
94 | 97 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
95 | 98 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
96 | 99 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
97 | 100 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
98 | 101 | <value type="QString">-w</value> |
|
99 | 102 | <value type="QString">-r</value> |
|
100 | 103 | </valuelist> |
|
101 | 104 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
102 | 105 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
103 | 106 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
104 | 107 | </valuemap> |
|
105 | 108 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
106 | 109 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
107 | 110 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
108 | 111 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
109 | 112 | </valuemap> |
|
110 | 113 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
111 | 114 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
112 | 115 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
113 | 116 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
114 | 117 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
115 | 118 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
116 | 119 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
117 | 120 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
118 | 121 | </valuemap> |
|
119 | 122 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
120 | 123 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
121 | 124 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
122 | 125 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
123 | 126 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
124 | 127 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
125 | 128 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
126 | 129 | </valuemap> |
|
127 | 130 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
128 | 131 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
129 | 132 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
130 | 133 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
131 | 134 | </valuemap> |
|
132 | 135 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
133 | 136 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
134 | 137 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
135 | 138 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
136 | 139 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
137 | 140 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
138 | 141 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
139 | 142 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
140 | 143 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
141 | 144 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
142 | 145 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
143 | 146 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
144 | 147 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
145 | 148 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
146 | 149 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
147 | 150 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
148 | 151 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
149 | 152 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
150 | 153 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
151 | 154 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
152 | 155 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
153 | 156 | <value type="int">0</value> |
|
154 | 157 | <value type="int">1</value> |
|
155 | 158 | <value type="int">2</value> |
|
156 | 159 | <value type="int">3</value> |
|
157 | 160 | <value type="int">4</value> |
|
158 | 161 | <value type="int">5</value> |
|
159 | 162 | <value type="int">6</value> |
|
160 | 163 | <value type="int">7</value> |
|
161 | 164 | <value type="int">8</value> |
|
162 | 165 | <value type="int">9</value> |
|
163 | 166 | <value type="int">10</value> |
|
164 | 167 | <value type="int">11</value> |
|
165 | 168 | <value type="int">12</value> |
|
166 | 169 | <value type="int">13</value> |
|
167 | 170 | <value type="int">14</value> |
|
168 | 171 | </valuelist> |
|
169 | 172 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
170 | 173 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
171 | 174 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
172 | 175 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
173 | 176 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
174 | 177 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
175 | 178 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
176 | 179 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
177 | 180 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
178 | 181 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
179 | 182 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
180 | 183 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
181 | 184 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
182 | 185 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
183 | 186 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
184 | 187 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
185 | 188 | </valuemap> |
|
186 | 189 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
187 | 190 | </valuemap> |
|
188 | 191 | </data> |
|
189 | 192 | <data> |
|
190 | 193 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
191 | 194 | <value type="int">1</value> |
|
192 | 195 | </data> |
|
193 | 196 | <data> |
|
194 | 197 | <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> |
|
195 | 198 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> |
|
196 | 199 | </data> |
|
197 | 200 | <data> |
|
198 | 201 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
|
199 | 202 | <value type="int">15</value> |
|
200 | 203 | </data> |
|
201 | 204 | </qtcreator> |
@@ -1,48 +1,49 | |||
|
1 | 1 | #ifndef FSW_INIT_H_INCLUDED |
|
2 | 2 | #define FSW_INIT_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "fsw_misc.h" |
|
9 | 9 | #include "fsw_processing.h" |
|
10 | 10 | |
|
11 | 11 | #include "tc_handler.h" |
|
12 | 12 | #include "wf_handler.h" |
|
13 | 13 | #include "fsw_spacewire.h" |
|
14 | 14 | |
|
15 | 15 | #include "avf0_prc0.h" |
|
16 | 16 | #include "avf1_prc1.h" |
|
17 | 17 | #include "avf2_prc2.h" |
|
18 | #include "fsw_spool.h" | |
|
18 | 19 | |
|
19 |
extern rtems_name Task_name[ |
|
|
20 |
extern rtems_id Task_id[ |
|
|
20 | extern rtems_name Task_name[]; /* array of task names */ | |
|
21 | extern rtems_id Task_id[]; /* array of task ids */ | |
|
21 | 22 | |
|
22 | 23 | // RTEMS TASKS |
|
23 | 24 | rtems_task Init( rtems_task_argument argument); |
|
24 | 25 | |
|
25 | 26 | // OTHER functions |
|
26 | 27 | void create_names( void ); |
|
27 | 28 | int create_all_tasks( void ); |
|
28 | 29 | int start_all_tasks( void ); |
|
29 | 30 | // |
|
30 | 31 | rtems_status_code create_message_queues( void ); |
|
31 | 32 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
32 | 33 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
33 | 34 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); |
|
34 | 35 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
35 | 36 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
36 | 37 | // |
|
37 | 38 | int start_recv_send_tasks( void ); |
|
38 | 39 | // |
|
39 | 40 | void init_local_mode_parameters( void ); |
|
40 | 41 | void reset_local_time( void ); |
|
41 | 42 | |
|
42 | 43 | extern int rtems_cpu_usage_report( void ); |
|
43 | 44 | extern int rtems_cpu_usage_reset( void ); |
|
44 | 45 | extern void rtems_stack_checker_report_usage( void ); |
|
45 | 46 | |
|
46 | 47 | extern int sched_yield( void ); |
|
47 | 48 | |
|
48 | 49 | #endif // FSW_INIT_H_INCLUDED |
@@ -1,255 +1,271 | |||
|
1 | 1 | #ifndef FSW_PARAMS_H_INCLUDED |
|
2 | 2 | #define FSW_PARAMS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include "grlib_regs.h" |
|
5 | 5 | #include "fsw_params_processing.h" |
|
6 | 6 | #include "fsw_params_nb_bytes.h" |
|
7 | 7 | #include "tm_byte_positions.h" |
|
8 | 8 | #include "ccsds_types.h" |
|
9 | 9 | |
|
10 | 10 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
11 | 11 | #define UART_DEVICE_NAME "/dev/console" |
|
12 | 12 | |
|
13 | 13 | typedef struct ring_node |
|
14 | 14 | { |
|
15 | 15 | struct ring_node *previous; |
|
16 | 16 | int buffer_address; |
|
17 | 17 | struct ring_node *next; |
|
18 | 18 | unsigned int status; |
|
19 | 19 | } ring_node; |
|
20 | 20 | |
|
21 | 21 | //************************ |
|
22 | 22 | // flight software version |
|
23 | 23 | // this parameters is handled by the Qt project options |
|
24 | 24 | |
|
25 | 25 | #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk |
|
26 | 26 | #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk |
|
27 | 27 | #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 |
|
28 | 28 | #define TIME_OFFSET 2 |
|
29 | 29 | #define TIME_OFFSET_IN_BYTES 8 |
|
30 | 30 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
31 | 31 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
32 | 32 | #define NB_WORDS_SWF_BLK 3 |
|
33 | 33 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
34 | 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 | 35 | #define NB_RING_NODES_F0 3 // AT LEAST 3 |
|
36 | 36 | #define NB_RING_NODES_F1 5 // AT LEAST 3 |
|
37 | 37 | #define NB_RING_NODES_F2 5 // AT LEAST 3 |
|
38 | 38 | #define NB_RING_NODES_F3 3 // AT LEAST 3 |
|
39 | 39 | |
|
40 | 40 | //********** |
|
41 | 41 | // LFR MODES |
|
42 | 42 | #define LFR_MODE_STANDBY 0 |
|
43 | 43 | #define LFR_MODE_NORMAL 1 |
|
44 | 44 | #define LFR_MODE_BURST 2 |
|
45 | 45 | #define LFR_MODE_SBM1 3 |
|
46 | 46 | #define LFR_MODE_SBM2 4 |
|
47 | 47 | |
|
48 | 48 | #define TDS_MODE_LFM 5 |
|
49 | 49 | #define TDS_MODE_STANDBY 0 |
|
50 | 50 | #define TDS_MODE_NORMAL 1 |
|
51 | 51 | #define TDS_MODE_BURST 2 |
|
52 | 52 | #define TDS_MODE_SBM1 3 |
|
53 | 53 | #define TDS_MODE_SBM2 4 |
|
54 | 54 | |
|
55 | 55 | #define THR_MODE_STANDBY 0 |
|
56 | 56 | #define THR_MODE_NORMAL 1 |
|
57 | 57 | #define THR_MODE_BURST 2 |
|
58 | 58 | |
|
59 | 59 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
60 | 60 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
61 | 61 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
62 | 62 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
63 | 63 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
64 | 64 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
65 | 65 | #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6 |
|
66 | 66 | #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7 |
|
67 | 67 | #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode |
|
68 | 68 | #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9 |
|
69 | 69 | #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10 |
|
70 | 70 | #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode |
|
71 | 71 | #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12 |
|
72 | 72 | #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13 |
|
73 | 73 | #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode |
|
74 | 74 | #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15 |
|
75 | 75 | #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16 |
|
76 | 76 | #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17 |
|
77 | 77 | #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18 |
|
78 | 78 | #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19 |
|
79 | 79 | #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20 |
|
80 | 80 | #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21 |
|
81 | 81 | #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22 |
|
82 | 82 | |
|
83 | 83 | //**************************** |
|
84 | 84 | // LFR DEFAULT MODE PARAMETERS |
|
85 | 85 | // COMMON |
|
86 | 86 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
87 | 87 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
88 | 88 | // NORM |
|
89 | 89 | #define SY_LFR_N_SWF_L 2048 // nb sample |
|
90 | 90 | #define SY_LFR_N_SWF_P 300 // sec |
|
91 | 91 | #define SY_LFR_N_ASM_P 3600 // sec |
|
92 | 92 | #define SY_LFR_N_BP_P0 4 // sec |
|
93 | 93 | #define SY_LFR_N_BP_P1 20 // sec |
|
94 | 94 | #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 |
|
95 | 95 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
96 | 96 | // BURST |
|
97 | 97 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
98 | 98 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
99 | 99 | // SBM1 |
|
100 | 100 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
101 | 101 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
102 | 102 | // SBM2 |
|
103 | 103 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
104 | 104 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
105 | 105 | // ADDITIONAL PARAMETERS |
|
106 | 106 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
107 | 107 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
108 | 108 | // STATUS WORD |
|
109 | 109 | #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits |
|
110 | 110 | #define DEFAULT_STATUS_WORD_BYTE1 0x00 |
|
111 | 111 | // |
|
112 | 112 | #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s |
|
113 | 113 | #define SY_LFR_DPU_CONNECT_ATTEMPT 3 |
|
114 | 114 | //**************************** |
|
115 | 115 | |
|
116 | 116 | //***************************** |
|
117 | 117 | // APB REGISTERS BASE ADDRESSES |
|
118 | 118 | #define REGS_ADDR_APBUART 0x80000100 |
|
119 | 119 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
120 | 120 | #define REGS_ADDR_GRSPW 0x80000500 |
|
121 | 121 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
122 | 122 | #define REGS_ADDR_GRGPIO 0x80000b00 |
|
123 | 123 | |
|
124 | 124 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
125 | 125 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50 |
|
126 | 126 | #define REGS_ADDR_VHDL_VERSION 0x80000ff0 |
|
127 | 127 | |
|
128 | 128 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
129 | 129 | #define APBUART_CTRL_REG_MASK_TE 0x00000002 |
|
130 | 130 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
131 | 131 | |
|
132 | 132 | //********** |
|
133 | 133 | // IRQ LINES |
|
134 | 134 | #define IRQ_SM_SIMULATOR 9 |
|
135 | 135 | #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
136 | 136 | #define IRQ_WAVEFORM_PICKER 14 |
|
137 | 137 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
138 | 138 | #define IRQ_SPECTRAL_MATRIX 6 |
|
139 | 139 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
140 | 140 | |
|
141 | 141 | //***** |
|
142 | 142 | // TIME |
|
143 | #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416 | |
|
144 | #define TIMER_SM_SIMULATOR 1 | |
|
145 | #define HK_PERIOD 100 // 100 * 10ms => 1s | |
|
146 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000 | |
|
147 |
#define SY_LFR_TIME_SYN_TIMEOUT_in_ |
|
|
143 | #ifdef FAST_SCHEDULER | |
|
144 | #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416 | |
|
145 | #define TIMER_SM_SIMULATOR 1 | |
|
146 | #define HK_PERIOD 1000 // 1000 * 1ms = 1s | |
|
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 | 164 | // LPP CODES |
|
151 | 165 | #define LFR_SUCCESSFUL 0 |
|
152 | 166 | #define LFR_DEFAULT 1 |
|
153 | 167 | #define LFR_EXE_ERROR 2 |
|
154 | 168 | |
|
155 | 169 | //****** |
|
156 | 170 | // RTEMS |
|
157 | 171 | #define TASKID_RECV 1 |
|
158 | 172 | #define TASKID_ACTN 2 |
|
159 | 173 | #define TASKID_SPIQ 3 |
|
160 | 174 | #define TASKID_STAT 4 |
|
161 | 175 | #define TASKID_AVF0 5 |
|
162 | 176 | #define TASKID_SWBD 6 |
|
163 | 177 | #define TASKID_WFRM 7 |
|
164 | 178 | #define TASKID_DUMB 8 |
|
165 | 179 | #define TASKID_HOUS 9 |
|
166 | 180 | #define TASKID_PRC0 10 |
|
167 | 181 | #define TASKID_CWF3 11 |
|
168 | 182 | #define TASKID_CWF2 12 |
|
169 | 183 | #define TASKID_CWF1 13 |
|
170 | 184 | #define TASKID_SEND 14 |
|
171 | 185 | #define TASKID_WTDG 15 |
|
172 | 186 | #define TASKID_AVF1 16 |
|
173 | 187 | #define TASKID_PRC1 17 |
|
174 | 188 | #define TASKID_AVF2 18 |
|
175 | 189 | #define TASKID_PRC2 19 |
|
190 | #define TASKID_SPOO 20 | |
|
176 | 191 | |
|
177 | 192 | #define TASK_PRIORITY_SPIQ 5 |
|
178 | 193 | #define TASK_PRIORITY_WTDG 20 |
|
179 | 194 | #define TASK_PRIORITY_HOUS 30 |
|
180 | 195 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together |
|
181 | 196 | #define TASK_PRIORITY_CWF2 35 // |
|
182 | 197 | #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it |
|
183 | 198 | #define TASK_PRIORITY_WFRM 40 |
|
184 | 199 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 |
|
185 | 200 | #define TASK_PRIORITY_SEND 45 |
|
186 | 201 | #define TASK_PRIORITY_RECV 50 |
|
187 | 202 | #define TASK_PRIORITY_ACTN 50 |
|
188 | 203 | #define TASK_PRIORITY_AVF0 60 |
|
189 | 204 | #define TASK_PRIORITY_AVF1 70 |
|
190 | 205 | #define TASK_PRIORITY_PRC0 100 |
|
191 | 206 | #define TASK_PRIORITY_PRC1 100 |
|
192 | 207 | #define TASK_PRIORITY_AVF2 110 |
|
193 | 208 | #define TASK_PRIORITY_PRC2 110 |
|
209 | #define TASK_PRIORITY_SPOO 150 | |
|
194 | 210 | #define TASK_PRIORITY_STAT 200 |
|
195 | 211 | #define TASK_PRIORITY_DUMB 200 |
|
196 | 212 | |
|
197 | 213 | #define MSG_QUEUE_COUNT_RECV 10 |
|
198 | 214 | #define MSG_QUEUE_COUNT_SEND 50 |
|
199 | 215 | #define MSG_QUEUE_COUNT_PRC0 10 |
|
200 | 216 | #define MSG_QUEUE_COUNT_PRC1 10 |
|
201 | 217 | #define MSG_QUEUE_COUNT_PRC2 5 |
|
202 | 218 | #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1 |
|
203 | 219 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
204 | 220 | #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers |
|
205 | 221 | #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers |
|
206 | 222 | #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers |
|
207 | 223 | |
|
208 | 224 | #define QUEUE_RECV 0 |
|
209 | 225 | #define QUEUE_SEND 1 |
|
210 | 226 | #define QUEUE_PRC0 2 |
|
211 | 227 | #define QUEUE_PRC1 3 |
|
212 | 228 | #define QUEUE_PRC2 4 |
|
213 | 229 | |
|
214 | 230 | //******* |
|
215 | 231 | // MACROS |
|
216 | 232 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
217 | 233 | #define PRINTF(x) printf(x); |
|
218 | 234 | #define PRINTF1(x,y) printf(x,y); |
|
219 | 235 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
220 | 236 | #else |
|
221 | 237 | #define PRINTF(x) ; |
|
222 | 238 | #define PRINTF1(x,y) ; |
|
223 | 239 | #define PRINTF2(x,y,z) ; |
|
224 | 240 | #endif |
|
225 | 241 | |
|
226 | 242 | #ifdef BOOT_MESSAGES |
|
227 | 243 | #define BOOT_PRINTF(x) printf(x); |
|
228 | 244 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
229 | 245 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
230 | 246 | #else |
|
231 | 247 | #define BOOT_PRINTF(x) ; |
|
232 | 248 | #define BOOT_PRINTF1(x,y) ; |
|
233 | 249 | #define BOOT_PRINTF2(x,y,z) ; |
|
234 | 250 | #endif |
|
235 | 251 | |
|
236 | 252 | #ifdef DEBUG_MESSAGES |
|
237 | 253 | #define DEBUG_PRINTF(x) printf(x); |
|
238 | 254 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
239 | 255 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
240 | 256 | #else |
|
241 | 257 | #define DEBUG_PRINTF(x) ; |
|
242 | 258 | #define DEBUG_PRINTF1(x,y) ; |
|
243 | 259 | #define DEBUG_PRINTF2(x,y,z) ; |
|
244 | 260 | #endif |
|
245 | 261 | |
|
246 | 262 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
247 | 263 | |
|
248 | 264 | struct param_local_str{ |
|
249 | 265 | unsigned int local_sbm1_nb_cwf_sent; |
|
250 | 266 | unsigned int local_sbm1_nb_cwf_max; |
|
251 | 267 | unsigned int local_sbm2_nb_cwf_sent; |
|
252 | 268 | unsigned int local_sbm2_nb_cwf_max; |
|
253 | 269 | }; |
|
254 | 270 | |
|
255 | 271 | #endif // FSW_PARAMS_H_INCLUDED |
@@ -1,243 +1,247 | |||
|
1 | 1 | #ifndef FSW_PROCESSING_H_INCLUDED |
|
2 | 2 | #define FSW_PROCESSING_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <grspw.h> |
|
6 | 6 | #include <math.h> |
|
7 | 7 | #include <stdlib.h> // abs() is in the stdlib |
|
8 | 8 | #include <stdio.h> // printf() |
|
9 | 9 | #include <math.h> |
|
10 | 10 | |
|
11 | 11 | #include "fsw_params.h" |
|
12 | 12 | #include "fsw_spacewire.h" |
|
13 | 13 | |
|
14 | 14 | typedef struct ring_node_sm |
|
15 | 15 | { |
|
16 | 16 | struct ring_node_sm *previous; |
|
17 | 17 | struct ring_node_sm *next; |
|
18 | 18 | int buffer_address; |
|
19 | 19 | unsigned int status; |
|
20 | 20 | unsigned int coarseTime; |
|
21 | 21 | unsigned int fineTime; |
|
22 | 22 | } ring_node_sm; |
|
23 | 23 | |
|
24 | 24 | typedef struct ring_node_asm |
|
25 | 25 | { |
|
26 | 26 | struct ring_node_asm *next; |
|
27 | 27 | float matrix[ TOTAL_SIZE_SM ]; |
|
28 | 28 | unsigned int status; |
|
29 | 29 | } ring_node_asm; |
|
30 | 30 | |
|
31 | 31 | typedef struct |
|
32 | 32 | { |
|
33 | 33 | Header_TM_LFR_SCIENCE_BP_t header; |
|
34 | 34 | unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
35 | 35 | } bp_packet; |
|
36 | 36 | |
|
37 | 37 | typedef struct |
|
38 | 38 | { |
|
39 | 39 | Header_TM_LFR_SCIENCE_BP_with_spare_t header; |
|
40 | 40 | unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
41 | 41 | } bp_packet_with_spare; |
|
42 | 42 | |
|
43 | 43 | typedef struct |
|
44 | 44 | { |
|
45 | 45 | ring_node_asm *norm; |
|
46 | 46 | ring_node_asm *burst_sbm; |
|
47 | 47 | rtems_event_set event; |
|
48 | 48 | unsigned int coarseTime; |
|
49 | 49 | unsigned int fineTime; |
|
50 | 50 | } asm_msg; |
|
51 | 51 | |
|
52 | 52 | extern volatile int sm_f0[ ]; |
|
53 | 53 | extern volatile int sm_f1[ ]; |
|
54 | 54 | extern volatile int sm_f2[ ]; |
|
55 | 55 | |
|
56 | 56 | // parameters |
|
57 | 57 | extern struct param_local_str param_local; |
|
58 | 58 | |
|
59 | 59 | // registers |
|
60 | 60 | extern time_management_regs_t *time_management_regs; |
|
61 | 61 | extern spectral_matrix_regs_t *spectral_matrix_regs; |
|
62 | 62 | |
|
63 |
extern rtems_name misc_name[ |
|
|
64 |
extern rtems_id Task_id[ |
|
|
63 | extern rtems_name misc_name[]; | |
|
64 | extern rtems_id Task_id[]; /* array of task ids */ | |
|
65 | 65 | |
|
66 | 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 | 71 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
68 | 72 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); |
|
69 | 73 | |
|
70 | 74 | //****************** |
|
71 | 75 | // Spectral Matrices |
|
72 | 76 | void reset_nb_sm( void ); |
|
73 | 77 | // SM |
|
74 | 78 | void SM_init_rings( void ); |
|
75 | 79 | void SM_reset_current_ring_nodes( void ); |
|
76 | 80 | void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ); |
|
77 | 81 | // ASM |
|
78 | 82 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); |
|
79 | 83 | void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header); |
|
80 | 84 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
81 | 85 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); |
|
82 | 86 | |
|
83 | 87 | //***************** |
|
84 | 88 | // Basic Parameters |
|
85 | 89 | |
|
86 | 90 | void BP_reset_current_ring_nodes( void ); |
|
87 | 91 | void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, |
|
88 | 92 | unsigned int apid, unsigned char sid, |
|
89 | 93 | unsigned int packetLength , unsigned char blkNr); |
|
90 | 94 | void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header, |
|
91 | 95 | unsigned int apid, unsigned char sid, |
|
92 | 96 | unsigned int packetLength, unsigned char blkNr ); |
|
93 | 97 | void BP_send( char *data, |
|
94 | 98 | rtems_id queue_id , |
|
95 | 99 | unsigned int nbBytesToSend , unsigned int sid ); |
|
96 | 100 | |
|
97 | 101 | //****************** |
|
98 | 102 | // general functions |
|
99 | 103 | void reset_spectral_matrix_regs( void ); |
|
100 | 104 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
101 | 105 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); |
|
102 | 106 | void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, |
|
103 | 107 | ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time); |
|
104 | 108 | unsigned char getSID( rtems_event_set event ); |
|
105 | 109 | |
|
106 | 110 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
107 | 111 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
108 | 112 | |
|
109 | 113 | //*************************************** |
|
110 | 114 | // DEFINITIONS OF STATIC INLINE FUNCTIONS |
|
111 | 115 | static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
112 | 116 | ring_node_sm *ring_node_tab[], |
|
113 | 117 | unsigned int nbAverageNORM, unsigned int nbAverageSBM ); |
|
114 | 118 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
115 | 119 | float divider ); |
|
116 | 120 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
117 | 121 | float divider, |
|
118 | 122 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
119 | 123 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
120 | 124 | |
|
121 | 125 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
122 | 126 | ring_node_sm *ring_node_tab[], |
|
123 | 127 | unsigned int nbAverageNORM, unsigned int nbAverageSBM ) |
|
124 | 128 | { |
|
125 | 129 | float sum; |
|
126 | 130 | unsigned int i; |
|
127 | 131 | |
|
128 | 132 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
129 | 133 | { |
|
130 | 134 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] |
|
131 | 135 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] |
|
132 | 136 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] |
|
133 | 137 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] |
|
134 | 138 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] |
|
135 | 139 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] |
|
136 | 140 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] |
|
137 | 141 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; |
|
138 | 142 | |
|
139 | 143 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
140 | 144 | { |
|
141 | 145 | averaged_spec_mat_NORM[ i ] = sum; |
|
142 | 146 | averaged_spec_mat_SBM[ i ] = sum; |
|
143 | 147 | } |
|
144 | 148 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
145 | 149 | { |
|
146 | 150 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
147 | 151 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
148 | 152 | } |
|
149 | 153 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
150 | 154 | { |
|
151 | 155 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
152 | 156 | averaged_spec_mat_SBM[ i ] = sum; |
|
153 | 157 | } |
|
154 | 158 | else |
|
155 | 159 | { |
|
156 | 160 | PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) |
|
157 | 161 | } |
|
158 | 162 | } |
|
159 | 163 | } |
|
160 | 164 | |
|
161 | 165 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
162 | 166 | { |
|
163 | 167 | int frequencyBin; |
|
164 | 168 | int asmComponent; |
|
165 | 169 | unsigned int offsetAveragedSpecMatReorganized; |
|
166 | 170 | unsigned int offsetAveragedSpecMat; |
|
167 | 171 | |
|
168 | 172 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
169 | 173 | { |
|
170 | 174 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
171 | 175 | { |
|
172 | 176 | offsetAveragedSpecMatReorganized = |
|
173 | 177 | frequencyBin * NB_VALUES_PER_SM |
|
174 | 178 | + asmComponent; |
|
175 | 179 | offsetAveragedSpecMat = |
|
176 | 180 | asmComponent * NB_BINS_PER_SM |
|
177 | 181 | + frequencyBin; |
|
178 | 182 | averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] = |
|
179 | 183 | averaged_spec_mat[ offsetAveragedSpecMat ] / divider; |
|
180 | 184 | } |
|
181 | 185 | } |
|
182 | 186 | } |
|
183 | 187 | |
|
184 | 188 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
185 | 189 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
186 | 190 | { |
|
187 | 191 | int frequencyBin; |
|
188 | 192 | int asmComponent; |
|
189 | 193 | int offsetASM; |
|
190 | 194 | int offsetCompressed; |
|
191 | 195 | int k; |
|
192 | 196 | |
|
193 | 197 | // build data |
|
194 | 198 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
195 | 199 | { |
|
196 | 200 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
197 | 201 | { |
|
198 | 202 | offsetCompressed = // NO TIME OFFSET |
|
199 | 203 | frequencyBin * NB_VALUES_PER_SM |
|
200 | 204 | + asmComponent; |
|
201 | 205 | offsetASM = // NO TIME OFFSET |
|
202 | 206 | asmComponent * NB_BINS_PER_SM |
|
203 | 207 | + ASMIndexStart |
|
204 | 208 | + frequencyBin * nbBinsToAverage; |
|
205 | 209 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
206 | 210 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
207 | 211 | { |
|
208 | 212 | compressed_spec_mat[offsetCompressed ] = |
|
209 | 213 | ( compressed_spec_mat[ offsetCompressed ] |
|
210 | 214 | + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage); |
|
211 | 215 | } |
|
212 | 216 | } |
|
213 | 217 | } |
|
214 | 218 | } |
|
215 | 219 | |
|
216 | 220 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
217 | 221 | { |
|
218 | 222 | unsigned int frequencyBin; |
|
219 | 223 | unsigned int asmComponent; |
|
220 | 224 | char * pt_char_input; |
|
221 | 225 | char * pt_char_output; |
|
222 | 226 | unsigned int offsetInput; |
|
223 | 227 | unsigned int offsetOutput; |
|
224 | 228 | |
|
225 | 229 | pt_char_input = (char*) &input_matrix; |
|
226 | 230 | pt_char_output = (char*) &output_matrix; |
|
227 | 231 | |
|
228 | 232 | // convert all other data |
|
229 | 233 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
230 | 234 | { |
|
231 | 235 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
232 | 236 | { |
|
233 | 237 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; |
|
234 | 238 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; |
|
235 | 239 | pt_char_input = (char*) &input_matrix [ offsetInput ]; |
|
236 | 240 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; |
|
237 | 241 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
238 | 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 | 247 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -1,62 +1,64 | |||
|
1 | 1 | #ifndef TC_HANDLER_H_INCLUDED |
|
2 | 2 | #define TC_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "tc_load_dump_parameters.h" |
|
8 | 8 | #include "tc_acceptance.h" |
|
9 | 9 | #include "tm_lfr_tc_exe.h" |
|
10 | 10 | #include "wf_handler.h" |
|
11 | 11 | #include "fsw_processing.h" |
|
12 | 12 | |
|
13 | 13 | #include "lfr_cpu_usage_report.h" |
|
14 | 14 | |
|
15 | 15 | // MODE PARAMETERS |
|
16 | 16 | extern unsigned int maxCount; |
|
17 | 17 | |
|
18 | 18 | //**** |
|
19 | 19 | // ISR |
|
20 | 20 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
21 | 21 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
22 | 22 | |
|
23 | 23 | //*********** |
|
24 | 24 | // RTEMS TASK |
|
25 | 25 | rtems_task actn_task( rtems_task_argument unused ); |
|
26 | 26 | |
|
27 | 27 | //*********** |
|
28 | 28 | // TC ACTIONS |
|
29 | 29 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
30 | 30 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
31 | 31 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
32 | 32 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
33 | 33 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
34 | 34 | int action_update_time( ccsdsTelecommandPacket_t *TC); |
|
35 | 35 | |
|
36 | 36 | // mode transition |
|
37 | 37 | int check_mode_value( unsigned char requestedMode ); |
|
38 | 38 | int check_mode_transition( unsigned char requestedMode ); |
|
39 | 39 | int check_transition_date( unsigned int transitionCoarseTime ); |
|
40 | 40 | int stop_current_mode( void ); |
|
41 | 41 | int enter_mode( unsigned char mode , unsigned int transitionCoarseTime ); |
|
42 | 42 | int restart_science_tasks(unsigned char lfrRequestedMode ); |
|
43 | 43 | int suspend_science_tasks(); |
|
44 | 44 | void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime); |
|
45 | void launch_waveform_picker_spool(unsigned char mode , unsigned int transitionCoarseTime); | |
|
45 | 46 | void launch_spectral_matrix( void ); |
|
47 | void launch_spectral_matrix_spool( void ); | |
|
46 | 48 | void launch_spectral_matrix_simu( void ); |
|
47 | 49 | void set_irq_on_new_ready_matrix(unsigned char value ); |
|
48 | 50 | void set_run_matrix_spectral( unsigned char value ); |
|
49 | 51 | |
|
50 | 52 | // other functions |
|
51 | 53 | void updateLFRCurrentMode(); |
|
52 | 54 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
53 | 55 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
54 | 56 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); |
|
55 | 57 | |
|
56 | 58 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
57 | 59 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
58 | 60 | |
|
59 | 61 | #endif // TC_HANDLER_H_INCLUDED |
|
60 | 62 | |
|
61 | 63 | |
|
62 | 64 |
@@ -1,92 +1,93 | |||
|
1 | 1 | #ifndef WF_HANDLER_H_INCLUDED |
|
2 | 2 | #define WF_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <grspw.h> |
|
6 | 6 | #include <stdio.h> |
|
7 | 7 | #include <math.h> |
|
8 | 8 | |
|
9 | 9 | #include "fsw_params.h" |
|
10 | 10 | #include "fsw_spacewire.h" |
|
11 | 11 | #include "fsw_misc.h" |
|
12 | 12 | #include "fsw_params_wf_handler.h" |
|
13 | 13 | |
|
14 | 14 | #define pi 3.1415 |
|
15 | 15 | |
|
16 | 16 | extern int fdSPW; |
|
17 | 17 | |
|
18 | 18 | //***************** |
|
19 | 19 | // waveform buffers |
|
20 | 20 | extern volatile int wf_snap_f0[ ]; |
|
21 | 21 | extern volatile int wf_snap_f1[ ]; |
|
22 | 22 | extern volatile int wf_snap_f2[ ]; |
|
23 | 23 | extern volatile int wf_cont_f3[ ]; |
|
24 | 24 | extern char wf_cont_f3_light[ ]; |
|
25 | 25 | |
|
26 | 26 | extern waveform_picker_regs_new_t *waveform_picker_regs; |
|
27 | 27 | extern time_management_regs_t *time_management_regs; |
|
28 | 28 | extern Packet_TM_LFR_HK_t housekeeping_packet; |
|
29 | 29 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
30 | 30 | extern struct param_local_str param_local; |
|
31 | 31 | |
|
32 | 32 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
33 | 33 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
34 | 34 | |
|
35 |
extern rtems_id Task_id[ |
|
|
35 | extern rtems_id Task_id[]; /* array of task ids */ | |
|
36 | 36 | |
|
37 | 37 | extern unsigned char lfrCurrentMode; |
|
38 | 38 | |
|
39 | 39 | //********** |
|
40 | 40 | // RTEMS_ISR |
|
41 | 41 | void reset_extractSWF( void ); |
|
42 | 42 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
43 | rtems_isr waveforms_isr_alt( rtems_vector_number vector ); | |
|
43 | 44 | |
|
44 | 45 | //*********** |
|
45 | 46 | // RTEMS_TASK |
|
46 | 47 | rtems_task wfrm_task( rtems_task_argument argument ); |
|
47 | 48 | rtems_task cwf3_task( rtems_task_argument argument ); |
|
48 | 49 | rtems_task cwf2_task( rtems_task_argument argument ); |
|
49 | 50 | rtems_task cwf1_task( rtems_task_argument argument ); |
|
50 | 51 | rtems_task swbd_task( rtems_task_argument argument ); |
|
51 | 52 | |
|
52 | 53 | //****************** |
|
53 | 54 | // general functions |
|
54 | 55 | void WFP_init_rings( void ); |
|
55 | 56 | void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] ); |
|
56 | 57 | void WFP_reset_current_ring_nodes( void ); |
|
57 | 58 | // |
|
58 | 59 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); |
|
59 | 60 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
60 | 61 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
61 | 62 | // |
|
62 | 63 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ); |
|
63 | 64 | int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
64 | 65 | int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
65 | 66 | int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
66 | 67 | // |
|
67 | 68 | void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, |
|
68 | 69 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); |
|
69 | 70 | void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel ); |
|
70 | 71 | void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node ); |
|
71 | 72 | // |
|
72 | 73 | rtems_id get_pkts_queue_id( void ); |
|
73 | 74 | |
|
74 | 75 | //************** |
|
75 | 76 | // wfp registers |
|
76 | 77 | // RESET |
|
77 | 78 | void reset_wfp_burst_enable( void ); |
|
78 | 79 | void reset_wfp_status(void); |
|
79 | 80 | void reset_waveform_picker_regs( void ); |
|
80 | 81 | // SET |
|
81 | 82 | void set_wfp_data_shaping(void); |
|
82 | 83 | void set_wfp_burst_enable_register( unsigned char mode ); |
|
83 | 84 | void set_wfp_delta_snapshot( void ); |
|
84 | 85 | void set_wfp_delta_f0_f0_2( void ); |
|
85 | 86 | void set_wfp_delta_f1( void ); |
|
86 | 87 | void set_wfp_delta_f2( void ); |
|
87 | 88 | |
|
88 | 89 | //***************** |
|
89 | 90 | // local parameters |
|
90 | 91 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); |
|
91 | 92 | |
|
92 | 93 | #endif // WF_HANDLER_H_INCLUDED |
@@ -1,75 +1,75 | |||
|
1 | 1 | /** Global variables of the LFR flight software. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * Among global variables, there are: |
|
7 | 7 | * - RTEMS names and id. |
|
8 | 8 | * - APB configuration registers. |
|
9 | 9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. |
|
10 | 10 | * - spectral matrices buffesr, used by the hardware module to store data. |
|
11 | 11 | * - variable related to LFR modes parameters. |
|
12 | 12 | * - the global HK packet buffer. |
|
13 | 13 | * - the global dump parameter buffer. |
|
14 | 14 | * |
|
15 | 15 | */ |
|
16 | 16 | |
|
17 | 17 | #include <rtems.h> |
|
18 | 18 | #include <grspw.h> |
|
19 | 19 | |
|
20 | 20 | #include "ccsds_types.h" |
|
21 | 21 | #include "grlib_regs.h" |
|
22 | 22 | #include "fsw_params.h" |
|
23 | 23 | #include "fsw_params_wf_handler.h" |
|
24 | 24 | |
|
25 | 25 | // RTEMS GLOBAL VARIABLES |
|
26 | 26 | rtems_name misc_name[5]; |
|
27 | 27 | rtems_id misc_id[5]; |
|
28 |
rtems_name Task_name[2 |
|
|
29 |
rtems_id Task_id[2 |
|
|
28 | rtems_name Task_name[21]; /* array of task names */ | |
|
29 | rtems_id Task_id[21]; /* array of task ids */ | |
|
30 | 30 | unsigned int maxCount; |
|
31 | 31 | int fdSPW = 0; |
|
32 | 32 | int fdUART = 0; |
|
33 | 33 | unsigned char lfrCurrentMode; |
|
34 | 34 | |
|
35 | 35 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 |
|
36 | 36 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words |
|
37 | 37 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 |
|
38 | 38 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words |
|
39 | 39 | // F0 F1 F2 F3 |
|
40 | 40 | volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
41 | 41 | volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
42 | 42 | volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
43 | 43 | volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
44 | 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 | 47 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
48 | 48 | |
|
49 | 49 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 |
|
50 | 50 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
51 | 51 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
52 | 52 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
53 | 53 | |
|
54 | 54 | // APB CONFIGURATION REGISTERS |
|
55 | 55 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
56 | 56 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
57 | 57 | waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
58 | 58 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
59 | 59 | |
|
60 | 60 | // MODE PARAMETERS |
|
61 | 61 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
62 | 62 | struct param_local_str param_local; |
|
63 | 63 | |
|
64 | 64 | // HK PACKETS |
|
65 | 65 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
66 | 66 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
67 | 67 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
68 | 68 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
69 | 69 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; |
|
70 | 70 | unsigned short sequenceCounterHK; |
|
71 | 71 | unsigned short sequenceCounterParameterDump; |
|
72 | 72 | spw_stats spacewire_stats; |
|
73 | 73 | spw_stats spacewire_stats_backup; |
|
74 | 74 | |
|
75 | 75 |
@@ -1,780 +1,800 | |||
|
1 | 1 | /** This is the RTEMS initialization module. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * This module contains two very different information: |
|
7 | 7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
8 | 8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
9 | 9 | * |
|
10 | 10 | */ |
|
11 | 11 | |
|
12 | 12 | //************************* |
|
13 | 13 | // GPL reminder to be added |
|
14 | 14 | //************************* |
|
15 | 15 | |
|
16 | 16 | #include <rtems.h> |
|
17 | 17 | |
|
18 | 18 | /* configuration information */ |
|
19 | 19 | |
|
20 | 20 | #define CONFIGURE_INIT |
|
21 | 21 | |
|
22 | 22 | #include <bsp.h> /* for device driver prototypes */ |
|
23 | 23 | |
|
24 | 24 | /* configuration information */ |
|
25 | 25 | |
|
26 | 26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
27 | 27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
28 | 28 | |
|
29 |
#define CONFIGURE_MAXIMUM_TASKS 2 |
|
|
29 | #define CONFIGURE_MAXIMUM_TASKS 21 | |
|
30 | 30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
31 | 31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
32 | 32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
33 | 33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
34 | 34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
35 | 35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
36 | 36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
37 | 37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
38 | 38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
39 | 39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
40 | 40 | #ifdef PRINT_STACK_REPORT |
|
41 | 41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
42 | 42 | #endif |
|
43 | #ifdef FAST_SCHEDULER | |
|
44 | #define CONFIGURE_MICROSECONDS_PER_TICK 1000 /* 1 millisecond */ | |
|
45 | #endif | |
|
43 | 46 | |
|
44 | 47 | #include <rtems/confdefs.h> |
|
45 | 48 | |
|
46 | 49 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
47 | 50 | #ifdef RTEMS_DRVMGR_STARTUP |
|
48 | 51 | #ifdef LEON3 |
|
49 | 52 | /* Add Timer and UART Driver */ |
|
50 | 53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
51 | 54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
52 | 55 | #endif |
|
53 | 56 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
54 | 57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
55 | 58 | #endif |
|
56 | 59 | #endif |
|
57 | 60 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
58 | 61 | #include <drvmgr/drvmgr_confdefs.h> |
|
59 | 62 | #endif |
|
60 | 63 | |
|
61 | 64 | #include "fsw_init.h" |
|
62 | 65 | #include "fsw_config.c" |
|
63 | 66 | |
|
64 | 67 | rtems_task Init( rtems_task_argument ignored ) |
|
65 | 68 | { |
|
66 | 69 | /** This is the RTEMS INIT taks, it the first task launched by the system. |
|
67 | 70 | * |
|
68 | 71 | * @param unused is the starting argument of the RTEMS task |
|
69 | 72 | * |
|
70 | 73 | * The INIT task create and run all other RTEMS tasks. |
|
71 | 74 | * |
|
72 | 75 | */ |
|
73 | 76 | |
|
74 | 77 | unsigned char *vhdlVersion; |
|
75 | 78 | |
|
76 | 79 | reset_local_time(); |
|
77 | 80 | |
|
78 | 81 | rtems_cpu_usage_reset(); |
|
79 | 82 | |
|
80 | 83 | rtems_status_code status; |
|
81 | 84 | rtems_status_code status_spw; |
|
82 | 85 | rtems_isr_entry old_isr_handler; |
|
83 | 86 | |
|
84 | 87 | // UART settings |
|
85 | 88 | send_console_outputs_on_apbuart_port(); |
|
86 | 89 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
87 | 90 | enable_apbuart_transmitter(); |
|
88 | 91 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
89 | 92 | |
|
90 | 93 | PRINTF("\n\n\n\n\n") |
|
91 | 94 | PRINTF("*************************\n") |
|
92 | 95 | PRINTF("** LFR Flight Software **\n") |
|
93 | 96 | PRINTF1("** %d.", SW_VERSION_N1) |
|
94 | 97 | PRINTF1("%d." , SW_VERSION_N2) |
|
95 | 98 | PRINTF1("%d." , SW_VERSION_N3) |
|
96 | 99 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
97 | 100 | |
|
98 | 101 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
99 | 102 | PRINTF("** VHDL **\n") |
|
100 | 103 | PRINTF1("** %d.", vhdlVersion[1]) |
|
101 | 104 | PRINTF1("%d." , vhdlVersion[2]) |
|
102 | 105 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
103 | 106 | PRINTF("*************************\n") |
|
104 | 107 | PRINTF("\n\n") |
|
105 | 108 | |
|
106 | 109 | init_parameter_dump(); |
|
107 | 110 | init_local_mode_parameters(); |
|
108 | 111 | init_housekeeping_parameters(); |
|
109 | 112 | |
|
110 | 113 | // waveform picker initialization |
|
111 | 114 | WFP_init_rings(); // initialize the waveform rings |
|
112 | 115 | WFP_reset_current_ring_nodes(); |
|
113 | 116 | reset_waveform_picker_regs(); |
|
114 | 117 | |
|
115 | 118 | // spectral matrices initialization |
|
116 | 119 | SM_init_rings(); // initialize spectral matrices rings |
|
117 | 120 | SM_reset_current_ring_nodes(); |
|
118 | 121 | reset_spectral_matrix_regs(); |
|
119 | 122 | |
|
120 | 123 | updateLFRCurrentMode(); |
|
121 | 124 | |
|
122 | 125 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
123 | 126 | |
|
124 | 127 | create_names(); // create all names |
|
125 | 128 | |
|
126 | 129 | status = create_message_queues(); // create message queues |
|
127 | 130 | if (status != RTEMS_SUCCESSFUL) |
|
128 | 131 | { |
|
129 | 132 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
130 | 133 | } |
|
131 | 134 | |
|
132 | 135 | status = create_all_tasks(); // create all tasks |
|
133 | 136 | if (status != RTEMS_SUCCESSFUL) |
|
134 | 137 | { |
|
135 | 138 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
136 | 139 | } |
|
137 | 140 | |
|
138 | 141 | // ************************** |
|
139 | 142 | // <SPACEWIRE INITIALIZATION> |
|
140 | 143 | grspw_timecode_callback = &timecode_irq_handler; |
|
141 | 144 | |
|
142 | 145 | status_spw = spacewire_open_link(); // (1) open the link |
|
143 | 146 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
144 | 147 | { |
|
145 | 148 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
146 | 149 | } |
|
147 | 150 | |
|
148 | 151 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
149 | 152 | { |
|
150 | 153 | status_spw = spacewire_configure_link( fdSPW ); |
|
151 | 154 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
152 | 155 | { |
|
153 | 156 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
154 | 157 | } |
|
155 | 158 | } |
|
156 | 159 | |
|
157 | 160 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
158 | 161 | { |
|
159 | 162 | status_spw = spacewire_start_link( fdSPW ); |
|
160 | 163 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
161 | 164 | { |
|
162 | 165 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
163 | 166 | } |
|
164 | 167 | } |
|
165 | 168 | // </SPACEWIRE INITIALIZATION> |
|
166 | 169 | // *************************** |
|
167 | 170 | |
|
168 | 171 | status = start_all_tasks(); // start all tasks |
|
169 | 172 | if (status != RTEMS_SUCCESSFUL) |
|
170 | 173 | { |
|
171 | 174 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
172 | 175 | } |
|
173 | 176 | |
|
174 | 177 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
175 | 178 | status = start_recv_send_tasks(); |
|
176 | 179 | if ( status != RTEMS_SUCCESSFUL ) |
|
177 | 180 | { |
|
178 | 181 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
179 | 182 | } |
|
180 | 183 | |
|
181 | 184 | // suspend science tasks, they will be restarted later depending on the mode |
|
182 | 185 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
183 | 186 | if (status != RTEMS_SUCCESSFUL) |
|
184 | 187 | { |
|
185 | 188 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
186 | 189 | } |
|
187 | 190 | |
|
188 | 191 | //****************************** |
|
189 | 192 | // <SPECTRAL MATRICES SIMULATOR> |
|
190 | 193 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
191 | 194 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
192 | 195 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
193 | 196 | // </SPECTRAL MATRICES SIMULATOR> |
|
194 | 197 | //******************************* |
|
195 | 198 | |
|
196 | 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 | 201 | IRQ_SPARC_WAVEFORM_PICKER, |
|
199 | 202 | &old_isr_handler) ; |
|
200 | 203 | // configure IRQ handling for the spectral matrices unit |
|
201 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
|
202 | IRQ_SPARC_SPECTRAL_MATRIX, | |
|
203 | &old_isr_handler) ; | |
|
204 | // status = rtems_interrupt_catch( spectral_matrices_isr, | |
|
205 | // IRQ_SPARC_SPECTRAL_MATRIX, | |
|
206 | // &old_isr_handler) ; | |
|
204 | 207 | |
|
205 | 208 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
206 | 209 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
207 | 210 | { |
|
208 | 211 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
209 | 212 | if ( status != RTEMS_SUCCESSFUL ) { |
|
210 | 213 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
211 | 214 | } |
|
212 | 215 | } |
|
213 | 216 | |
|
214 | 217 | BOOT_PRINTF("delete INIT\n") |
|
215 | 218 | |
|
216 | 219 | status = rtems_task_delete(RTEMS_SELF); |
|
217 | 220 | |
|
218 | 221 | } |
|
219 | 222 | |
|
220 | 223 | void init_local_mode_parameters( void ) |
|
221 | 224 | { |
|
222 | 225 | /** This function initialize the param_local global variable with default values. |
|
223 | 226 | * |
|
224 | 227 | */ |
|
225 | 228 | |
|
226 | 229 | unsigned int i; |
|
227 | 230 | |
|
228 | 231 | // LOCAL PARAMETERS |
|
229 | 232 | |
|
230 | 233 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
231 | 234 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
232 | 235 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
233 | 236 | |
|
234 | 237 | // init sequence counters |
|
235 | 238 | |
|
236 | 239 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
237 | 240 | { |
|
238 | 241 | sequenceCounters_TC_EXE[i] = 0x00; |
|
239 | 242 | } |
|
240 | 243 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
241 | 244 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
242 | 245 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
243 | 246 | sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
244 | 247 | } |
|
245 | 248 | |
|
246 | 249 | void reset_local_time( void ) |
|
247 | 250 | { |
|
248 | 251 | time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000 |
|
249 | 252 | } |
|
250 | 253 | |
|
251 | 254 | void create_names( void ) // create all names for tasks and queues |
|
252 | 255 | { |
|
253 | 256 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
254 | 257 | * |
|
255 | 258 | * @return RTEMS directive status codes: |
|
256 | 259 | * - RTEMS_SUCCESSFUL - successful completion |
|
257 | 260 | * |
|
258 | 261 | */ |
|
259 | 262 | |
|
260 | 263 | // task names |
|
261 | 264 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
262 | 265 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
263 | 266 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
264 | 267 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
265 | 268 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
266 | 269 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
267 | 270 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
268 | 271 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
269 | 272 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
270 | 273 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
271 | 274 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
272 | 275 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
273 | 276 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
274 | 277 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
275 | 278 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
276 | 279 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
277 | 280 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
278 | 281 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
279 | 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 | 285 | // rate monotonic period names |
|
282 |
name_hk_rate_monotonic = rtems_build_name( 'H', ' |
|
|
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 | 289 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
285 | 290 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
286 | 291 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
287 | 292 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
288 | 293 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
289 | 294 | } |
|
290 | 295 | |
|
291 | 296 | int create_all_tasks( void ) // create all tasks which run in the software |
|
292 | 297 | { |
|
293 | 298 | /** This function creates all RTEMS tasks used in the software. |
|
294 | 299 | * |
|
295 | 300 | * @return RTEMS directive status codes: |
|
296 | 301 | * - RTEMS_SUCCESSFUL - task created successfully |
|
297 | 302 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
298 | 303 | * - RTEMS_INVALID_NAME - invalid task name |
|
299 | 304 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
300 | 305 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
301 | 306 | * - RTEMS_TOO_MANY - too many tasks created |
|
302 | 307 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
303 | 308 | * - RTEMS_TOO_MANY - too many global objects |
|
304 | 309 | * |
|
305 | 310 | */ |
|
306 | 311 | |
|
307 | 312 | rtems_status_code status; |
|
308 | 313 | |
|
309 | 314 | //********** |
|
310 | 315 | // SPACEWIRE |
|
311 | 316 | // RECV |
|
312 | 317 | status = rtems_task_create( |
|
313 | 318 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
314 | 319 | RTEMS_DEFAULT_MODES, |
|
315 | 320 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
316 | 321 | ); |
|
317 | 322 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
318 | 323 | { |
|
319 | 324 | status = rtems_task_create( |
|
320 | 325 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
321 | 326 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
322 | 327 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
323 | 328 | ); |
|
324 | 329 | } |
|
325 | 330 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
326 | 331 | { |
|
327 | 332 | status = rtems_task_create( |
|
328 | 333 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
329 | 334 | RTEMS_DEFAULT_MODES, |
|
330 | 335 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
331 | 336 | ); |
|
332 | 337 | } |
|
333 | 338 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
334 | 339 | { |
|
335 | 340 | status = rtems_task_create( |
|
336 | 341 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
337 | 342 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
338 | 343 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
339 | 344 | ); |
|
340 | 345 | } |
|
341 | 346 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
342 | 347 | { |
|
343 | 348 | status = rtems_task_create( |
|
344 | 349 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
345 | 350 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
346 | 351 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
347 | 352 | ); |
|
348 | 353 | } |
|
349 | 354 | |
|
350 | 355 | //****************** |
|
351 | 356 | // SPECTRAL MATRICES |
|
352 | 357 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
353 | 358 | { |
|
354 | 359 | status = rtems_task_create( |
|
355 | 360 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
356 | 361 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
357 | 362 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
358 | 363 | ); |
|
359 | 364 | } |
|
360 | 365 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
361 | 366 | { |
|
362 | 367 | status = rtems_task_create( |
|
363 | 368 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
364 | 369 | RTEMS_DEFAULT_MODES, |
|
365 | 370 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
366 | 371 | ); |
|
367 | 372 | } |
|
368 | 373 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
369 | 374 | { |
|
370 | 375 | status = rtems_task_create( |
|
371 | 376 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
372 | 377 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
373 | 378 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
374 | 379 | ); |
|
375 | 380 | } |
|
376 | 381 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
377 | 382 | { |
|
378 | 383 | status = rtems_task_create( |
|
379 | 384 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
380 | 385 | RTEMS_DEFAULT_MODES, |
|
381 | 386 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
382 | 387 | ); |
|
383 | 388 | } |
|
384 | 389 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
385 | 390 | { |
|
386 | 391 | status = rtems_task_create( |
|
387 | 392 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
388 | 393 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
389 | 394 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
390 | 395 | ); |
|
391 | 396 | } |
|
392 | 397 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
393 | 398 | { |
|
394 | 399 | status = rtems_task_create( |
|
395 | 400 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
396 | 401 | RTEMS_DEFAULT_MODES, |
|
397 | 402 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
398 | 403 | ); |
|
399 | 404 | } |
|
400 | 405 | |
|
401 | 406 | //**************** |
|
402 | 407 | // WAVEFORM PICKER |
|
403 | 408 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
404 | 409 | { |
|
405 | 410 | status = rtems_task_create( |
|
406 | 411 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
407 | 412 | RTEMS_DEFAULT_MODES, |
|
408 | 413 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
409 | 414 | ); |
|
410 | 415 | } |
|
411 | 416 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
412 | 417 | { |
|
413 | 418 | status = rtems_task_create( |
|
414 | 419 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
415 | 420 | RTEMS_DEFAULT_MODES, |
|
416 | 421 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
417 | 422 | ); |
|
418 | 423 | } |
|
419 | 424 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
420 | 425 | { |
|
421 | 426 | status = rtems_task_create( |
|
422 | 427 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
423 | 428 | RTEMS_DEFAULT_MODES, |
|
424 | 429 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
425 | 430 | ); |
|
426 | 431 | } |
|
427 | 432 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
428 | 433 | { |
|
429 | 434 | status = rtems_task_create( |
|
430 | 435 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
431 | 436 | RTEMS_DEFAULT_MODES, |
|
432 | 437 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
433 | 438 | ); |
|
434 | 439 | } |
|
435 | 440 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
436 | 441 | { |
|
437 | 442 | status = rtems_task_create( |
|
438 | 443 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
439 | 444 | RTEMS_DEFAULT_MODES, |
|
440 | 445 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
441 | 446 | ); |
|
442 | 447 | } |
|
443 | 448 | |
|
444 | 449 | //***** |
|
445 | 450 | // MISC |
|
446 | 451 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
447 | 452 | { |
|
448 | 453 | status = rtems_task_create( |
|
449 | 454 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
450 | 455 | RTEMS_DEFAULT_MODES, |
|
451 | 456 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
452 | 457 | ); |
|
453 | 458 | } |
|
454 | 459 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
455 | 460 | { |
|
456 | 461 | status = rtems_task_create( |
|
457 | 462 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
458 | 463 | RTEMS_DEFAULT_MODES, |
|
459 | 464 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
460 | 465 | ); |
|
461 | 466 | } |
|
462 | 467 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
463 | 468 | { |
|
464 | 469 | status = rtems_task_create( |
|
465 | 470 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
466 | 471 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
467 | 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 | 484 | return status; |
|
472 | 485 | } |
|
473 | 486 | |
|
474 | 487 | int start_recv_send_tasks( void ) |
|
475 | 488 | { |
|
476 | 489 | rtems_status_code status; |
|
477 | 490 | |
|
478 | 491 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
479 | 492 | if (status!=RTEMS_SUCCESSFUL) { |
|
480 | 493 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
481 | 494 | } |
|
482 | 495 | |
|
483 | 496 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
484 | 497 | { |
|
485 | 498 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
486 | 499 | if (status!=RTEMS_SUCCESSFUL) { |
|
487 | 500 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
488 | 501 | } |
|
489 | 502 | } |
|
490 | 503 | |
|
491 | 504 | return status; |
|
492 | 505 | } |
|
493 | 506 | |
|
494 | 507 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
495 | 508 | { |
|
496 | 509 | /** This function starts all RTEMS tasks used in the software. |
|
497 | 510 | * |
|
498 | 511 | * @return RTEMS directive status codes: |
|
499 | 512 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
500 | 513 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
501 | 514 | * - RTEMS_INVALID_ID - invalid task id |
|
502 | 515 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
503 | 516 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
504 | 517 | * |
|
505 | 518 | */ |
|
506 | 519 | // starts all the tasks fot eh flight software |
|
507 | 520 | |
|
508 | 521 | rtems_status_code status; |
|
509 | 522 | |
|
510 | 523 | //********** |
|
511 | 524 | // SPACEWIRE |
|
512 | 525 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
513 | 526 | if (status!=RTEMS_SUCCESSFUL) { |
|
514 | 527 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
515 | 528 | } |
|
516 | 529 | |
|
517 | 530 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
518 | 531 | { |
|
519 | 532 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
520 | 533 | if (status!=RTEMS_SUCCESSFUL) { |
|
521 | 534 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
522 | 535 | } |
|
523 | 536 | } |
|
524 | 537 | |
|
525 | 538 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
526 | 539 | { |
|
527 | 540 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
528 | 541 | if (status!=RTEMS_SUCCESSFUL) { |
|
529 | 542 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
530 | 543 | } |
|
531 | 544 | } |
|
532 | 545 | |
|
533 | 546 | //****************** |
|
534 | 547 | // SPECTRAL MATRICES |
|
535 | 548 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
536 | 549 | { |
|
537 | 550 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
538 | 551 | if (status!=RTEMS_SUCCESSFUL) { |
|
539 | 552 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
540 | 553 | } |
|
541 | 554 | } |
|
542 | 555 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
543 | 556 | { |
|
544 | 557 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
545 | 558 | if (status!=RTEMS_SUCCESSFUL) { |
|
546 | 559 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
547 | 560 | } |
|
548 | 561 | } |
|
549 | 562 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
550 | 563 | { |
|
551 | 564 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
552 | 565 | if (status!=RTEMS_SUCCESSFUL) { |
|
553 | 566 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
554 | 567 | } |
|
555 | 568 | } |
|
556 | 569 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
557 | 570 | { |
|
558 | 571 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
559 | 572 | if (status!=RTEMS_SUCCESSFUL) { |
|
560 | 573 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
561 | 574 | } |
|
562 | 575 | } |
|
563 | 576 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
564 | 577 | { |
|
565 | 578 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
566 | 579 | if (status!=RTEMS_SUCCESSFUL) { |
|
567 | 580 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
568 | 581 | } |
|
569 | 582 | } |
|
570 | 583 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
571 | 584 | { |
|
572 | 585 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
573 | 586 | if (status!=RTEMS_SUCCESSFUL) { |
|
574 | 587 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
575 | 588 | } |
|
576 | 589 | } |
|
577 | 590 | |
|
578 | 591 | //**************** |
|
579 | 592 | // WAVEFORM PICKER |
|
580 | 593 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
581 | 594 | { |
|
582 | 595 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
583 | 596 | if (status!=RTEMS_SUCCESSFUL) { |
|
584 | 597 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
585 | 598 | } |
|
586 | 599 | } |
|
587 | 600 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
588 | 601 | { |
|
589 | 602 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
590 | 603 | if (status!=RTEMS_SUCCESSFUL) { |
|
591 | 604 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
592 | 605 | } |
|
593 | 606 | } |
|
594 | 607 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
595 | 608 | { |
|
596 | 609 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
597 | 610 | if (status!=RTEMS_SUCCESSFUL) { |
|
598 | 611 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
599 | 612 | } |
|
600 | 613 | } |
|
601 | 614 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
602 | 615 | { |
|
603 | 616 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
604 | 617 | if (status!=RTEMS_SUCCESSFUL) { |
|
605 | 618 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
606 | 619 | } |
|
607 | 620 | } |
|
608 | 621 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
609 | 622 | { |
|
610 | 623 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
611 | 624 | if (status!=RTEMS_SUCCESSFUL) { |
|
612 | 625 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
613 | 626 | } |
|
614 | 627 | } |
|
615 | 628 | |
|
616 | 629 | //***** |
|
617 | 630 | // MISC |
|
618 | 631 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
619 | 632 | { |
|
620 | 633 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
621 | 634 | if (status!=RTEMS_SUCCESSFUL) { |
|
622 | 635 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
623 | 636 | } |
|
624 | 637 | } |
|
625 | 638 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
626 | 639 | { |
|
627 | 640 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
628 | 641 | if (status!=RTEMS_SUCCESSFUL) { |
|
629 | 642 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
630 | 643 | } |
|
631 | 644 | } |
|
632 | 645 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
633 | 646 | { |
|
634 | 647 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
635 | 648 | if (status!=RTEMS_SUCCESSFUL) { |
|
636 | 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 | 660 | return status; |
|
641 | 661 | } |
|
642 | 662 | |
|
643 | 663 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
644 | 664 | { |
|
645 | 665 | rtems_status_code status_recv; |
|
646 | 666 | rtems_status_code status_send; |
|
647 | 667 | rtems_status_code status_q_p0; |
|
648 | 668 | rtems_status_code status_q_p1; |
|
649 | 669 | rtems_status_code status_q_p2; |
|
650 | 670 | rtems_status_code ret; |
|
651 | 671 | rtems_id queue_id; |
|
652 | 672 | |
|
653 | 673 | //**************************************** |
|
654 | 674 | // create the queue for handling valid TCs |
|
655 | 675 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
656 | 676 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
657 | 677 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
658 | 678 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
659 | 679 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
660 | 680 | } |
|
661 | 681 | |
|
662 | 682 | //************************************************ |
|
663 | 683 | // create the queue for handling TM packet sending |
|
664 | 684 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
665 | 685 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
666 | 686 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
667 | 687 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
668 | 688 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
669 | 689 | } |
|
670 | 690 | |
|
671 | 691 | //***************************************************************************** |
|
672 | 692 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
673 | 693 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
674 | 694 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
675 | 695 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
676 | 696 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
677 | 697 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
678 | 698 | } |
|
679 | 699 | |
|
680 | 700 | //***************************************************************************** |
|
681 | 701 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
682 | 702 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
683 | 703 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
684 | 704 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
685 | 705 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
686 | 706 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
687 | 707 | } |
|
688 | 708 | |
|
689 | 709 | //***************************************************************************** |
|
690 | 710 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
691 | 711 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
692 | 712 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
693 | 713 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
694 | 714 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
695 | 715 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
696 | 716 | } |
|
697 | 717 | |
|
698 | 718 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
699 | 719 | { |
|
700 | 720 | ret = status_recv; |
|
701 | 721 | } |
|
702 | 722 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
703 | 723 | { |
|
704 | 724 | ret = status_send; |
|
705 | 725 | } |
|
706 | 726 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
707 | 727 | { |
|
708 | 728 | ret = status_q_p0; |
|
709 | 729 | } |
|
710 | 730 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
711 | 731 | { |
|
712 | 732 | ret = status_q_p1; |
|
713 | 733 | } |
|
714 | 734 | else |
|
715 | 735 | { |
|
716 | 736 | ret = status_q_p2; |
|
717 | 737 | } |
|
718 | 738 | |
|
719 | 739 | return ret; |
|
720 | 740 | } |
|
721 | 741 | |
|
722 | 742 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
723 | 743 | { |
|
724 | 744 | rtems_status_code status; |
|
725 | 745 | rtems_name queue_name; |
|
726 | 746 | |
|
727 | 747 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
728 | 748 | |
|
729 | 749 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
730 | 750 | |
|
731 | 751 | return status; |
|
732 | 752 | } |
|
733 | 753 | |
|
734 | 754 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
735 | 755 | { |
|
736 | 756 | rtems_status_code status; |
|
737 | 757 | rtems_name queue_name; |
|
738 | 758 | |
|
739 | 759 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
740 | 760 | |
|
741 | 761 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
742 | 762 | |
|
743 | 763 | return status; |
|
744 | 764 | } |
|
745 | 765 | |
|
746 | 766 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
747 | 767 | { |
|
748 | 768 | rtems_status_code status; |
|
749 | 769 | rtems_name queue_name; |
|
750 | 770 | |
|
751 | 771 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
752 | 772 | |
|
753 | 773 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
754 | 774 | |
|
755 | 775 | return status; |
|
756 | 776 | } |
|
757 | 777 | |
|
758 | 778 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
759 | 779 | { |
|
760 | 780 | rtems_status_code status; |
|
761 | 781 | rtems_name queue_name; |
|
762 | 782 | |
|
763 | 783 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
764 | 784 | |
|
765 | 785 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
766 | 786 | |
|
767 | 787 | return status; |
|
768 | 788 | } |
|
769 | 789 | |
|
770 | 790 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
771 | 791 | { |
|
772 | 792 | rtems_status_code status; |
|
773 | 793 | rtems_name queue_name; |
|
774 | 794 | |
|
775 | 795 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
776 | 796 | |
|
777 | 797 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
778 | 798 | |
|
779 | 799 | return status; |
|
780 | 800 | } |
@@ -1,529 +1,526 | |||
|
1 | 1 | /** General usage functions and RTEMS tasks. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | */ |
|
7 | 7 | |
|
8 | 8 | #include "fsw_misc.h" |
|
9 | 9 | |
|
10 | 10 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
11 | 11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
12 | 12 | { |
|
13 | 13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
14 | 14 | * |
|
15 | 15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
16 | 16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
17 | 17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
18 | 18 | * @param interrupt_level is the interrupt level that the timer drives. |
|
19 | 19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
20 | 20 | * |
|
21 | 21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
22 | 22 | * |
|
23 | 23 | */ |
|
24 | 24 | |
|
25 | 25 | rtems_status_code status; |
|
26 | 26 | rtems_isr_entry old_isr_handler; |
|
27 | 27 | |
|
28 | 28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register |
|
29 | 29 | |
|
30 | 30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
31 | 31 | if (status!=RTEMS_SUCCESSFUL) |
|
32 | 32 | { |
|
33 | 33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
40 | 40 | { |
|
41 | 41 | /** This function starts a GPTIMER timer. |
|
42 | 42 | * |
|
43 | 43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
44 | 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 | 48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
49 | 49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
50 | 50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
51 | 51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
52 | 52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
56 | 56 | { |
|
57 | 57 | /** This function stops a GPTIMER timer. |
|
58 | 58 | * |
|
59 | 59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
60 | 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 | 64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
65 | 65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
66 | 66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) |
|
70 | 70 | { |
|
71 | 71 | /** This function sets the clock divider of a GPTIMER timer. |
|
72 | 72 | * |
|
73 | 73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
74 | 74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
75 | 75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
76 | 76 | * |
|
77 | 77 | */ |
|
78 | 78 | |
|
79 | 79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
83 | 83 | { |
|
84 | 84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
85 | 85 | |
|
86 | 86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
87 | 87 | |
|
88 | 88 | return 0; |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
92 | 92 | { |
|
93 | 93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
94 | 94 | |
|
95 | 95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; |
|
96 | 96 | |
|
97 | 97 | return 0; |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
101 | 101 | { |
|
102 | 102 | /** This function sets the scaler reload register of the apbuart module |
|
103 | 103 | * |
|
104 | 104 | * @param regs is the address of the apbuart registers in memory |
|
105 | 105 | * @param value is the value that will be stored in the scaler register |
|
106 | 106 | * |
|
107 | 107 | * The value shall be set by the software to get data on the serial interface. |
|
108 | 108 | * |
|
109 | 109 | */ |
|
110 | 110 | |
|
111 | 111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
112 | 112 | |
|
113 | 113 | apbuart_regs->scaler = value; |
|
114 | 114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | //************ |
|
118 | 118 | // RTEMS TASKS |
|
119 | 119 | |
|
120 | 120 | rtems_task stat_task(rtems_task_argument argument) |
|
121 | 121 | { |
|
122 | 122 | int i; |
|
123 | 123 | int j; |
|
124 | 124 | i = 0; |
|
125 | 125 | j = 0; |
|
126 | 126 | BOOT_PRINTF("in STAT *** \n") |
|
127 | 127 | while(1){ |
|
128 |
rtems_task_wake_after( |
|
|
128 | rtems_task_wake_after(STAT_TASK_PERIOD); | |
|
129 | 129 | PRINTF1("%d\n", j) |
|
130 | 130 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
131 | 131 | // #ifdef PRINT_TASK_STATISTICS |
|
132 | 132 | // rtems_cpu_usage_report(); |
|
133 | 133 | // rtems_cpu_usage_reset(); |
|
134 | 134 | // #endif |
|
135 | 135 | i = 0; |
|
136 | 136 | } |
|
137 | 137 | else i++; |
|
138 | 138 | j++; |
|
139 | 139 | } |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | rtems_task hous_task(rtems_task_argument argument) |
|
143 | 143 | { |
|
144 | 144 | rtems_status_code status; |
|
145 | 145 | rtems_id queue_id; |
|
146 | 146 | rtems_rate_monotonic_period_status period_status; |
|
147 | 147 | |
|
148 | 148 | status = get_message_queue_id_send( &queue_id ); |
|
149 | 149 | if (status != RTEMS_SUCCESSFUL) |
|
150 | 150 | { |
|
151 | 151 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
152 | 152 | } |
|
153 | 153 | |
|
154 | 154 | BOOT_PRINTF("in HOUS ***\n") |
|
155 | 155 | |
|
156 | 156 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
157 | 157 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
158 | 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 | 163 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
164 | 164 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
165 | 165 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
166 | 166 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
167 | 167 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
168 | 168 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
169 | 169 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
170 | 170 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
171 | 171 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
172 | 172 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
173 | 173 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
174 | 174 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
175 | 175 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
176 | 176 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
177 | 177 | housekeeping_packet.sid = SID_HK; |
|
178 | 178 | |
|
179 | 179 | status = rtems_rate_monotonic_cancel(HK_id); |
|
180 | 180 | if( status != RTEMS_SUCCESSFUL ) { |
|
181 | 181 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
182 | 182 | } |
|
183 | 183 | else { |
|
184 | 184 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
185 | 185 | } |
|
186 | 186 | |
|
187 | 187 | // startup phase |
|
188 | 188 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
189 | 189 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
190 | 190 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
191 | 191 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
192 | 192 | { |
|
193 | 193 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization |
|
194 | 194 | { |
|
195 | 195 | break; // break if LFR is synchronized |
|
196 | 196 | } |
|
197 | 197 | else |
|
198 | 198 | { |
|
199 | 199 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
200 | 200 | // sched_yield(); |
|
201 | 201 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms |
|
202 | 202 | } |
|
203 | 203 | } |
|
204 | 204 | status = rtems_rate_monotonic_cancel(HK_id); |
|
205 | 205 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
206 | 206 | |
|
207 | 207 | while(1){ // launch the rate monotonic task |
|
208 | 208 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
209 | 209 | if ( status != RTEMS_SUCCESSFUL ) { |
|
210 | 210 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
211 | 211 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
212 | 212 | } |
|
213 | 213 | else { |
|
214 | 214 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); |
|
215 | 215 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); |
|
216 | 216 | increment_seq_counter( &sequenceCounterHK ); |
|
217 | 217 | |
|
218 | 218 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
219 | 219 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
220 | 220 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
221 | 221 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
222 | 222 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
223 | 223 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
224 | 224 | |
|
225 | 225 | spacewire_update_statistics(); |
|
226 | 226 | |
|
227 | 227 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
228 | 228 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
229 | 229 | |
|
230 | 230 | // SEND PACKET |
|
231 | 231 | status = rtems_message_queue_urgent( queue_id, &housekeeping_packet, |
|
232 | 232 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
233 | 233 | if (status != RTEMS_SUCCESSFUL) { |
|
234 | 234 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
235 | 235 | } |
|
236 | 236 | } |
|
237 | 237 | } |
|
238 | 238 | |
|
239 | 239 | PRINTF("in HOUS *** deleting task\n") |
|
240 | 240 | |
|
241 | 241 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
242 | 242 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
243 | 243 | return; |
|
244 | 244 | } |
|
245 | 245 | |
|
246 | 246 | rtems_task dumb_task( rtems_task_argument unused ) |
|
247 | 247 | { |
|
248 | 248 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
249 | 249 | * |
|
250 | 250 | * @param unused is the starting argument of the RTEMS task |
|
251 | 251 | * |
|
252 | 252 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
253 | 253 | * |
|
254 | 254 | */ |
|
255 | 255 | |
|
256 | 256 | unsigned int i; |
|
257 | 257 | unsigned int intEventOut; |
|
258 | 258 | unsigned int coarse_time = 0; |
|
259 | 259 | unsigned int fine_time = 0; |
|
260 | 260 | rtems_event_set event_out; |
|
261 | 261 | |
|
262 | 262 | char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
263 | 263 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
264 | 264 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 |
|
265 | 265 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
266 | 266 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
267 | 267 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 |
|
268 | 268 | "ERR HK", // RTEMS_EVENT_6 |
|
269 | 269 | "ready for dump", // RTEMS_EVENT_7 |
|
270 | 270 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 |
|
271 | 271 | "tick", // RTEMS_EVENT_9 |
|
272 | 272 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 |
|
273 | 273 | "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11 |
|
274 | 274 | }; |
|
275 | 275 | |
|
276 | 276 | BOOT_PRINTF("in DUMB *** \n") |
|
277 | 277 | |
|
278 | 278 | while(1){ |
|
279 | 279 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
280 | 280 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
281 | 281 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, |
|
282 | 282 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
283 | 283 | intEventOut = (unsigned int) event_out; |
|
284 | 284 | for ( i=0; i<32; i++) |
|
285 | 285 | { |
|
286 | 286 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
287 | 287 | { |
|
288 | 288 | coarse_time = time_management_regs->coarse_time; |
|
289 | 289 | fine_time = time_management_regs->fine_time; |
|
290 | 290 | printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); |
|
291 | 291 | if (i==8) |
|
292 | 292 | { |
|
293 | 293 | PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status) |
|
294 | 294 | } |
|
295 | 295 | if (i==10) |
|
296 | 296 | { |
|
297 | 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 | 305 | // init housekeeping parameters |
|
306 | 306 | |
|
307 | 307 | void init_housekeeping_parameters( void ) |
|
308 | 308 | { |
|
309 | 309 | /** This function initialize the housekeeping_packet global variable with default values. |
|
310 | 310 | * |
|
311 | 311 | */ |
|
312 | 312 | |
|
313 | 313 | unsigned int i = 0; |
|
314 | 314 | unsigned char *parameters; |
|
315 | 315 | |
|
316 | 316 | parameters = (unsigned char*) &housekeeping_packet.lfr_status_word; |
|
317 | 317 | for(i = 0; i< SIZE_HK_PARAMETERS; i++) |
|
318 | 318 | { |
|
319 | 319 | parameters[i] = 0x00; |
|
320 | 320 | } |
|
321 | 321 | // init status word |
|
322 | 322 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
323 | 323 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
324 | 324 | // init software version |
|
325 | 325 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
326 | 326 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
327 | 327 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
328 | 328 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
329 | 329 | // init fpga version |
|
330 | 330 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
331 | 331 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
332 | 332 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
333 | 333 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
334 | 334 | } |
|
335 | 335 | |
|
336 | 336 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
337 | 337 | { |
|
338 | 338 | /** This function increment the sequence counter psased in argument. |
|
339 | 339 | * |
|
340 | 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 | 344 | unsigned short segmentation_grouping_flag; |
|
345 | 345 | unsigned short sequence_cnt; |
|
346 | 346 | |
|
347 | 347 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 |
|
348 | 348 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] |
|
349 | 349 | |
|
350 | 350 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
351 | 351 | { |
|
352 | 352 | sequence_cnt = sequence_cnt + 1; |
|
353 | 353 | } |
|
354 | 354 | else |
|
355 | 355 | { |
|
356 | 356 | sequence_cnt = 0; |
|
357 | 357 | } |
|
358 | 358 | |
|
359 | 359 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
360 | 360 | } |
|
361 | 361 | |
|
362 | 362 | void getTime( unsigned char *time) |
|
363 | 363 | { |
|
364 | 364 | /** This function write the current local time in the time buffer passed in argument. |
|
365 | 365 | * |
|
366 | 366 | */ |
|
367 | 367 | |
|
368 | 368 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
369 | 369 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
370 | 370 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
371 | 371 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
372 | 372 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
373 | 373 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
374 | 374 | } |
|
375 | 375 | |
|
376 | 376 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
377 | 377 | { |
|
378 | 378 | /** This function write the current local time in the time buffer passed in argument. |
|
379 | 379 | * |
|
380 | 380 | */ |
|
381 | 381 | unsigned long long int time; |
|
382 | 382 | |
|
383 | 383 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) |
|
384 | 384 | + time_management_regs->fine_time; |
|
385 | 385 | |
|
386 | 386 | return time; |
|
387 | 387 | } |
|
388 | 388 | |
|
389 | 389 | void send_dumb_hk( void ) |
|
390 | 390 | { |
|
391 | 391 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
392 | 392 | unsigned char *parameters; |
|
393 | 393 | unsigned int i; |
|
394 | 394 | rtems_id queue_id; |
|
395 | 395 | |
|
396 | 396 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
397 | 397 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
398 | 398 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
399 | 399 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
400 | 400 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
401 | 401 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
402 | 402 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
403 | 403 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
404 | 404 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
405 | 405 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
406 | 406 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
407 | 407 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
408 | 408 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
409 | 409 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
410 | 410 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
411 | 411 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
412 | 412 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
413 | 413 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
414 | 414 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
415 | 415 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
416 | 416 | dummy_hk_packet.sid = SID_HK; |
|
417 | 417 | |
|
418 | 418 | // init status word |
|
419 | 419 | dummy_hk_packet.lfr_status_word[0] = 0xff; |
|
420 | 420 | dummy_hk_packet.lfr_status_word[1] = 0xff; |
|
421 | 421 | // init software version |
|
422 | 422 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
423 | 423 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
424 | 424 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
425 | 425 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
426 | 426 | // init fpga version |
|
427 | 427 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); |
|
428 | 428 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
429 | 429 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
430 | 430 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
431 | 431 | |
|
432 | 432 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
433 | 433 | |
|
434 | 434 | for (i=0; i<100; i++) |
|
435 | 435 | { |
|
436 | 436 | parameters[i] = 0xff; |
|
437 | 437 | } |
|
438 | 438 | |
|
439 | 439 | get_message_queue_id_send( &queue_id ); |
|
440 | 440 | |
|
441 | 441 | rtems_message_queue_urgent( queue_id, &dummy_hk_packet, |
|
442 | 442 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
443 | 443 | } |
|
444 | 444 | |
|
445 | 445 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
446 | 446 | { |
|
447 | 447 | unsigned int coarseTime; |
|
448 | 448 | unsigned int acquisitionTime; |
|
449 | 449 | unsigned int deltaT = 0; |
|
450 | 450 | unsigned char *bufferPtr; |
|
451 | 451 | |
|
452 | 452 | unsigned int offset_in_samples; |
|
453 | 453 | unsigned int offset_in_bytes; |
|
454 | 454 | unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz |
|
455 | 455 | |
|
456 | 456 | if (lfrCurrentMode == LFR_MODE_STANDBY) |
|
457 | 457 | { |
|
458 | 458 | spacecraft_potential[0] = 0x00; |
|
459 | 459 | spacecraft_potential[1] = 0x00; |
|
460 | 460 | spacecraft_potential[2] = 0x00; |
|
461 | 461 | spacecraft_potential[3] = 0x00; |
|
462 | 462 | spacecraft_potential[4] = 0x00; |
|
463 | 463 | spacecraft_potential[5] = 0x00; |
|
464 | 464 | } |
|
465 | 465 | else |
|
466 | 466 | { |
|
467 | 467 | coarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
468 | 468 | bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address; |
|
469 | 469 | acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 ) |
|
470 | 470 | + (unsigned int) ( bufferPtr[1] << 16 ) |
|
471 | 471 | + (unsigned int) ( bufferPtr[2] << 8 ) |
|
472 | 472 | + (unsigned int) ( bufferPtr[3] ); |
|
473 | 473 | if ( coarseTime > acquisitionTime ) |
|
474 | 474 | { |
|
475 | 475 | deltaT = coarseTime - acquisitionTime; |
|
476 | 476 | offset_in_samples = (deltaT-1) * f3 ; |
|
477 | 477 | } |
|
478 | 478 | else if( coarseTime == acquisitionTime ) |
|
479 | 479 | { |
|
480 | 480 | bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer |
|
481 | 481 | offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1; |
|
482 | 482 | } |
|
483 | 483 | else |
|
484 | 484 | { |
|
485 | 485 | offset_in_samples = 0; |
|
486 | 486 | PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime) |
|
487 | 487 | } |
|
488 | 488 | |
|
489 | 489 | if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) ) |
|
490 | 490 | { |
|
491 | 491 | PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples) |
|
492 | 492 | offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1; |
|
493 | 493 | } |
|
494 | 494 | offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4; |
|
495 | 495 | spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0]; |
|
496 | 496 | spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1]; |
|
497 | 497 | spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2]; |
|
498 | 498 | spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3]; |
|
499 | 499 | spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4]; |
|
500 | 500 | spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5]; |
|
501 | 501 | } |
|
502 | 502 | } |
|
503 | 503 | |
|
504 | 504 | void get_cpu_load( unsigned char *resource_statistics ) |
|
505 | 505 | { |
|
506 | 506 | unsigned char cpu_load; |
|
507 | 507 | |
|
508 | 508 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
509 | 509 | |
|
510 | 510 | // HK_LFR_CPU_LOAD |
|
511 | 511 | resource_statistics[0] = cpu_load; |
|
512 | 512 | |
|
513 | 513 | // HK_LFR_CPU_LOAD_MAX |
|
514 | 514 | if (cpu_load > resource_statistics[1]) |
|
515 | 515 | { |
|
516 | 516 | resource_statistics[1] = cpu_load; |
|
517 | 517 | } |
|
518 | 518 | |
|
519 | 519 | // CPU_LOAD_AVE |
|
520 | 520 | resource_statistics[2] = 0; |
|
521 | 521 | |
|
522 | 522 | #ifndef PRINT_TASK_STATISTICS |
|
523 | 523 | rtems_cpu_usage_reset(); |
|
524 | 524 | #endif |
|
525 | 525 | |
|
526 | 526 | } |
|
527 | ||
|
528 | ||
|
529 |
@@ -1,610 +1,613 | |||
|
1 | 1 | /** Functions related to the SpaceWire interface. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle SpaceWire transmissions: |
|
7 | 7 | * - configuration of the SpaceWire link |
|
8 | 8 | * - SpaceWire related interruption requests processing |
|
9 | 9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
10 | 10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
11 | 11 | * |
|
12 | 12 | */ |
|
13 | 13 | |
|
14 | 14 | #include "fsw_spacewire.h" |
|
15 | 15 | |
|
16 | 16 | rtems_name semq_name; |
|
17 | 17 | rtems_id semq_id; |
|
18 | 18 | |
|
19 | 19 | //*********** |
|
20 | 20 | // RTEMS TASK |
|
21 | 21 | rtems_task spiq_task(rtems_task_argument unused) |
|
22 | 22 | { |
|
23 | 23 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
24 | 24 | * |
|
25 | 25 | * @param unused is the starting argument of the RTEMS task |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | rtems_event_set event_out; |
|
30 | 30 | rtems_status_code status; |
|
31 | 31 | int linkStatus; |
|
32 | 32 | |
|
33 | 33 | BOOT_PRINTF("in SPIQ *** \n") |
|
34 | 34 | |
|
35 | 35 | while(true){ |
|
36 | 36 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
37 | 37 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
38 | 38 | |
|
39 | 39 | // [0] SUSPEND RECV AND SEND TASKS |
|
40 | 40 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
41 | 41 | if ( status != RTEMS_SUCCESSFUL ) { |
|
42 | 42 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
43 | 43 | } |
|
44 | 44 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
45 | 45 | if ( status != RTEMS_SUCCESSFUL ) { |
|
46 | 46 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | 49 | // [1] CHECK THE LINK |
|
50 | 50 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
51 | 51 | if ( linkStatus != 5) { |
|
52 | 52 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
53 | 53 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
57 | 57 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
58 | 58 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
59 | 59 | { |
|
60 | 60 | spacewire_compute_stats_offsets(); |
|
61 | 61 | status = spacewire_reset_link( ); |
|
62 | 62 | } |
|
63 | 63 | else // [2.b] in run state, start the link |
|
64 | 64 | { |
|
65 | 65 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
66 | 66 | if ( status != RTEMS_SUCCESSFUL) |
|
67 | 67 | { |
|
68 | 68 | PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status) |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
73 | 73 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
74 | 74 | { |
|
75 | 75 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
76 | 76 | if ( status != RTEMS_SUCCESSFUL ) { |
|
77 | 77 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
78 | 78 | } |
|
79 | 79 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
80 | 80 | if ( status != RTEMS_SUCCESSFUL ) { |
|
81 | 81 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
82 | 82 | } |
|
83 | 83 | } |
|
84 | 84 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
85 | 85 | { |
|
86 | 86 | status = stop_current_mode(); |
|
87 | 87 | if ( status != RTEMS_SUCCESSFUL ) { |
|
88 | 88 | PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) |
|
89 | 89 | } |
|
90 | 90 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
91 | 91 | if ( status != RTEMS_SUCCESSFUL ) { |
|
92 | 92 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
93 | 93 | } |
|
94 | 94 | // wake the WTDG task up to wait for the link recovery |
|
95 | 95 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
96 | 96 | status = rtems_task_suspend( RTEMS_SELF ); |
|
97 | 97 | } |
|
98 | 98 | } |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | rtems_task recv_task( rtems_task_argument unused ) |
|
102 | 102 | { |
|
103 | 103 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
104 | 104 | * |
|
105 | 105 | * @param unused is the starting argument of the RTEMS task |
|
106 | 106 | * |
|
107 | 107 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
108 | 108 | * 1. It reads the incoming data. |
|
109 | 109 | * 2. Launches the acceptance procedure. |
|
110 | 110 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
111 | 111 | * |
|
112 | 112 | */ |
|
113 | 113 | |
|
114 | 114 | int len; |
|
115 | 115 | ccsdsTelecommandPacket_t currentTC; |
|
116 | 116 | unsigned char computed_CRC[ 2 ]; |
|
117 | 117 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
118 | 118 | unsigned char destinationID; |
|
119 | 119 | unsigned int estimatedPacketLength; |
|
120 | 120 | unsigned int parserCode; |
|
121 | 121 | rtems_status_code status; |
|
122 | 122 | rtems_id queue_recv_id; |
|
123 | 123 | rtems_id queue_send_id; |
|
124 | 124 | |
|
125 | 125 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
126 | 126 | |
|
127 | 127 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
128 | 128 | if (status != RTEMS_SUCCESSFUL) |
|
129 | 129 | { |
|
130 | 130 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
131 | 131 | } |
|
132 | 132 | |
|
133 | 133 | status = get_message_queue_id_send( &queue_send_id ); |
|
134 | 134 | if (status != RTEMS_SUCCESSFUL) |
|
135 | 135 | { |
|
136 | 136 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | BOOT_PRINTF("in RECV *** \n") |
|
140 | 140 | |
|
141 | 141 | while(1) |
|
142 | 142 | { |
|
143 | 143 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
144 | 144 | if (len == -1){ // error during the read call |
|
145 | 145 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
146 | 146 | } |
|
147 | 147 | else { |
|
148 | 148 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
149 | 149 | PRINTF("in RECV *** packet lenght too short\n") |
|
150 | 150 | } |
|
151 | 151 | else { |
|
152 | 152 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
153 | 153 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
154 | 154 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
155 | 155 | // CHECK THE TC |
|
156 | 156 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
157 | 157 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
158 | 158 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
159 | 159 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
160 | 160 | || (parserCode == WRONG_SRC_ID) ) |
|
161 | 161 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
162 | 162 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
163 | 163 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
164 | 164 | && |
|
165 | 165 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
166 | 166 | ) |
|
167 | 167 | { |
|
168 | 168 | if ( parserCode == WRONG_SRC_ID ) |
|
169 | 169 | { |
|
170 | 170 | destinationID = SID_TC_GROUND; |
|
171 | 171 | } |
|
172 | 172 | else |
|
173 | 173 | { |
|
174 | 174 | destinationID = currentTC.sourceID; |
|
175 | 175 | } |
|
176 | 176 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
177 | 177 | computed_CRC, currentTC_LEN_RCV, |
|
178 | 178 | destinationID ); |
|
179 | 179 | } |
|
180 | 180 | } |
|
181 | 181 | else |
|
182 | 182 | { // send valid TC to the action launcher |
|
183 | 183 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
184 | 184 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
185 | 185 | } |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | } |
|
189 | 189 | } |
|
190 | 190 | |
|
191 | 191 | rtems_task send_task( rtems_task_argument argument) |
|
192 | 192 | { |
|
193 | 193 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
194 | 194 | * |
|
195 | 195 | * @param unused is the starting argument of the RTEMS task |
|
196 | 196 | * |
|
197 | 197 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
198 | 198 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
199 | 199 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
200 | 200 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
201 | 201 | * data it contains. |
|
202 | 202 | * |
|
203 | 203 | */ |
|
204 | 204 | |
|
205 | 205 | rtems_status_code status; // RTEMS status code |
|
206 | 206 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
207 | 207 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
208 | 208 | size_t size; // size of the incoming TC packet |
|
209 | 209 | u_int32_t count; |
|
210 | 210 | rtems_id queue_id; |
|
211 | rtems_interrupt_level level; | |
|
211 | 212 | |
|
212 | 213 | status = get_message_queue_id_send( &queue_id ); |
|
213 | 214 | if (status != RTEMS_SUCCESSFUL) |
|
214 | 215 | { |
|
215 | 216 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
216 | 217 | } |
|
217 | 218 | |
|
218 | 219 | BOOT_PRINTF("in SEND *** \n") |
|
219 | 220 | |
|
220 | 221 | while(1) |
|
221 | 222 | { |
|
222 | 223 | status = rtems_message_queue_receive( queue_id, incomingData, &size, |
|
223 | 224 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
224 | ||
|
225 | rtems_interrupt_disable( level ); | |
|
225 | 226 | if (status!=RTEMS_SUCCESSFUL) |
|
226 | 227 | { |
|
227 | 228 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
228 | 229 | } |
|
229 | 230 | else |
|
230 | 231 | { |
|
231 | 232 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet |
|
232 | 233 | { |
|
233 | 234 | status = write( fdSPW, incomingData, size ); |
|
234 | 235 | if (status == -1){ |
|
235 | 236 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
236 | 237 | } |
|
237 | 238 | } |
|
238 | 239 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
239 | 240 | { |
|
240 | 241 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
241 | 242 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
242 | 243 | if (status == -1){ |
|
243 | 244 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
244 | 245 | } |
|
245 | 246 | } |
|
246 | 247 | } |
|
247 | 248 | |
|
248 | 249 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
249 | 250 | if (status != RTEMS_SUCCESSFUL) |
|
250 | 251 | { |
|
251 | 252 | PRINTF1("in SEND *** (3) ERR = %d\n", status) |
|
252 | 253 | } |
|
253 | 254 | else |
|
254 | 255 | { |
|
255 | 256 | if (count > maxCount) |
|
256 | 257 | { |
|
257 | 258 | maxCount = count; |
|
258 | 259 | } |
|
259 | 260 | } |
|
261 | ||
|
262 | rtems_interrupt_enable( level ); | |
|
260 | 263 | } |
|
261 | 264 | } |
|
262 | 265 | |
|
263 | 266 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
264 | 267 | { |
|
265 | 268 | rtems_event_set event_out; |
|
266 | 269 | rtems_status_code status; |
|
267 | 270 | int linkStatus; |
|
268 | 271 | |
|
269 | 272 | BOOT_PRINTF("in WTDG ***\n") |
|
270 | 273 | |
|
271 | 274 | while(1) |
|
272 | 275 | { |
|
273 | 276 | // wait for an RTEMS_EVENT |
|
274 | 277 | rtems_event_receive( RTEMS_EVENT_0, |
|
275 | 278 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
276 | 279 | PRINTF("in WTDG *** wait for the link\n") |
|
277 | 280 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
278 | 281 | while( linkStatus != 5) // wait for the link |
|
279 | 282 | { |
|
280 | 283 | rtems_task_wake_after( 10 ); |
|
281 | 284 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
282 | 285 | } |
|
283 | 286 | |
|
284 | 287 | status = spacewire_stop_and_start_link( fdSPW ); |
|
285 | 288 | |
|
286 | 289 | if (status != RTEMS_SUCCESSFUL) |
|
287 | 290 | { |
|
288 | 291 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
289 | 292 | } |
|
290 | 293 | else |
|
291 | 294 | { |
|
292 | 295 | PRINTF("in WTDG *** OK link started\n") |
|
293 | 296 | } |
|
294 | 297 | |
|
295 | 298 | // restart the SPIQ task |
|
296 | 299 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
297 | 300 | if ( status != RTEMS_SUCCESSFUL ) { |
|
298 | 301 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
299 | 302 | } |
|
300 | 303 | |
|
301 | 304 | // restart RECV and SEND |
|
302 | 305 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
303 | 306 | if ( status != RTEMS_SUCCESSFUL ) { |
|
304 | 307 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
305 | 308 | } |
|
306 | 309 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
307 | 310 | if ( status != RTEMS_SUCCESSFUL ) { |
|
308 | 311 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
309 | 312 | } |
|
310 | 313 | } |
|
311 | 314 | } |
|
312 | 315 | |
|
313 | 316 | //**************** |
|
314 | 317 | // OTHER FUNCTIONS |
|
315 | 318 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
316 | 319 | { |
|
317 | 320 | /** This function opens the SpaceWire link. |
|
318 | 321 | * |
|
319 | 322 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
320 | 323 | * |
|
321 | 324 | */ |
|
322 | 325 | rtems_status_code status; |
|
323 | 326 | |
|
324 | 327 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
325 | 328 | if ( fdSPW < 0 ) { |
|
326 | 329 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
327 | 330 | } |
|
328 | 331 | else |
|
329 | 332 | { |
|
330 | 333 | status = RTEMS_SUCCESSFUL; |
|
331 | 334 | } |
|
332 | 335 | |
|
333 | 336 | return status; |
|
334 | 337 | } |
|
335 | 338 | |
|
336 | 339 | int spacewire_start_link( int fd ) |
|
337 | 340 | { |
|
338 | 341 | rtems_status_code status; |
|
339 | 342 | |
|
340 | 343 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
341 | 344 | // -1 default hardcoded driver timeout |
|
342 | 345 | |
|
343 | 346 | return status; |
|
344 | 347 | } |
|
345 | 348 | |
|
346 | 349 | int spacewire_stop_and_start_link( int fd ) |
|
347 | 350 | { |
|
348 | 351 | rtems_status_code status; |
|
349 | 352 | |
|
350 | 353 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
351 | 354 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
352 | 355 | // -1 default hardcoded driver timeout |
|
353 | 356 | |
|
354 | 357 | return status; |
|
355 | 358 | } |
|
356 | 359 | |
|
357 | 360 | int spacewire_configure_link( int fd ) |
|
358 | 361 | { |
|
359 | 362 | /** This function configures the SpaceWire link. |
|
360 | 363 | * |
|
361 | 364 | * @return GR-RTEMS-DRIVER directive status codes: |
|
362 | 365 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
363 | 366 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
364 | 367 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
365 | 368 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
366 | 369 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
367 | 370 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
368 | 371 | * - 2 ENOENT - No such file or directory |
|
369 | 372 | */ |
|
370 | 373 | |
|
371 | 374 | rtems_status_code status; |
|
372 | 375 | |
|
373 | 376 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
374 | 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 | 379 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
377 | 380 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
378 | 381 | // |
|
379 | 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 | 383 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
381 | 384 | // |
|
382 | 385 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
383 | 386 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
384 | 387 | // |
|
385 | 388 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
386 | 389 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
387 | 390 | // |
|
388 | 391 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks |
|
389 | 392 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
390 | 393 | // |
|
391 | 394 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
392 | 395 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
393 | 396 | // |
|
394 | 397 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
395 | 398 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
396 | 399 | |
|
397 | 400 | return status; |
|
398 | 401 | } |
|
399 | 402 | |
|
400 | 403 | int spacewire_reset_link( void ) |
|
401 | 404 | { |
|
402 | 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 | 407 | * @return RTEMS directive status code: |
|
405 | 408 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
406 | 409 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
407 | 410 | * |
|
408 | 411 | */ |
|
409 | 412 | |
|
410 | 413 | rtems_status_code status_spw; |
|
411 | 414 | int i; |
|
412 | 415 | |
|
413 | 416 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
414 | 417 | { |
|
415 | 418 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
416 | 419 | |
|
417 | 420 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
418 | 421 | |
|
419 | 422 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
420 | 423 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
421 | 424 | { |
|
422 | 425 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
423 | 426 | } |
|
424 | 427 | |
|
425 | 428 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
426 | 429 | { |
|
427 | 430 | break; |
|
428 | 431 | } |
|
429 | 432 | } |
|
430 | 433 | |
|
431 | 434 | return status_spw; |
|
432 | 435 | } |
|
433 | 436 | |
|
434 | 437 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
435 | 438 | { |
|
436 | 439 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
437 | 440 | * |
|
438 | 441 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
439 | 442 | * @param regAddr is the address of the GRSPW control register. |
|
440 | 443 | * |
|
441 | 444 | * NP is the bit 20 of the GRSPW control register. |
|
442 | 445 | * |
|
443 | 446 | */ |
|
444 | 447 | |
|
445 | 448 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
446 | 449 | |
|
447 | 450 | if (val == 1) { |
|
448 | 451 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
449 | 452 | } |
|
450 | 453 | if (val== 0) { |
|
451 | 454 | *spwptr = *spwptr & 0xffdfffff; |
|
452 | 455 | } |
|
453 | 456 | } |
|
454 | 457 | |
|
455 | 458 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
456 | 459 | { |
|
457 | 460 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
458 | 461 | * |
|
459 | 462 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
460 | 463 | * @param regAddr is the address of the GRSPW control register. |
|
461 | 464 | * |
|
462 | 465 | * RE is the bit 16 of the GRSPW control register. |
|
463 | 466 | * |
|
464 | 467 | */ |
|
465 | 468 | |
|
466 | 469 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
467 | 470 | |
|
468 | 471 | if (val == 1) |
|
469 | 472 | { |
|
470 | 473 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
471 | 474 | } |
|
472 | 475 | if (val== 0) |
|
473 | 476 | { |
|
474 | 477 | *spwptr = *spwptr & 0xfffdffff; |
|
475 | 478 | } |
|
476 | 479 | } |
|
477 | 480 | |
|
478 | 481 | void spacewire_compute_stats_offsets( void ) |
|
479 | 482 | { |
|
480 | 483 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
481 | 484 | * |
|
482 | 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 | 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 | 487 | * during the open systel call). |
|
485 | 488 | * |
|
486 | 489 | */ |
|
487 | 490 | |
|
488 | 491 | spw_stats spacewire_stats_grspw; |
|
489 | 492 | rtems_status_code status; |
|
490 | 493 | |
|
491 | 494 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
492 | 495 | |
|
493 | 496 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
494 | 497 | + spacewire_stats.packets_received; |
|
495 | 498 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
496 | 499 | + spacewire_stats.packets_sent; |
|
497 | 500 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
498 | 501 | + spacewire_stats.parity_err; |
|
499 | 502 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
500 | 503 | + spacewire_stats.disconnect_err; |
|
501 | 504 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
502 | 505 | + spacewire_stats.escape_err; |
|
503 | 506 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
504 | 507 | + spacewire_stats.credit_err; |
|
505 | 508 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
506 | 509 | + spacewire_stats.write_sync_err; |
|
507 | 510 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
508 | 511 | + spacewire_stats.rx_rmap_header_crc_err; |
|
509 | 512 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
510 | 513 | + spacewire_stats.rx_rmap_data_crc_err; |
|
511 | 514 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
512 | 515 | + spacewire_stats.early_ep; |
|
513 | 516 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
514 | 517 | + spacewire_stats.invalid_address; |
|
515 | 518 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
516 | 519 | + spacewire_stats.rx_eep_err; |
|
517 | 520 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
518 | 521 | + spacewire_stats.rx_truncated; |
|
519 | 522 | } |
|
520 | 523 | |
|
521 | 524 | void spacewire_update_statistics( void ) |
|
522 | 525 | { |
|
523 | 526 | rtems_status_code status; |
|
524 | 527 | spw_stats spacewire_stats_grspw; |
|
525 | 528 | |
|
526 | 529 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
527 | 530 | |
|
528 | 531 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
529 | 532 | + spacewire_stats_grspw.packets_received; |
|
530 | 533 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
531 | 534 | + spacewire_stats_grspw.packets_sent; |
|
532 | 535 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
533 | 536 | + spacewire_stats_grspw.parity_err; |
|
534 | 537 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
535 | 538 | + spacewire_stats_grspw.disconnect_err; |
|
536 | 539 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
537 | 540 | + spacewire_stats_grspw.escape_err; |
|
538 | 541 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
539 | 542 | + spacewire_stats_grspw.credit_err; |
|
540 | 543 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
541 | 544 | + spacewire_stats_grspw.write_sync_err; |
|
542 | 545 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
543 | 546 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
544 | 547 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
545 | 548 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
546 | 549 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
547 | 550 | + spacewire_stats_grspw.early_ep; |
|
548 | 551 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
549 | 552 | + spacewire_stats_grspw.invalid_address; |
|
550 | 553 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
551 | 554 | + spacewire_stats_grspw.rx_eep_err; |
|
552 | 555 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
553 | 556 | + spacewire_stats_grspw.rx_truncated; |
|
554 | 557 | //spacewire_stats.tx_link_err; |
|
555 | 558 | |
|
556 | 559 | //**************************** |
|
557 | 560 | // DPU_SPACEWIRE_IF_STATISTICS |
|
558 | 561 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
559 | 562 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
560 | 563 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
561 | 564 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
562 | 565 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
563 | 566 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
564 | 567 | |
|
565 | 568 | //****************************************** |
|
566 | 569 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
567 | 570 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
568 | 571 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
569 | 572 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
570 | 573 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
571 | 574 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
572 | 575 | |
|
573 | 576 | //********************************************* |
|
574 | 577 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
575 | 578 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
576 | 579 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
577 | 580 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
578 | 581 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
579 | 582 | } |
|
580 | 583 | |
|
581 | 584 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
582 | 585 | { |
|
583 | 586 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 ); |
|
584 | 587 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
585 | 588 | |
|
586 | 589 | grgpio_regs->io_port_direction_register = |
|
587 | 590 | grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled |
|
588 | 591 | |
|
589 | 592 | if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 ) |
|
590 | 593 | { |
|
591 | 594 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7; |
|
592 | 595 | } |
|
593 | 596 | else |
|
594 | 597 | { |
|
595 | 598 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08; |
|
596 | 599 | } |
|
597 | 600 | } |
|
598 | 601 | |
|
599 | 602 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
600 | 603 | { |
|
601 | 604 | int linkStatus; |
|
602 | 605 | rtems_status_code status; |
|
603 | 606 | |
|
604 | 607 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
605 | 608 | |
|
606 | 609 | if ( linkStatus == 5) { |
|
607 | 610 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
608 | 611 | status = RTEMS_SUCCESSFUL; |
|
609 | 612 | } |
|
610 | 613 | } |
@@ -1,689 +1,691 | |||
|
1 | 1 | /** Functions related to data processing. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "fsw_processing.h" |
|
11 | 11 | #include "fsw_processing_globals.c" |
|
12 | 12 | |
|
13 | 13 | unsigned int nb_sm_f0; |
|
14 | 14 | unsigned int nb_sm_f0_aux_f1; |
|
15 | 15 | unsigned int nb_sm_f1; |
|
16 | 16 | unsigned int nb_sm_f0_aux_f2; |
|
17 | 17 | |
|
18 | 18 | //************************ |
|
19 | 19 | // spectral matrices rings |
|
20 | 20 | ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ]; |
|
21 | 21 | ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ]; |
|
22 | 22 | ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ]; |
|
23 | 23 | ring_node_sm *current_ring_node_sm_f0; |
|
24 | 24 | ring_node_sm *current_ring_node_sm_f1; |
|
25 | 25 | ring_node_sm *current_ring_node_sm_f2; |
|
26 | 26 | ring_node_sm *ring_node_for_averaging_sm_f0; |
|
27 | 27 | ring_node_sm *ring_node_for_averaging_sm_f1; |
|
28 | 28 | ring_node_sm *ring_node_for_averaging_sm_f2; |
|
29 | 29 | |
|
30 | 30 | //*********************************************************** |
|
31 | 31 | // Interrupt Service Routine for spectral matrices processing |
|
32 | 32 | |
|
33 | 33 | void spectral_matrices_isr_f0( void ) |
|
34 | 34 | { |
|
35 | 35 | unsigned char status; |
|
36 | 36 | unsigned long long int time_0; |
|
37 | 37 | unsigned long long int time_1; |
|
38 | 38 | unsigned long long int syncBit0; |
|
39 | 39 | unsigned long long int syncBit1; |
|
40 | 40 | |
|
41 | 41 | status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits |
|
42 | 42 | |
|
43 | 43 | time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time ); |
|
44 | 44 | time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time ); |
|
45 | 45 | syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16; |
|
46 | 46 | syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16; |
|
47 | 47 | |
|
48 | 48 | switch(status) |
|
49 | 49 | { |
|
50 | 50 | case 0: |
|
51 | 51 | break; |
|
52 | 52 | case 3: |
|
53 | 53 | if ( time_0 < time_1 ) |
|
54 | 54 | { |
|
55 | 55 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
56 | 56 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0); |
|
57 | 57 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
58 | 58 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
59 | 59 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
60 | 60 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1); |
|
61 | 61 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
62 | 62 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
67 | 67 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1); |
|
68 | 68 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
69 | 69 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
70 | 70 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
71 | 71 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0); |
|
72 | 72 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
73 | 73 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
74 | 74 | } |
|
75 | 75 | spectral_matrix_regs->status = 0x03; // [0011] |
|
76 | 76 | break; |
|
77 | 77 | case 1: |
|
78 | 78 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
79 | 79 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0); |
|
80 | 80 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
81 | 81 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
82 | 82 | spectral_matrix_regs->status = 0x01; // [0001] |
|
83 | 83 | break; |
|
84 | 84 | case 2: |
|
85 | 85 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
86 | 86 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1); |
|
87 | 87 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
88 | 88 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
89 | 89 | spectral_matrix_regs->status = 0x02; // [0010] |
|
90 | 90 | break; |
|
91 | 91 | } |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | void spectral_matrices_isr_f1( void ) |
|
95 | 95 | { |
|
96 | 96 | unsigned char status; |
|
97 | 97 | unsigned long long int time; |
|
98 | 98 | unsigned long long int syncBit; |
|
99 | 99 | |
|
100 | 100 | status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits |
|
101 | 101 | |
|
102 | 102 | switch(status) |
|
103 | 103 | { |
|
104 | 104 | case 0: |
|
105 | 105 | break; |
|
106 | 106 | case 3: |
|
107 | 107 | // UNEXPECTED VALUE |
|
108 | 108 | spectral_matrix_regs->status = 0xc0; // [1100] |
|
109 | 109 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
110 | 110 | break; |
|
111 | 111 | case 1: |
|
112 | 112 | time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time ); |
|
113 | 113 | syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16; |
|
114 | 114 | close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], |
|
115 | 115 | ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit); |
|
116 | 116 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
117 | 117 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; |
|
118 | 118 | spectral_matrix_regs->status = 0x04; // [0100] |
|
119 | 119 | break; |
|
120 | 120 | case 2: |
|
121 | 121 | time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time ); |
|
122 | 122 | syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16; |
|
123 | 123 | close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], |
|
124 | 124 | ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit); |
|
125 | 125 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
126 | 126 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
127 | 127 | spectral_matrix_regs->status = 0x08; // [1000] |
|
128 | 128 | break; |
|
129 | 129 | } |
|
130 | 130 | } |
|
131 | 131 | |
|
132 | 132 | void spectral_matrices_isr_f2( void ) |
|
133 | 133 | { |
|
134 | 134 | unsigned char status; |
|
135 | 135 | |
|
136 | 136 | status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits |
|
137 | 137 | |
|
138 | 138 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
139 | 139 | |
|
140 | 140 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
141 | 141 | |
|
142 | 142 | switch(status) |
|
143 | 143 | { |
|
144 | 144 | case 0: |
|
145 | 145 | break; |
|
146 | 146 | case 3: |
|
147 | 147 | // UNEXPECTED VALUE |
|
148 | 148 | spectral_matrix_regs->status = 0x30; // [0011 0000] |
|
149 | 149 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
150 | 150 | break; |
|
151 | 151 | case 1: |
|
152 | 152 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; |
|
153 | 153 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; |
|
154 | 154 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; |
|
155 | 155 | spectral_matrix_regs->status = 0x10; // [0001 0000] |
|
156 | 156 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
157 | 157 | { |
|
158 | 158 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
159 | 159 | } |
|
160 | 160 | break; |
|
161 | 161 | case 2: |
|
162 | 162 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; |
|
163 | 163 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; |
|
164 | 164 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
165 | 165 | spectral_matrix_regs->status = 0x20; // [0010 0000] |
|
166 | 166 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
167 | 167 | { |
|
168 | 168 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
169 | 169 | } |
|
170 | 170 | break; |
|
171 | 171 | } |
|
172 | 172 | } |
|
173 | 173 | |
|
174 | 174 | void spectral_matrix_isr_error_handler( void ) |
|
175 | 175 | { |
|
176 | if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000] | |
|
177 | { | |
|
178 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
|
179 | } | |
|
176 | // if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000] | |
|
177 | // { | |
|
178 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
|
179 | // } | |
|
180 | ||
|
181 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x83f; | |
|
180 | 182 | } |
|
181 | 183 | |
|
182 | 184 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
183 | 185 | { |
|
184 | 186 | // STATUS REGISTER |
|
185 | 187 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
186 | 188 | // 10 9 8 |
|
187 | 189 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
188 | 190 | // 7 6 5 4 3 2 1 0 |
|
189 | 191 | |
|
190 | 192 | spectral_matrices_isr_f0(); |
|
191 | 193 | |
|
192 | 194 | spectral_matrices_isr_f1(); |
|
193 | 195 | |
|
194 | 196 | spectral_matrices_isr_f2(); |
|
195 | 197 | |
|
196 | 198 | // spectral_matrix_isr_error_handler(); |
|
197 | 199 | } |
|
198 | 200 | |
|
199 | 201 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
200 | 202 | { |
|
201 | 203 | //*** |
|
202 | 204 | // F0 |
|
203 | 205 | nb_sm_f0 = nb_sm_f0 + 1; |
|
204 | 206 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) |
|
205 | 207 | { |
|
206 | 208 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; |
|
207 | 209 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
208 | 210 | { |
|
209 | 211 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
210 | 212 | } |
|
211 | 213 | nb_sm_f0 = 0; |
|
212 | 214 | } |
|
213 | 215 | |
|
214 | 216 | //*** |
|
215 | 217 | // F1 |
|
216 | 218 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; |
|
217 | 219 | if (nb_sm_f0_aux_f1 == 6) |
|
218 | 220 | { |
|
219 | 221 | nb_sm_f0_aux_f1 = 0; |
|
220 | 222 | nb_sm_f1 = nb_sm_f1 + 1; |
|
221 | 223 | } |
|
222 | 224 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) |
|
223 | 225 | { |
|
224 | 226 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; |
|
225 | 227 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
226 | 228 | { |
|
227 | 229 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
228 | 230 | } |
|
229 | 231 | nb_sm_f1 = 0; |
|
230 | 232 | } |
|
231 | 233 | |
|
232 | 234 | //*** |
|
233 | 235 | // F2 |
|
234 | 236 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; |
|
235 | 237 | if (nb_sm_f0_aux_f2 == 96) |
|
236 | 238 | { |
|
237 | 239 | nb_sm_f0_aux_f2 = 0; |
|
238 | 240 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
239 | 241 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
240 | 242 | { |
|
241 | 243 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
242 | 244 | } |
|
243 | 245 | } |
|
244 | 246 | } |
|
245 | 247 | |
|
246 | 248 | //****************** |
|
247 | 249 | // Spectral Matrices |
|
248 | 250 | |
|
249 | 251 | void reset_nb_sm( void ) |
|
250 | 252 | { |
|
251 | 253 | nb_sm_f0 = 0; |
|
252 | 254 | nb_sm_f0_aux_f1 = 0; |
|
253 | 255 | nb_sm_f0_aux_f2 = 0; |
|
254 | 256 | |
|
255 | 257 | nb_sm_f1 = 0; |
|
256 | 258 | } |
|
257 | 259 | |
|
258 | 260 | void SM_init_rings( void ) |
|
259 | 261 | { |
|
260 | 262 | unsigned char i; |
|
261 | 263 | |
|
262 | 264 | // F0 RING |
|
263 | 265 | sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1]; |
|
264 | 266 | sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1]; |
|
265 | 267 | sm_ring_f0[0].buffer_address = |
|
266 | 268 | (int) &sm_f0[ 0 ]; |
|
267 | 269 | |
|
268 | 270 | sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0]; |
|
269 | 271 | sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2]; |
|
270 | 272 | sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address = |
|
271 | 273 | (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ]; |
|
272 | 274 | |
|
273 | 275 | for(i=1; i<NB_RING_NODES_SM_F0-1; i++) |
|
274 | 276 | { |
|
275 | 277 | sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1]; |
|
276 | 278 | sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1]; |
|
277 | 279 | sm_ring_f0[i].buffer_address = |
|
278 | 280 | (int) &sm_f0[ i * TOTAL_SIZE_SM ]; |
|
279 | 281 | } |
|
280 | 282 | |
|
281 | 283 | // F1 RING |
|
282 | 284 | sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1]; |
|
283 | 285 | sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1]; |
|
284 | 286 | sm_ring_f1[0].buffer_address = |
|
285 | 287 | (int) &sm_f1[ 0 ]; |
|
286 | 288 | |
|
287 | 289 | sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0]; |
|
288 | 290 | sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2]; |
|
289 | 291 | sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address = |
|
290 | 292 | (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ]; |
|
291 | 293 | |
|
292 | 294 | for(i=1; i<NB_RING_NODES_SM_F1-1; i++) |
|
293 | 295 | { |
|
294 | 296 | sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1]; |
|
295 | 297 | sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1]; |
|
296 | 298 | sm_ring_f1[i].buffer_address = |
|
297 | 299 | (int) &sm_f1[ i * TOTAL_SIZE_SM ]; |
|
298 | 300 | } |
|
299 | 301 | |
|
300 | 302 | // F2 RING |
|
301 | 303 | sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1]; |
|
302 | 304 | sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1]; |
|
303 | 305 | sm_ring_f2[0].buffer_address = |
|
304 | 306 | (int) &sm_f2[ 0 ]; |
|
305 | 307 | |
|
306 | 308 | sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0]; |
|
307 | 309 | sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2]; |
|
308 | 310 | sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address = |
|
309 | 311 | (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ]; |
|
310 | 312 | |
|
311 | 313 | for(i=1; i<NB_RING_NODES_SM_F2-1; i++) |
|
312 | 314 | { |
|
313 | 315 | sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1]; |
|
314 | 316 | sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1]; |
|
315 | 317 | sm_ring_f2[i].buffer_address = |
|
316 | 318 | (int) &sm_f2[ i * TOTAL_SIZE_SM ]; |
|
317 | 319 | } |
|
318 | 320 | |
|
319 | 321 | DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
320 | 322 | DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
321 | 323 | DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
322 | 324 | |
|
323 | 325 | spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address; |
|
324 | 326 | DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address) |
|
325 | 327 | } |
|
326 | 328 | |
|
327 | 329 | void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ) |
|
328 | 330 | { |
|
329 | 331 | unsigned char i; |
|
330 | 332 | |
|
331 | 333 | //*************** |
|
332 | 334 | // BUFFER ADDRESS |
|
333 | 335 | for(i=0; i<nbNodes; i++) |
|
334 | 336 | { |
|
335 | 337 | ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ]; |
|
336 | 338 | } |
|
337 | 339 | |
|
338 | 340 | //***** |
|
339 | 341 | // NEXT |
|
340 | 342 | ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ]; |
|
341 | 343 | for(i=0; i<nbNodes-1; i++) |
|
342 | 344 | { |
|
343 | 345 | ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ]; |
|
344 | 346 | } |
|
345 | 347 | |
|
346 | 348 | //********* |
|
347 | 349 | // PREVIOUS |
|
348 | 350 | ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ]; |
|
349 | 351 | for(i=1; i<nbNodes; i++) |
|
350 | 352 | { |
|
351 | 353 | ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ]; |
|
352 | 354 | } |
|
353 | 355 | } |
|
354 | 356 | |
|
355 | 357 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) |
|
356 | 358 | { |
|
357 | 359 | unsigned char i; |
|
358 | 360 | |
|
359 | 361 | ring[ nbNodes - 1 ].next |
|
360 | 362 | = (ring_node_asm*) &ring[ 0 ]; |
|
361 | 363 | |
|
362 | 364 | for(i=0; i<nbNodes-1; i++) |
|
363 | 365 | { |
|
364 | 366 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; |
|
365 | 367 | } |
|
366 | 368 | } |
|
367 | 369 | |
|
368 | 370 | void SM_reset_current_ring_nodes( void ) |
|
369 | 371 | { |
|
370 | 372 | current_ring_node_sm_f0 = sm_ring_f0[0].next; |
|
371 | 373 | current_ring_node_sm_f1 = sm_ring_f1[0].next; |
|
372 | 374 | current_ring_node_sm_f2 = sm_ring_f2[0].next; |
|
373 | 375 | |
|
374 | 376 | ring_node_for_averaging_sm_f0 = sm_ring_f0; |
|
375 | 377 | ring_node_for_averaging_sm_f1 = sm_ring_f1; |
|
376 | 378 | ring_node_for_averaging_sm_f2 = sm_ring_f2; |
|
377 | 379 | } |
|
378 | 380 | |
|
379 | 381 | void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header) |
|
380 | 382 | { |
|
381 | 383 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
382 | 384 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
383 | 385 | header->reserved = 0x00; |
|
384 | 386 | header->userApplication = CCSDS_USER_APP; |
|
385 | 387 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
386 | 388 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
387 | 389 | header->packetSequenceControl[0] = 0xc0; |
|
388 | 390 | header->packetSequenceControl[1] = 0x00; |
|
389 | 391 | header->packetLength[0] = 0x00; |
|
390 | 392 | header->packetLength[1] = 0x00; |
|
391 | 393 | // DATA FIELD HEADER |
|
392 | 394 | header->spare1_pusVersion_spare2 = 0x10; |
|
393 | 395 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
394 | 396 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
395 | 397 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
396 | 398 | // AUXILIARY DATA HEADER |
|
397 | 399 | header->sid = 0x00; |
|
398 | 400 | header->biaStatusInfo = 0x00; |
|
399 | 401 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
400 | 402 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
401 | 403 | header->time[0] = 0x00; |
|
402 | 404 | header->time[0] = 0x00; |
|
403 | 405 | header->time[0] = 0x00; |
|
404 | 406 | header->time[0] = 0x00; |
|
405 | 407 | header->time[0] = 0x00; |
|
406 | 408 | header->time[0] = 0x00; |
|
407 | 409 | header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB |
|
408 | 410 | header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB |
|
409 | 411 | } |
|
410 | 412 | |
|
411 | 413 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
412 | 414 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) |
|
413 | 415 | { |
|
414 | 416 | unsigned int i; |
|
415 | 417 | unsigned int length = 0; |
|
416 | 418 | rtems_status_code status; |
|
417 | 419 | |
|
418 | 420 | for (i=0; i<2; i++) |
|
419 | 421 | { |
|
420 | 422 | // (1) BUILD THE DATA |
|
421 | 423 | switch(sid) |
|
422 | 424 | { |
|
423 | 425 | case SID_NORM_ASM_F0: |
|
424 | 426 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent |
|
425 | 427 | spw_ioctl_send->data = &spectral_matrix[ |
|
426 | 428 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2 |
|
427 | 429 | ]; |
|
428 | 430 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0; |
|
429 | 431 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB |
|
430 | 432 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB |
|
431 | 433 | break; |
|
432 | 434 | case SID_NORM_ASM_F1: |
|
433 | 435 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent |
|
434 | 436 | spw_ioctl_send->data = &spectral_matrix[ |
|
435 | 437 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2 |
|
436 | 438 | ]; |
|
437 | 439 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1; |
|
438 | 440 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB |
|
439 | 441 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB |
|
440 | 442 | break; |
|
441 | 443 | case SID_NORM_ASM_F2: |
|
442 | 444 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent |
|
443 | 445 | spw_ioctl_send->data = &spectral_matrix[ |
|
444 | 446 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2 |
|
445 | 447 | ]; |
|
446 | 448 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
447 | 449 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
448 | 450 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
449 | 451 | break; |
|
450 | 452 | default: |
|
451 | 453 | PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid) |
|
452 | 454 | break; |
|
453 | 455 | } |
|
454 | 456 | spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
455 | 457 | spw_ioctl_send->hdr = (char *) header; |
|
456 | 458 | spw_ioctl_send->options = 0; |
|
457 | 459 | |
|
458 | 460 | // (2) BUILD THE HEADER |
|
459 | 461 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
460 | 462 | header->packetLength[0] = (unsigned char) (length>>8); |
|
461 | 463 | header->packetLength[1] = (unsigned char) (length); |
|
462 | 464 | header->sid = (unsigned char) sid; // SID |
|
463 | 465 | header->pa_lfr_pkt_cnt_asm = 2; |
|
464 | 466 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
465 | 467 | |
|
466 | 468 | // (3) SET PACKET TIME |
|
467 | 469 | header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
468 | 470 | header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
469 | 471 | header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
470 | 472 | header->time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
471 | 473 | header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
472 | 474 | header->time[5] = (unsigned char) (time_management_regs->fine_time); |
|
473 | 475 | // |
|
474 | 476 | header->acquisitionTime[0] = header->time[0]; |
|
475 | 477 | header->acquisitionTime[1] = header->time[1]; |
|
476 | 478 | header->acquisitionTime[2] = header->time[2]; |
|
477 | 479 | header->acquisitionTime[3] = header->time[3]; |
|
478 | 480 | header->acquisitionTime[4] = header->time[4]; |
|
479 | 481 | header->acquisitionTime[5] = header->time[5]; |
|
480 | 482 | |
|
481 | 483 | // (4) SEND PACKET |
|
482 | 484 | status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
483 | 485 | if (status != RTEMS_SUCCESSFUL) { |
|
484 | 486 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
485 | 487 | } |
|
486 | 488 | } |
|
487 | 489 | } |
|
488 | 490 | |
|
489 | 491 | //***************** |
|
490 | 492 | // Basic Parameters |
|
491 | 493 | |
|
492 | 494 | void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, |
|
493 | 495 | unsigned int apid, unsigned char sid, |
|
494 | 496 | unsigned int packetLength, unsigned char blkNr ) |
|
495 | 497 | { |
|
496 | 498 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
497 | 499 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
498 | 500 | header->reserved = 0x00; |
|
499 | 501 | header->userApplication = CCSDS_USER_APP; |
|
500 | 502 | header->packetID[0] = (unsigned char) (apid >> 8); |
|
501 | 503 | header->packetID[1] = (unsigned char) (apid); |
|
502 | 504 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
503 | 505 | header->packetSequenceControl[1] = 0x00; |
|
504 | 506 | header->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
505 | 507 | header->packetLength[1] = (unsigned char) (packetLength); |
|
506 | 508 | // DATA FIELD HEADER |
|
507 | 509 | header->spare1_pusVersion_spare2 = 0x10; |
|
508 | 510 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
509 | 511 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
510 | 512 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
511 | 513 | // AUXILIARY DATA HEADER |
|
512 | 514 | header->sid = sid; |
|
513 | 515 | header->biaStatusInfo = 0x00; |
|
514 | 516 | header->time[0] = 0x00; |
|
515 | 517 | header->time[0] = 0x00; |
|
516 | 518 | header->time[0] = 0x00; |
|
517 | 519 | header->time[0] = 0x00; |
|
518 | 520 | header->time[0] = 0x00; |
|
519 | 521 | header->time[0] = 0x00; |
|
520 | 522 | header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
521 | 523 | header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
522 | 524 | } |
|
523 | 525 | |
|
524 | 526 | void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, |
|
525 | 527 | unsigned int apid, unsigned char sid, |
|
526 | 528 | unsigned int packetLength , unsigned char blkNr) |
|
527 | 529 | { |
|
528 | 530 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
529 | 531 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
530 | 532 | header->reserved = 0x00; |
|
531 | 533 | header->userApplication = CCSDS_USER_APP; |
|
532 | 534 | header->packetID[0] = (unsigned char) (apid >> 8); |
|
533 | 535 | header->packetID[1] = (unsigned char) (apid); |
|
534 | 536 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
535 | 537 | header->packetSequenceControl[1] = 0x00; |
|
536 | 538 | header->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
537 | 539 | header->packetLength[1] = (unsigned char) (packetLength); |
|
538 | 540 | // DATA FIELD HEADER |
|
539 | 541 | header->spare1_pusVersion_spare2 = 0x10; |
|
540 | 542 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
541 | 543 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
542 | 544 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
543 | 545 | // AUXILIARY DATA HEADER |
|
544 | 546 | header->sid = sid; |
|
545 | 547 | header->biaStatusInfo = 0x00; |
|
546 | 548 | header->time[0] = 0x00; |
|
547 | 549 | header->time[0] = 0x00; |
|
548 | 550 | header->time[0] = 0x00; |
|
549 | 551 | header->time[0] = 0x00; |
|
550 | 552 | header->time[0] = 0x00; |
|
551 | 553 | header->time[0] = 0x00; |
|
552 | 554 | header->source_data_spare = 0x00; |
|
553 | 555 | header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
554 | 556 | header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
555 | 557 | } |
|
556 | 558 | |
|
557 | 559 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
558 | 560 | { |
|
559 | 561 | rtems_status_code status; |
|
560 | 562 | |
|
561 | 563 | // SET THE SEQUENCE_CNT PARAMETER |
|
562 | 564 | increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid ); |
|
563 | 565 | // SEND PACKET |
|
564 | 566 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
565 | 567 | if (status != RTEMS_SUCCESSFUL) |
|
566 | 568 | { |
|
567 | 569 | printf("ERR *** in BP_send *** ERR %d\n", (int) status); |
|
568 | 570 | } |
|
569 | 571 | } |
|
570 | 572 | |
|
571 | 573 | //****************** |
|
572 | 574 | // general functions |
|
573 | 575 | |
|
574 | 576 | void reset_spectral_matrix_regs( void ) |
|
575 | 577 | { |
|
576 | 578 | /** This function resets the spectral matrices module registers. |
|
577 | 579 | * |
|
578 | 580 | * The registers affected by this function are located at the following offset addresses: |
|
579 | 581 | * |
|
580 | 582 | * - 0x00 config |
|
581 | 583 | * - 0x04 status |
|
582 | 584 | * - 0x08 matrixF0_Address0 |
|
583 | 585 | * - 0x10 matrixFO_Address1 |
|
584 | 586 | * - 0x14 matrixF1_Address |
|
585 | 587 | * - 0x18 matrixF2_Address |
|
586 | 588 | * |
|
587 | 589 | */ |
|
588 | 590 | |
|
589 | 591 | spectral_matrix_regs->config = 0x00; |
|
590 | 592 | spectral_matrix_regs->status = 0x00; |
|
591 | 593 | |
|
592 | 594 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; |
|
593 | 595 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
594 | 596 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; |
|
595 | 597 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
596 | 598 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; |
|
597 | 599 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
598 | 600 | } |
|
599 | 601 | |
|
600 | 602 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
601 | 603 | { |
|
602 | 604 | time[0] = timeInBuffer[0]; |
|
603 | 605 | time[1] = timeInBuffer[1]; |
|
604 | 606 | time[2] = timeInBuffer[2]; |
|
605 | 607 | time[3] = timeInBuffer[3]; |
|
606 | 608 | time[4] = timeInBuffer[6]; |
|
607 | 609 | time[5] = timeInBuffer[7]; |
|
608 | 610 | } |
|
609 | 611 | |
|
610 | 612 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) |
|
611 | 613 | { |
|
612 | 614 | unsigned long long int acquisitionTimeAslong; |
|
613 | 615 | acquisitionTimeAslong = 0x00; |
|
614 | 616 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
615 | 617 | + ( (unsigned long long int) timePtr[1] << 32 ) |
|
616 | 618 | + ( (unsigned long long int) timePtr[2] << 24 ) |
|
617 | 619 | + ( (unsigned long long int) timePtr[3] << 16 ) |
|
618 | 620 | + ( (unsigned long long int) timePtr[6] << 8 ) |
|
619 | 621 | + ( (unsigned long long int) timePtr[7] ); |
|
620 | 622 | return acquisitionTimeAslong; |
|
621 | 623 | } |
|
622 | 624 | |
|
623 | 625 | void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, |
|
624 | 626 | ring_node_sm *node_for_averaging, ring_node_sm *ringNode, |
|
625 | 627 | unsigned long long int time ) |
|
626 | 628 | { |
|
627 | 629 | unsigned char *timePtr; |
|
628 | 630 | unsigned char *coarseTimePtr; |
|
629 | 631 | unsigned char *fineTimePtr; |
|
630 | 632 | |
|
631 | 633 | timePtr = (unsigned char *) &time; |
|
632 | 634 | coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime; |
|
633 | 635 | fineTimePtr = (unsigned char *) &node_for_averaging->fineTime; |
|
634 | 636 | |
|
635 | 637 | *nb_sm = *nb_sm + 1; |
|
636 | 638 | if (*nb_sm == nb_sm_before_avf) |
|
637 | 639 | { |
|
638 | 640 | node_for_averaging = ringNode; |
|
639 | 641 | coarseTimePtr[0] = timePtr[2]; |
|
640 | 642 | coarseTimePtr[1] = timePtr[3]; |
|
641 | 643 | coarseTimePtr[2] = timePtr[4]; |
|
642 | 644 | coarseTimePtr[3] = timePtr[5]; |
|
643 | 645 | fineTimePtr[2] = timePtr[6]; |
|
644 | 646 | fineTimePtr[3] = timePtr[7]; |
|
645 | 647 | if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
646 | 648 | { |
|
647 | 649 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
648 | 650 | } |
|
649 | 651 | *nb_sm = 0; |
|
650 | 652 | } |
|
651 | 653 | } |
|
652 | 654 | |
|
653 | 655 | unsigned char getSID( rtems_event_set event ) |
|
654 | 656 | { |
|
655 | 657 | unsigned char sid; |
|
656 | 658 | |
|
657 | 659 | rtems_event_set eventSetBURST; |
|
658 | 660 | rtems_event_set eventSetSBM; |
|
659 | 661 | |
|
660 | 662 | //****** |
|
661 | 663 | // BURST |
|
662 | 664 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 |
|
663 | 665 | | RTEMS_EVENT_BURST_BP1_F1 |
|
664 | 666 | | RTEMS_EVENT_BURST_BP2_F0 |
|
665 | 667 | | RTEMS_EVENT_BURST_BP2_F1; |
|
666 | 668 | |
|
667 | 669 | //**** |
|
668 | 670 | // SBM |
|
669 | 671 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 |
|
670 | 672 | | RTEMS_EVENT_SBM_BP1_F1 |
|
671 | 673 | | RTEMS_EVENT_SBM_BP2_F0 |
|
672 | 674 | | RTEMS_EVENT_SBM_BP2_F1; |
|
673 | 675 | |
|
674 | 676 | if (event & eventSetBURST) |
|
675 | 677 | { |
|
676 | 678 | sid = SID_BURST_BP1_F0; |
|
677 | 679 | } |
|
678 | 680 | else if (event & eventSetSBM) |
|
679 | 681 | { |
|
680 | 682 | sid = SID_SBM1_BP1_F0; |
|
681 | 683 | } |
|
682 | 684 | else |
|
683 | 685 | { |
|
684 | 686 | sid = 0; |
|
685 | 687 | } |
|
686 | 688 | |
|
687 | 689 | return sid; |
|
688 | 690 | } |
|
689 | 691 |
@@ -1,948 +1,1002 | |||
|
1 | 1 | /** Functions and tasks related to TeleCommand handling. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands:\n |
|
7 | 7 | * action launching\n |
|
8 | 8 | * TC parsing\n |
|
9 | 9 | * ... |
|
10 | 10 | * |
|
11 | 11 | */ |
|
12 | 12 | |
|
13 | 13 | #include "tc_handler.h" |
|
14 | 14 | |
|
15 | 15 | //*********** |
|
16 | 16 | // RTEMS TASK |
|
17 | 17 | |
|
18 | 18 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | 19 | { |
|
20 | 20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | 21 | * |
|
22 | 22 | * @param unused is the starting argument of the RTEMS task |
|
23 | 23 | * |
|
24 | 24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | 25 | * on the incoming TeleCommand. |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | int result; |
|
30 | 30 | rtems_status_code status; // RTEMS status code |
|
31 | 31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | 32 | size_t size; // size of the incoming TC packet |
|
33 | 33 | unsigned char subtype; // subtype of the current TC packet |
|
34 | 34 | unsigned char time[6]; |
|
35 | 35 | rtems_id queue_rcv_id; |
|
36 | 36 | rtems_id queue_snd_id; |
|
37 | 37 | |
|
38 | 38 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | 39 | if (status != RTEMS_SUCCESSFUL) |
|
40 | 40 | { |
|
41 | 41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | 45 | if (status != RTEMS_SUCCESSFUL) |
|
46 | 46 | { |
|
47 | 47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | result = LFR_SUCCESSFUL; |
|
51 | 51 | subtype = 0; // subtype of the current TC packet |
|
52 | 52 | |
|
53 | 53 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | 54 | |
|
55 | 55 | while(1) |
|
56 | 56 | { |
|
57 | 57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | 58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | 59 | getTime( time ); // set time to the current time |
|
60 | 60 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | 61 | { |
|
62 | 62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | subtype = TC.serviceSubType; |
|
67 | 67 | switch(subtype) |
|
68 | 68 | { |
|
69 | 69 | case TC_SUBTYPE_RESET: |
|
70 | 70 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | 71 | close_action( &TC, result, queue_snd_id ); |
|
72 | 72 | break; |
|
73 | 73 | // |
|
74 | 74 | case TC_SUBTYPE_LOAD_COMM: |
|
75 | 75 | result = action_load_common_par( &TC ); |
|
76 | 76 | close_action( &TC, result, queue_snd_id ); |
|
77 | 77 | break; |
|
78 | 78 | // |
|
79 | 79 | case TC_SUBTYPE_LOAD_NORM: |
|
80 | 80 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
81 | 81 | close_action( &TC, result, queue_snd_id ); |
|
82 | 82 | break; |
|
83 | 83 | // |
|
84 | 84 | case TC_SUBTYPE_LOAD_BURST: |
|
85 | 85 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
86 | 86 | close_action( &TC, result, queue_snd_id ); |
|
87 | 87 | break; |
|
88 | 88 | // |
|
89 | 89 | case TC_SUBTYPE_LOAD_SBM1: |
|
90 | 90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
91 | 91 | close_action( &TC, result, queue_snd_id ); |
|
92 | 92 | break; |
|
93 | 93 | // |
|
94 | 94 | case TC_SUBTYPE_LOAD_SBM2: |
|
95 | 95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
96 | 96 | close_action( &TC, result, queue_snd_id ); |
|
97 | 97 | break; |
|
98 | 98 | // |
|
99 | 99 | case TC_SUBTYPE_DUMP: |
|
100 | 100 | result = action_dump_par( queue_snd_id ); |
|
101 | 101 | close_action( &TC, result, queue_snd_id ); |
|
102 | 102 | break; |
|
103 | 103 | // |
|
104 | 104 | case TC_SUBTYPE_ENTER: |
|
105 | 105 | result = action_enter_mode( &TC, queue_snd_id ); |
|
106 | 106 | close_action( &TC, result, queue_snd_id ); |
|
107 | 107 | break; |
|
108 | 108 | // |
|
109 | 109 | case TC_SUBTYPE_UPDT_INFO: |
|
110 | 110 | result = action_update_info( &TC, queue_snd_id ); |
|
111 | 111 | close_action( &TC, result, queue_snd_id ); |
|
112 | 112 | break; |
|
113 | 113 | // |
|
114 | 114 | case TC_SUBTYPE_EN_CAL: |
|
115 | 115 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
116 | 116 | close_action( &TC, result, queue_snd_id ); |
|
117 | 117 | break; |
|
118 | 118 | // |
|
119 | 119 | case TC_SUBTYPE_DIS_CAL: |
|
120 | 120 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
121 | 121 | close_action( &TC, result, queue_snd_id ); |
|
122 | 122 | break; |
|
123 | 123 | // |
|
124 | 124 | case TC_SUBTYPE_UPDT_TIME: |
|
125 | 125 | result = action_update_time( &TC ); |
|
126 | 126 | close_action( &TC, result, queue_snd_id ); |
|
127 | 127 | break; |
|
128 | 128 | // |
|
129 | 129 | default: |
|
130 | 130 | break; |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | //*********** |
|
137 | 137 | // TC ACTIONS |
|
138 | 138 | |
|
139 | 139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | 140 | { |
|
141 | 141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | 142 | * |
|
143 | 143 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | 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 | 148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
149 | 149 | return LFR_DEFAULT; |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
153 | 153 | { |
|
154 | 154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
155 | 155 | * |
|
156 | 156 | * @param TC points to the TeleCommand packet that is being processed |
|
157 | 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 | 161 | rtems_status_code status; |
|
162 | 162 | unsigned char requestedMode; |
|
163 | 163 | unsigned int *transitionCoarseTime_ptr; |
|
164 | 164 | unsigned int transitionCoarseTime; |
|
165 | 165 | unsigned char * bytePosPtr; |
|
166 | 166 | |
|
167 | 167 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
168 | 168 | |
|
169 | 169 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
170 | 170 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
171 | 171 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
172 | 172 | |
|
173 | 173 | status = check_mode_value( requestedMode ); |
|
174 | 174 | |
|
175 | 175 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
176 | 176 | { |
|
177 | 177 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
178 | 178 | } |
|
179 | 179 | else // the mode value is consistent, check the transition |
|
180 | 180 | { |
|
181 | 181 | status = check_mode_transition(requestedMode); |
|
182 | 182 | if (status != LFR_SUCCESSFUL) |
|
183 | 183 | { |
|
184 | 184 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
185 | 185 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | |
|
189 | 189 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode |
|
190 | 190 | { |
|
191 | 191 | status = check_transition_date( transitionCoarseTime ); |
|
192 | 192 | if (status != LFR_SUCCESSFUL) |
|
193 | 193 | { |
|
194 | 194 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
195 | 195 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
196 | 196 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
197 | 197 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
198 | 198 | } |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
202 | 202 | { |
|
203 | 203 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
204 | 204 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | return status; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
211 | 211 | { |
|
212 | 212 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
213 | 213 | * |
|
214 | 214 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | 215 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
216 | 216 | * |
|
217 | 217 | * @return LFR directive status code: |
|
218 | 218 | * - LFR_DEFAULT |
|
219 | 219 | * - LFR_SUCCESSFUL |
|
220 | 220 | * |
|
221 | 221 | */ |
|
222 | 222 | |
|
223 | 223 | unsigned int val; |
|
224 | 224 | int result; |
|
225 | 225 | unsigned int status; |
|
226 | 226 | unsigned char mode; |
|
227 | 227 | unsigned char * bytePosPtr; |
|
228 | 228 | |
|
229 | 229 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
230 | 230 | |
|
231 | 231 | // check LFR mode |
|
232 | 232 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
233 | 233 | status = check_update_info_hk_lfr_mode( mode ); |
|
234 | 234 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
235 | 235 | { |
|
236 | 236 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
237 | 237 | status = check_update_info_hk_tds_mode( mode ); |
|
238 | 238 | } |
|
239 | 239 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
240 | 240 | { |
|
241 | 241 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
242 | 242 | status = check_update_info_hk_thr_mode( mode ); |
|
243 | 243 | } |
|
244 | 244 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
245 | 245 | { |
|
246 | 246 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
247 | 247 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
248 | 248 | val++; |
|
249 | 249 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
250 | 250 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
251 | 251 | } |
|
252 | 252 | |
|
253 | 253 | result = status; |
|
254 | 254 | |
|
255 | 255 | return result; |
|
256 | 256 | } |
|
257 | 257 | |
|
258 | 258 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
259 | 259 | { |
|
260 | 260 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
261 | 261 | * |
|
262 | 262 | * @param TC points to the TeleCommand packet that is being processed |
|
263 | 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 | 267 | int result; |
|
268 | 268 | unsigned char lfrMode; |
|
269 | 269 | |
|
270 | 270 | result = LFR_DEFAULT; |
|
271 | 271 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
272 | 272 | |
|
273 | 273 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
274 | 274 | result = LFR_DEFAULT; |
|
275 | 275 | |
|
276 | 276 | return result; |
|
277 | 277 | } |
|
278 | 278 | |
|
279 | 279 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
280 | 280 | { |
|
281 | 281 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
282 | 282 | * |
|
283 | 283 | * @param TC points to the TeleCommand packet that is being processed |
|
284 | 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 | 288 | int result; |
|
289 | 289 | unsigned char lfrMode; |
|
290 | 290 | |
|
291 | 291 | result = LFR_DEFAULT; |
|
292 | 292 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
293 | 293 | |
|
294 | 294 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
295 | 295 | result = LFR_DEFAULT; |
|
296 | 296 | |
|
297 | 297 | return result; |
|
298 | 298 | } |
|
299 | 299 | |
|
300 | 300 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
301 | 301 | { |
|
302 | 302 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
303 | 303 | * |
|
304 | 304 | * @param TC points to the TeleCommand packet that is being processed |
|
305 | 305 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
306 | 306 | * |
|
307 | 307 | * @return LFR_SUCCESSFUL |
|
308 | 308 | * |
|
309 | 309 | */ |
|
310 | 310 | |
|
311 | 311 | unsigned int val; |
|
312 | 312 | |
|
313 | 313 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
314 | 314 | + (TC->dataAndCRC[1] << 16) |
|
315 | 315 | + (TC->dataAndCRC[2] << 8) |
|
316 | 316 | + TC->dataAndCRC[3]; |
|
317 | 317 | |
|
318 | 318 | PRINTF1("time received: %x\n", time_management_regs->coarse_time_load) |
|
319 | 319 | |
|
320 | 320 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
321 | 321 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
322 | 322 | val++; |
|
323 | 323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
324 | 324 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
325 | 325 | // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick |
|
326 | 326 | |
|
327 | 327 | return LFR_SUCCESSFUL; |
|
328 | 328 | } |
|
329 | 329 | |
|
330 | 330 | //******************* |
|
331 | 331 | // ENTERING THE MODES |
|
332 | 332 | int check_mode_value( unsigned char requestedMode ) |
|
333 | 333 | { |
|
334 | 334 | int status; |
|
335 | 335 | |
|
336 | 336 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
337 | 337 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
338 | 338 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
339 | 339 | { |
|
340 | 340 | status = LFR_DEFAULT; |
|
341 | 341 | } |
|
342 | 342 | else |
|
343 | 343 | { |
|
344 | 344 | status = LFR_SUCCESSFUL; |
|
345 | 345 | } |
|
346 | 346 | |
|
347 | 347 | return status; |
|
348 | 348 | } |
|
349 | 349 | |
|
350 | 350 | int check_mode_transition( unsigned char requestedMode ) |
|
351 | 351 | { |
|
352 | 352 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
353 | 353 | * |
|
354 | 354 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
355 | 355 | * |
|
356 | 356 | * @return LFR directive status codes: |
|
357 | 357 | * - LFR_SUCCESSFUL - the transition is authorized |
|
358 | 358 | * - LFR_DEFAULT - the transition is not authorized |
|
359 | 359 | * |
|
360 | 360 | */ |
|
361 | 361 | |
|
362 | 362 | int status; |
|
363 | 363 | |
|
364 | 364 | switch (requestedMode) |
|
365 | 365 | { |
|
366 | 366 | case LFR_MODE_STANDBY: |
|
367 | 367 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
368 | 368 | status = LFR_DEFAULT; |
|
369 | 369 | } |
|
370 | 370 | else |
|
371 | 371 | { |
|
372 | 372 | status = LFR_SUCCESSFUL; |
|
373 | 373 | } |
|
374 | 374 | break; |
|
375 | 375 | case LFR_MODE_NORMAL: |
|
376 | 376 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
377 | 377 | status = LFR_DEFAULT; |
|
378 | 378 | } |
|
379 | 379 | else { |
|
380 | 380 | status = LFR_SUCCESSFUL; |
|
381 | 381 | } |
|
382 | 382 | break; |
|
383 | 383 | case LFR_MODE_BURST: |
|
384 | 384 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
385 | 385 | status = LFR_DEFAULT; |
|
386 | 386 | } |
|
387 | 387 | else { |
|
388 | 388 | status = LFR_SUCCESSFUL; |
|
389 | 389 | } |
|
390 | 390 | break; |
|
391 | 391 | case LFR_MODE_SBM1: |
|
392 | 392 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
393 | 393 | status = LFR_DEFAULT; |
|
394 | 394 | } |
|
395 | 395 | else { |
|
396 | 396 | status = LFR_SUCCESSFUL; |
|
397 | 397 | } |
|
398 | 398 | break; |
|
399 | 399 | case LFR_MODE_SBM2: |
|
400 | 400 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
401 | 401 | status = LFR_DEFAULT; |
|
402 | 402 | } |
|
403 | 403 | else { |
|
404 | 404 | status = LFR_SUCCESSFUL; |
|
405 | 405 | } |
|
406 | 406 | break; |
|
407 | 407 | default: |
|
408 | 408 | status = LFR_DEFAULT; |
|
409 | 409 | break; |
|
410 | 410 | } |
|
411 | 411 | |
|
412 | 412 | return status; |
|
413 | 413 | } |
|
414 | 414 | |
|
415 | 415 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
416 | 416 | { |
|
417 | 417 | int status; |
|
418 | 418 | unsigned int localCoarseTime; |
|
419 | 419 | unsigned int deltaCoarseTime; |
|
420 | 420 | |
|
421 | 421 | status = LFR_SUCCESSFUL; |
|
422 | 422 | |
|
423 | 423 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
424 | 424 | { |
|
425 | 425 | status = LFR_SUCCESSFUL; |
|
426 | 426 | } |
|
427 | 427 | else |
|
428 | 428 | { |
|
429 | 429 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
430 | 430 | |
|
431 | 431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
432 | 432 | { |
|
433 | 433 | status = LFR_DEFAULT; |
|
434 | 434 | PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime) |
|
435 | 435 | } |
|
436 | 436 | |
|
437 | 437 | if (status == LFR_SUCCESSFUL) |
|
438 | 438 | { |
|
439 | 439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
440 | 440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
441 | 441 | { |
|
442 | 442 | status = LFR_DEFAULT; |
|
443 | 443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
444 | 444 | } |
|
445 | 445 | } |
|
446 | 446 | } |
|
447 | 447 | |
|
448 | 448 | return status; |
|
449 | 449 | } |
|
450 | 450 | |
|
451 | 451 | int stop_current_mode( void ) |
|
452 | 452 | { |
|
453 | 453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
454 | 454 | * |
|
455 | 455 | * @return RTEMS directive status codes: |
|
456 | 456 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
457 | 457 | * - RTEMS_INVALID_ID - task id invalid |
|
458 | 458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
459 | 459 | * |
|
460 | 460 | */ |
|
461 | 461 | |
|
462 | 462 | rtems_status_code status; |
|
463 | 463 | |
|
464 | 464 | status = RTEMS_SUCCESSFUL; |
|
465 | 465 | |
|
466 | 466 | // (1) mask interruptions |
|
467 | 467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
468 | 468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
469 | 469 | |
|
470 | 470 | // (2) clear interruptions |
|
471 | 471 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
472 | 472 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
473 | 473 | |
|
474 | 474 | // (3) reset waveform picker registers |
|
475 | 475 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
476 | 476 | reset_wfp_status(); // reset all the status bits |
|
477 | 477 | |
|
478 | 478 | // (4) reset spectral matrices registers |
|
479 | 479 | set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices |
|
480 | 480 | set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 |
|
481 | 481 | reset_extractSWF(); // reset the extractSWF flag to false |
|
482 | 482 | |
|
483 | 483 | // <Spectral Matrices simulator> |
|
484 | 484 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
485 | 485 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
486 | 486 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
487 | 487 | // </Spectral Matrices simulator> |
|
488 | 488 | |
|
489 | 489 | // suspend several tasks |
|
490 | 490 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
491 | 491 | status = suspend_science_tasks(); |
|
492 | 492 | } |
|
493 | 493 | |
|
494 | 494 | if (status != RTEMS_SUCCESSFUL) |
|
495 | 495 | { |
|
496 | 496 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
497 | 497 | } |
|
498 | 498 | |
|
499 | 499 | return status; |
|
500 | 500 | } |
|
501 | 501 | |
|
502 | 502 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
503 | 503 | { |
|
504 | 504 | /** This function is launched after a mode transition validation. |
|
505 | 505 | * |
|
506 | 506 | * @param mode is the mode in which LFR will be put. |
|
507 | 507 | * |
|
508 | 508 | * @return RTEMS directive status codes: |
|
509 | 509 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
510 | 510 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
511 | 511 | * |
|
512 | 512 | */ |
|
513 | 513 | |
|
514 | 514 | rtems_status_code status; |
|
515 | 515 | |
|
516 | 516 | //********************** |
|
517 | 517 | // STOP THE CURRENT MODE |
|
518 | 518 | status = stop_current_mode(); |
|
519 | 519 | if (status != RTEMS_SUCCESSFUL) |
|
520 | 520 | { |
|
521 | 521 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
522 | 522 | } |
|
523 | 523 | |
|
524 | 524 | //************************* |
|
525 | 525 | // ENTER THE REQUESTED MODE |
|
526 | 526 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
527 | 527 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
528 | 528 | { |
|
529 | 529 | #ifdef PRINT_TASK_STATISTICS |
|
530 | 530 | rtems_cpu_usage_reset(); |
|
531 | 531 | maxCount = 0; |
|
532 | 532 | #endif |
|
533 | 533 | status = restart_science_tasks( mode ); |
|
534 | //**************** | |
|
535 | // WAVEFORM PICKER | |
|
534 | 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 | 542 | // launch_spectral_matrix_simu( ); |
|
543 | launch_spectral_matrix_spool( ); | |
|
537 | 544 | } |
|
538 | 545 | else if ( mode == LFR_MODE_STANDBY ) |
|
539 | 546 | { |
|
540 | 547 | #ifdef PRINT_TASK_STATISTICS |
|
541 | 548 | rtems_cpu_usage_report(); |
|
542 | 549 | #endif |
|
543 | 550 | |
|
544 | 551 | #ifdef PRINT_STACK_REPORT |
|
545 | 552 | PRINTF("stack report selected\n") |
|
546 | 553 | rtems_stack_checker_report_usage(); |
|
547 | 554 | #endif |
|
548 | 555 | PRINTF1("maxCount = %d\n", maxCount) |
|
549 | 556 | } |
|
550 | 557 | else |
|
551 | 558 | { |
|
552 | 559 | status = RTEMS_UNSATISFIED; |
|
553 | 560 | } |
|
554 | 561 | |
|
555 | 562 | if (status != RTEMS_SUCCESSFUL) |
|
556 | 563 | { |
|
557 | 564 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
558 | 565 | status = RTEMS_UNSATISFIED; |
|
559 | 566 | } |
|
560 | 567 | |
|
561 | 568 | return status; |
|
562 | 569 | } |
|
563 | 570 | |
|
564 | 571 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
565 | 572 | { |
|
566 | 573 | /** This function is used to restart all science tasks. |
|
567 | 574 | * |
|
568 | 575 | * @return RTEMS directive status codes: |
|
569 | 576 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
570 | 577 | * - RTEMS_INVALID_ID - task id invalid |
|
571 | 578 | * - RTEMS_INCORRECT_STATE - task never started |
|
572 | 579 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
573 | 580 | * |
|
574 | 581 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
575 | 582 | * |
|
576 | 583 | */ |
|
577 | 584 | |
|
578 |
rtems_status_code status[1 |
|
|
585 | rtems_status_code status[11]; | |
|
579 | 586 | rtems_status_code ret; |
|
580 | 587 | |
|
581 | 588 | ret = RTEMS_SUCCESSFUL; |
|
582 | 589 | |
|
583 | 590 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
584 | 591 | if (status[0] != RTEMS_SUCCESSFUL) |
|
585 | 592 | { |
|
586 | 593 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
587 | 594 | } |
|
588 | 595 | |
|
589 | 596 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
590 | 597 | if (status[1] != RTEMS_SUCCESSFUL) |
|
591 | 598 | { |
|
592 | 599 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
593 | 600 | } |
|
594 | 601 | |
|
595 | 602 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
596 | 603 | if (status[2] != RTEMS_SUCCESSFUL) |
|
597 | 604 | { |
|
598 | 605 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
599 | 606 | } |
|
600 | 607 | |
|
601 | 608 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
602 | 609 | if (status[3] != RTEMS_SUCCESSFUL) |
|
603 | 610 | { |
|
604 | 611 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
605 | 612 | } |
|
606 | 613 | |
|
607 | 614 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
608 | 615 | if (status[4] != RTEMS_SUCCESSFUL) |
|
609 | 616 | { |
|
610 | 617 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
611 | 618 | } |
|
612 | 619 | |
|
613 | 620 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
614 | 621 | if (status[5] != RTEMS_SUCCESSFUL) |
|
615 | 622 | { |
|
616 | 623 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
617 | 624 | } |
|
618 | 625 | |
|
619 | 626 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
620 | 627 | if (status[6] != RTEMS_SUCCESSFUL) |
|
621 | 628 | { |
|
622 | 629 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
623 | 630 | } |
|
624 | 631 | |
|
625 | 632 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
626 | 633 | if (status[7] != RTEMS_SUCCESSFUL) |
|
627 | 634 | { |
|
628 | 635 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
629 | 636 | } |
|
630 | 637 | |
|
631 | 638 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
632 | 639 | if (status[8] != RTEMS_SUCCESSFUL) |
|
633 | 640 | { |
|
634 | 641 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
635 | 642 | } |
|
636 | 643 | |
|
637 | 644 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
638 | 645 | if (status[9] != RTEMS_SUCCESSFUL) |
|
639 | 646 | { |
|
640 | 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 | 657 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
644 | 658 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
645 | 659 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
646 | 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 | 664 | ret = RTEMS_UNSATISFIED; |
|
650 | 665 | } |
|
651 | 666 | |
|
652 | 667 | return ret; |
|
653 | 668 | } |
|
654 | 669 | |
|
655 | 670 | int suspend_science_tasks() |
|
656 | 671 | { |
|
657 | 672 | /** This function suspends the science tasks. |
|
658 | 673 | * |
|
659 | 674 | * @return RTEMS directive status codes: |
|
660 | 675 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
661 | 676 | * - RTEMS_INVALID_ID - task id invalid |
|
662 | 677 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
663 | 678 | * |
|
664 | 679 | */ |
|
665 | 680 | |
|
666 | 681 | rtems_status_code status; |
|
667 | 682 | |
|
668 | 683 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
669 | 684 | if (status != RTEMS_SUCCESSFUL) |
|
670 | 685 | { |
|
671 | 686 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
672 | 687 | } |
|
673 | 688 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
674 | 689 | { |
|
675 | 690 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
676 | 691 | if (status != RTEMS_SUCCESSFUL) |
|
677 | 692 | { |
|
678 | 693 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
679 | 694 | } |
|
680 | 695 | } |
|
681 | 696 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
682 | 697 | { |
|
683 | 698 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
684 | 699 | if (status != RTEMS_SUCCESSFUL) |
|
685 | 700 | { |
|
686 | 701 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
687 | 702 | } |
|
688 | 703 | } |
|
689 | 704 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
690 | 705 | { |
|
691 | 706 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
692 | 707 | if (status != RTEMS_SUCCESSFUL) |
|
693 | 708 | { |
|
694 | 709 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
695 | 710 | } |
|
696 | 711 | } |
|
697 | 712 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
698 | 713 | { |
|
699 | 714 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
700 | 715 | if (status != RTEMS_SUCCESSFUL) |
|
701 | 716 | { |
|
702 | 717 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
703 | 718 | } |
|
704 | 719 | } |
|
705 | 720 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
706 | 721 | { |
|
707 | 722 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
708 | 723 | if (status != RTEMS_SUCCESSFUL) |
|
709 | 724 | { |
|
710 | 725 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
711 | 726 | } |
|
712 | 727 | } |
|
713 | 728 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
714 | 729 | { |
|
715 | 730 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
716 | 731 | if (status != RTEMS_SUCCESSFUL) |
|
717 | 732 | { |
|
718 | 733 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
719 | 734 | } |
|
720 | 735 | } |
|
721 | 736 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
722 | 737 | { |
|
723 | 738 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
724 | 739 | if (status != RTEMS_SUCCESSFUL) |
|
725 | 740 | { |
|
726 | 741 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
727 | 742 | } |
|
728 | 743 | } |
|
729 | 744 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
730 | 745 | { |
|
731 | 746 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
732 | 747 | if (status != RTEMS_SUCCESSFUL) |
|
733 | 748 | { |
|
734 | 749 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
735 | 750 | } |
|
736 | 751 | } |
|
737 | 752 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
738 | 753 | { |
|
739 | 754 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
740 | 755 | if (status != RTEMS_SUCCESSFUL) |
|
741 | 756 | { |
|
742 | 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 | 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 | 789 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
750 | 790 | { |
|
751 | 791 | WFP_reset_current_ring_nodes(); |
|
752 | 792 | reset_waveform_picker_regs(); |
|
753 | 793 | set_wfp_burst_enable_register( mode ); |
|
754 | 794 | |
|
755 | 795 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
756 | 796 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
757 | 797 | |
|
758 | 798 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] |
|
759 | 799 | if (transitionCoarseTime == 0) |
|
760 | 800 | { |
|
761 | 801 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
762 | 802 | } |
|
763 | 803 | else |
|
764 | 804 | { |
|
765 | 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 | 823 | void launch_spectral_matrix( void ) |
|
770 | 824 | { |
|
771 | 825 | SM_reset_current_ring_nodes(); |
|
772 | 826 | reset_spectral_matrix_regs(); |
|
773 | 827 | reset_nb_sm(); |
|
774 | 828 | |
|
775 | 829 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
776 | 830 | grgpio_regs->io_port_direction_register = |
|
777 | 831 | grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled |
|
778 | 832 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0 |
|
779 | 833 | set_irq_on_new_ready_matrix( 1 ); |
|
780 | 834 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
781 | 835 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
782 | 836 | set_run_matrix_spectral( 1 ); |
|
783 | 837 | } |
|
784 | 838 | |
|
785 | 839 | void launch_spectral_matrix_simu( void ) |
|
786 | 840 | { |
|
787 | 841 | SM_reset_current_ring_nodes(); |
|
788 | 842 | reset_spectral_matrix_regs(); |
|
789 | 843 | reset_nb_sm(); |
|
790 | 844 | |
|
791 | 845 | // Spectral Matrices simulator |
|
792 | 846 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
793 | 847 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
794 | 848 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
795 | 849 | } |
|
796 | 850 | |
|
797 | 851 | void set_irq_on_new_ready_matrix( unsigned char value ) |
|
798 | 852 | { |
|
799 | 853 | if (value == 1) |
|
800 | 854 | { |
|
801 | 855 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
802 | 856 | } |
|
803 | 857 | else |
|
804 | 858 | { |
|
805 | 859 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
806 | 860 | } |
|
807 | 861 | } |
|
808 | 862 | |
|
809 | 863 | void set_run_matrix_spectral( unsigned char value ) |
|
810 | 864 | { |
|
811 | 865 | if (value == 1) |
|
812 | 866 | { |
|
813 | 867 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1 |
|
814 | 868 | } |
|
815 | 869 | else |
|
816 | 870 | { |
|
817 | 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 | 876 | // CLOSING ACTIONS |
|
823 | 877 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
824 | 878 | { |
|
825 | 879 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
826 | 880 | * |
|
827 | 881 | * @param TC points to the TC being processed |
|
828 | 882 | * @param time is the time used to date the TC execution |
|
829 | 883 | * |
|
830 | 884 | */ |
|
831 | 885 | |
|
832 | 886 | unsigned int val; |
|
833 | 887 | |
|
834 | 888 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
835 | 889 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
836 | 890 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
837 | 891 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
838 | 892 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
839 | 893 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
840 | 894 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
841 | 895 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
842 | 896 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
843 | 897 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
844 | 898 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
845 | 899 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
846 | 900 | |
|
847 | 901 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
848 | 902 | val++; |
|
849 | 903 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
850 | 904 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
851 | 905 | } |
|
852 | 906 | |
|
853 | 907 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
854 | 908 | { |
|
855 | 909 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
856 | 910 | * |
|
857 | 911 | * @param TC points to the TC being processed |
|
858 | 912 | * @param time is the time used to date the TC rejection |
|
859 | 913 | * |
|
860 | 914 | */ |
|
861 | 915 | |
|
862 | 916 | unsigned int val; |
|
863 | 917 | |
|
864 | 918 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
865 | 919 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
866 | 920 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
867 | 921 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
868 | 922 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
869 | 923 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
870 | 924 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
871 | 925 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
872 | 926 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
873 | 927 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
874 | 928 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
875 | 929 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
876 | 930 | |
|
877 | 931 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
878 | 932 | val++; |
|
879 | 933 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
880 | 934 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
881 | 935 | } |
|
882 | 936 | |
|
883 | 937 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
884 | 938 | { |
|
885 | 939 | /** This function is the last step of the TC execution workflow. |
|
886 | 940 | * |
|
887 | 941 | * @param TC points to the TC being processed |
|
888 | 942 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
889 | 943 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
890 | 944 | * @param time is the time used to date the TC execution |
|
891 | 945 | * |
|
892 | 946 | */ |
|
893 | 947 | |
|
894 | 948 | unsigned char requestedMode; |
|
895 | 949 | |
|
896 | 950 | if (result == LFR_SUCCESSFUL) |
|
897 | 951 | { |
|
898 | 952 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
899 | 953 | & |
|
900 | 954 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
901 | 955 | ) |
|
902 | 956 | { |
|
903 | 957 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
904 | 958 | } |
|
905 | 959 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
906 | 960 | { |
|
907 | 961 | //********************************** |
|
908 | 962 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
909 | 963 | requestedMode = TC->dataAndCRC[1]; |
|
910 | 964 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
911 | 965 | updateLFRCurrentMode(); |
|
912 | 966 | } |
|
913 | 967 | } |
|
914 | 968 | else if (result == LFR_EXE_ERROR) |
|
915 | 969 | { |
|
916 | 970 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
917 | 971 | } |
|
918 | 972 | } |
|
919 | 973 | |
|
920 | 974 | //*************************** |
|
921 | 975 | // Interrupt Service Routines |
|
922 | 976 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
923 | 977 | { |
|
924 | 978 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
925 | 979 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
926 | 980 | } |
|
927 | 981 | } |
|
928 | 982 | |
|
929 | 983 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
930 | 984 | { |
|
931 | 985 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
932 | 986 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
933 | 987 | } |
|
934 | 988 | } |
|
935 | 989 | |
|
936 | 990 | //**************** |
|
937 | 991 | // OTHER FUNCTIONS |
|
938 | 992 | void updateLFRCurrentMode() |
|
939 | 993 | { |
|
940 | 994 | /** This function updates the value of the global variable lfrCurrentMode. |
|
941 | 995 | * |
|
942 | 996 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
943 | 997 | * |
|
944 | 998 | */ |
|
945 | 999 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
946 | 1000 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
947 | 1001 | } |
|
948 | 1002 |
@@ -1,1310 +1,1457 | |||
|
1 | 1 | /** Functions and tasks related to waveform packet generation. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "wf_handler.h" |
|
11 | 11 | |
|
12 | 12 | //***************** |
|
13 | 13 | // waveform headers |
|
14 | 14 | // SWF |
|
15 | 15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
16 | 16 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
17 | 17 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
18 | 18 | // CWF |
|
19 | 19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
20 | 20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
21 | 21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
22 | 22 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
23 | 23 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ]; |
|
24 | 24 | |
|
25 | 25 | //************** |
|
26 | 26 | // waveform ring |
|
27 | 27 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
28 | 28 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
29 | 29 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
30 | 30 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; |
|
31 | 31 | ring_node *current_ring_node_f0; |
|
32 | 32 | ring_node *ring_node_to_send_swf_f0; |
|
33 | 33 | ring_node *current_ring_node_f1; |
|
34 | 34 | ring_node *ring_node_to_send_swf_f1; |
|
35 | 35 | ring_node *ring_node_to_send_cwf_f1; |
|
36 | 36 | ring_node *current_ring_node_f2; |
|
37 | 37 | ring_node *ring_node_to_send_swf_f2; |
|
38 | 38 | ring_node *ring_node_to_send_cwf_f2; |
|
39 | 39 | ring_node *current_ring_node_f3; |
|
40 | 40 | ring_node *ring_node_to_send_cwf_f3; |
|
41 | 41 | |
|
42 | 42 | bool extractSWF = false; |
|
43 | 43 | bool swf_f0_ready = false; |
|
44 | 44 | bool swf_f1_ready = false; |
|
45 | 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 | 53 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
48 | 54 | |
|
49 | 55 | //********************* |
|
50 | 56 | // Interrupt SubRoutine |
|
51 | 57 | |
|
52 | 58 | void reset_extractSWF( void ) |
|
53 | 59 | { |
|
54 | 60 | extractSWF = false; |
|
55 | 61 | swf_f0_ready = false; |
|
56 | 62 | swf_f1_ready = false; |
|
57 | 63 | swf_f2_ready = false; |
|
58 | 64 | } |
|
59 | 65 | |
|
60 | 66 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
61 | 67 | { |
|
62 | 68 | /** This is the interrupt sub routine called by the waveform picker core. |
|
63 | 69 | * |
|
64 | 70 | * This ISR launch different actions depending mainly on two pieces of information: |
|
65 | 71 | * 1. the values read in the registers of the waveform picker. |
|
66 | 72 | * 2. the current LFR mode. |
|
67 | 73 | * |
|
68 | 74 | */ |
|
69 | 75 | |
|
70 | 76 | rtems_status_code status; |
|
71 | 77 | |
|
72 | 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 | 79 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
74 | 80 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
75 | 81 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
76 | 82 | // (1) change the receiving buffer for the waveform picker |
|
77 | 83 | ring_node_to_send_cwf_f3 = current_ring_node_f3; |
|
78 | 84 | current_ring_node_f3 = current_ring_node_f3->next; |
|
79 | 85 | waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; |
|
80 | 86 | // (2) send an event for the waveforms transmission |
|
81 | 87 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
82 | 88 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
83 | 89 | } |
|
84 | 90 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2); |
|
85 | 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 | 95 | switch(lfrCurrentMode) |
|
90 | 96 | { |
|
91 | 97 | //******** |
|
92 | 98 | // STANDBY |
|
93 | 99 | case(LFR_MODE_STANDBY): |
|
94 | 100 | break; |
|
95 | 101 | |
|
96 | 102 | //****** |
|
97 | 103 | // NORMAL |
|
98 | 104 | case(LFR_MODE_NORMAL): |
|
99 | 105 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
100 | 106 | { |
|
101 | 107 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
102 | 108 | } |
|
103 | 109 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits |
|
104 | 110 | { |
|
105 | 111 | // change F0 ring node |
|
106 | 112 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
107 | 113 | current_ring_node_f0 = current_ring_node_f0->next; |
|
108 | 114 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
109 | 115 | // change F1 ring node |
|
110 | 116 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
111 | 117 | current_ring_node_f1 = current_ring_node_f1->next; |
|
112 | 118 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
113 | 119 | // change F2 ring node |
|
114 | 120 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
115 | 121 | current_ring_node_f2 = current_ring_node_f2->next; |
|
116 | 122 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
117 | 123 | // |
|
118 | 124 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) |
|
119 | 125 | { |
|
120 | 126 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
121 | 127 | } |
|
122 | 128 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] |
|
123 | 129 | } |
|
124 | 130 | break; |
|
125 | 131 | |
|
126 | 132 | //****** |
|
127 | 133 | // BURST |
|
128 | 134 | case(LFR_MODE_BURST): |
|
129 | 135 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
130 | 136 | // (1) change the receiving buffer for the waveform picker |
|
131 | 137 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
132 | 138 | current_ring_node_f2 = current_ring_node_f2->next; |
|
133 | 139 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
134 | 140 | // (2) send an event for the waveforms transmission |
|
135 | 141 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
136 | 142 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
137 | 143 | } |
|
138 | 144 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
139 | 145 | } |
|
140 | 146 | break; |
|
141 | 147 | |
|
142 | 148 | //***** |
|
143 | 149 | // SBM1 |
|
144 | 150 | case(LFR_MODE_SBM1): |
|
145 | 151 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
146 | 152 | // (1) change the receiving buffer for the waveform picker |
|
147 | 153 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
148 | 154 | current_ring_node_f1 = current_ring_node_f1->next; |
|
149 | 155 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
150 | 156 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
151 | 157 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
152 | 158 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 |
|
153 | 159 | } |
|
154 | 160 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
155 | 161 | swf_f0_ready = true; |
|
156 | 162 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
157 | 163 | } |
|
158 | 164 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
159 | 165 | swf_f2_ready = true; |
|
160 | 166 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
161 | 167 | } |
|
162 | 168 | break; |
|
163 | 169 | |
|
164 | 170 | //***** |
|
165 | 171 | // SBM2 |
|
166 | 172 | case(LFR_MODE_SBM2): |
|
167 | 173 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
168 | 174 | // (1) change the receiving buffer for the waveform picker |
|
169 | 175 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
170 | 176 | current_ring_node_f2 = current_ring_node_f2->next; |
|
171 | 177 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
172 | 178 | // (2) send an event for the waveforms transmission |
|
173 | 179 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
174 | 180 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
175 | 181 | } |
|
176 | 182 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
177 | 183 | swf_f0_ready = true; |
|
178 | 184 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
179 | 185 | } |
|
180 | 186 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
181 | 187 | swf_f1_ready = true; |
|
182 | 188 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0 |
|
183 | 189 | } |
|
184 | 190 | break; |
|
185 | 191 | |
|
186 | 192 | //******** |
|
187 | 193 | // DEFAULT |
|
188 | 194 | default: |
|
189 | 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 | 329 | // RTEMS TASKS |
|
195 | 330 | |
|
196 | 331 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
197 | 332 | { |
|
198 | 333 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
199 | 334 | * |
|
200 | 335 | * @param unused is the starting argument of the RTEMS task |
|
201 | 336 | * |
|
202 | 337 | * The following data packets are sent by this task: |
|
203 | 338 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
204 | 339 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
205 | 340 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
206 | 341 | * |
|
207 | 342 | */ |
|
208 | 343 | |
|
209 | 344 | rtems_event_set event_out; |
|
210 | 345 | rtems_id queue_id; |
|
211 | 346 | rtems_status_code status; |
|
212 | 347 | |
|
213 | 348 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
214 | 349 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
215 | 350 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
216 | 351 | |
|
217 | 352 | status = get_message_queue_id_send( &queue_id ); |
|
218 | 353 | if (status != RTEMS_SUCCESSFUL) |
|
219 | 354 | { |
|
220 | 355 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
221 | 356 | } |
|
222 | 357 | |
|
223 | 358 | BOOT_PRINTF("in WFRM ***\n") |
|
224 | 359 | |
|
225 | 360 | while(1){ |
|
226 | 361 | // wait for an RTEMS_EVENT |
|
227 | 362 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
228 | 363 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
229 | 364 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
230 | 365 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
231 | 366 | { |
|
232 | 367 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
233 | 368 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
234 | 369 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
235 | 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 | 372 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
238 | 373 | { |
|
239 | 374 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
240 | 375 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
241 | 376 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
242 | 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 | 379 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
245 | 380 | { |
|
246 | 381 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
247 | 382 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
248 | 383 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
249 | 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 | 389 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
255 | 390 | { |
|
256 | 391 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
257 | 392 | * |
|
258 | 393 | * @param unused is the starting argument of the RTEMS task |
|
259 | 394 | * |
|
260 | 395 | * The following data packet is sent by this task: |
|
261 | 396 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
262 | 397 | * |
|
263 | 398 | */ |
|
264 | 399 | |
|
265 | 400 | rtems_event_set event_out; |
|
266 | 401 | rtems_id queue_id; |
|
267 | 402 | rtems_status_code status; |
|
268 | 403 | |
|
269 | 404 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); |
|
270 | 405 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); |
|
271 | 406 | |
|
272 | 407 | status = get_message_queue_id_send( &queue_id ); |
|
273 | 408 | if (status != RTEMS_SUCCESSFUL) |
|
274 | 409 | { |
|
275 | 410 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
276 | 411 | } |
|
277 | 412 | |
|
278 | 413 | BOOT_PRINTF("in CWF3 ***\n") |
|
279 | 414 | |
|
280 | 415 | while(1){ |
|
281 | 416 | // wait for an RTEMS_EVENT |
|
282 | 417 | rtems_event_receive( RTEMS_EVENT_0, |
|
283 | 418 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
284 | 419 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
285 | 420 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
286 | 421 | { |
|
287 | 422 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
288 | 423 | { |
|
289 | 424 | PRINTF("send CWF_LONG_F3\n") |
|
290 | 425 | send_waveform_CWF( |
|
291 | 426 | (volatile int*) ring_node_to_send_cwf_f3->buffer_address, |
|
292 | 427 | SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
293 | 428 | } |
|
294 | 429 | else |
|
295 | 430 | { |
|
296 | 431 | PRINTF("send CWF_F3 (light)\n") |
|
297 | 432 | send_waveform_CWF3_light( |
|
298 | 433 | (volatile int*) ring_node_to_send_cwf_f3->buffer_address, |
|
299 | 434 | headerCWF_F3_light, queue_id ); |
|
300 | 435 | } |
|
301 | 436 | |
|
302 | 437 | } |
|
303 | 438 | else |
|
304 | 439 | { |
|
305 | 440 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
306 | 441 | } |
|
307 | 442 | } |
|
308 | 443 | } |
|
309 | 444 | |
|
310 | 445 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
311 | 446 | { |
|
312 | 447 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
313 | 448 | * |
|
314 | 449 | * @param unused is the starting argument of the RTEMS task |
|
315 | 450 | * |
|
316 | 451 | * The following data packet is sent by this function: |
|
317 | 452 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
318 | 453 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
319 | 454 | * |
|
320 | 455 | */ |
|
321 | 456 | |
|
322 | 457 | rtems_event_set event_out; |
|
323 | 458 | rtems_id queue_id; |
|
324 | 459 | rtems_status_code status; |
|
325 | 460 | |
|
326 | 461 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
327 | 462 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
328 | 463 | |
|
329 | 464 | status = get_message_queue_id_send( &queue_id ); |
|
330 | 465 | if (status != RTEMS_SUCCESSFUL) |
|
331 | 466 | { |
|
332 | 467 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
333 | 468 | } |
|
334 | 469 | |
|
335 | 470 | BOOT_PRINTF("in CWF2 ***\n") |
|
336 | 471 | |
|
337 | 472 | while(1){ |
|
338 | 473 | // wait for an RTEMS_EVENT |
|
339 | 474 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
340 | 475 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
341 | 476 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
342 | 477 | { |
|
343 | 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 | 480 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
346 | 481 | { |
|
347 | 482 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
348 | 483 | // launch snapshot extraction if needed |
|
349 | 484 | if (extractSWF == true) |
|
350 | 485 | { |
|
351 | 486 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
352 | 487 | // extract the snapshot |
|
353 | 488 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); |
|
354 | 489 | // send the snapshot when built |
|
355 | 490 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
356 | 491 | extractSWF = false; |
|
357 | 492 | } |
|
358 | 493 | if (swf_f0_ready && swf_f1_ready) |
|
359 | 494 | { |
|
360 | 495 | extractSWF = true; |
|
361 | 496 | swf_f0_ready = false; |
|
362 | 497 | swf_f1_ready = false; |
|
363 | 498 | } |
|
364 | 499 | } |
|
365 | 500 | } |
|
366 | 501 | } |
|
367 | 502 | |
|
368 | 503 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
369 | 504 | { |
|
370 | 505 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
371 | 506 | * |
|
372 | 507 | * @param unused is the starting argument of the RTEMS task |
|
373 | 508 | * |
|
374 | 509 | * The following data packet is sent by this function: |
|
375 | 510 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
376 | 511 | * |
|
377 | 512 | */ |
|
378 | 513 | |
|
379 | 514 | rtems_event_set event_out; |
|
380 | 515 | rtems_id queue_id; |
|
381 | 516 | rtems_status_code status; |
|
517 | rtems_interrupt_level level = 0; | |
|
382 | 518 | |
|
383 | 519 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
384 | 520 | |
|
385 | 521 | status = get_message_queue_id_send( &queue_id ); |
|
386 | 522 | if (status != RTEMS_SUCCESSFUL) |
|
387 | 523 | { |
|
388 | 524 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
389 | 525 | } |
|
390 | 526 | |
|
391 | 527 | BOOT_PRINTF("in CWF1 ***\n") |
|
392 | 528 | |
|
529 | printf("(0) level = %x\n", (unsigned int) level); | |
|
530 | ||
|
393 | 531 | while(1){ |
|
394 | 532 | // wait for an RTEMS_EVENT |
|
395 | 533 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
396 | 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 | 540 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
398 | 541 | // launch snapshot extraction if needed |
|
399 | 542 | if (extractSWF == true) |
|
400 | 543 | { |
|
401 | 544 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1; |
|
402 | 545 | // launch the snapshot extraction |
|
403 | 546 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
404 | 547 | extractSWF = false; |
|
405 | 548 | } |
|
406 | 549 | if (swf_f0_ready == true) |
|
407 | 550 | { |
|
408 | 551 | extractSWF = true; |
|
409 | 552 | swf_f0_ready = false; // this step shall be executed only one time |
|
410 | 553 | } |
|
411 | 554 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
412 | 555 | { |
|
413 | 556 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
414 | 557 | swf_f1_ready = false; |
|
415 | 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 | 567 | rtems_task swbd_task(rtems_task_argument argument) |
|
421 | 568 | { |
|
422 | 569 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
423 | 570 | * |
|
424 | 571 | * @param unused is the starting argument of the RTEMS task |
|
425 | 572 | * |
|
426 | 573 | */ |
|
427 | 574 | |
|
428 | 575 | rtems_event_set event_out; |
|
429 | 576 | |
|
430 | 577 | BOOT_PRINTF("in SWBD ***\n") |
|
431 | 578 | |
|
432 | 579 | while(1){ |
|
433 | 580 | // wait for an RTEMS_EVENT |
|
434 | 581 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
435 | 582 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
436 | 583 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
437 | 584 | { |
|
438 | 585 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 ); |
|
439 | 586 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
440 | 587 | } |
|
441 | 588 | else |
|
442 | 589 | { |
|
443 | 590 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
444 | 591 | } |
|
445 | 592 | } |
|
446 | 593 | } |
|
447 | 594 | |
|
448 | 595 | //****************** |
|
449 | 596 | // general functions |
|
450 | 597 | |
|
451 | 598 | void WFP_init_rings( void ) |
|
452 | 599 | { |
|
453 | 600 | // F0 RING |
|
454 | 601 | init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 ); |
|
455 | 602 | // F1 RING |
|
456 | 603 | init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 ); |
|
457 | 604 | // F2 RING |
|
458 | 605 | init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 ); |
|
459 | 606 | // F3 RING |
|
460 | 607 | init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 ); |
|
461 | 608 | |
|
462 | 609 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
463 | 610 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
464 | 611 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
465 | 612 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
466 | 613 | } |
|
467 | 614 | |
|
468 | 615 | void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] ) |
|
469 | 616 | { |
|
470 | 617 | unsigned char i; |
|
471 | 618 | |
|
472 | 619 | waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ]; |
|
473 | 620 | waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ]; |
|
474 | 621 | waveform_ring[0].buffer_address = (int) &wfrm[0]; |
|
475 | 622 | |
|
476 | 623 | waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ]; |
|
477 | 624 | waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ]; |
|
478 | 625 | waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ]; |
|
479 | 626 | |
|
480 | 627 | for(i=1; i<nbNodes-1; i++) |
|
481 | 628 | { |
|
482 | 629 | waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ]; |
|
483 | 630 | waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ]; |
|
484 | 631 | waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ]; |
|
485 | 632 | } |
|
486 | 633 | } |
|
487 | 634 | |
|
488 | 635 | void WFP_reset_current_ring_nodes( void ) |
|
489 | 636 | { |
|
490 | 637 | current_ring_node_f0 = waveform_ring_f0; |
|
491 | 638 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
492 | 639 | |
|
493 | 640 | current_ring_node_f1 = waveform_ring_f1; |
|
494 | 641 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
495 | 642 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
496 | 643 | |
|
497 | 644 | current_ring_node_f2 = waveform_ring_f2; |
|
498 | 645 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
499 | 646 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
500 | 647 | |
|
501 | 648 | current_ring_node_f3 = waveform_ring_f3; |
|
502 | 649 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
503 | 650 | } |
|
504 | 651 | |
|
505 | 652 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
506 | 653 | { |
|
507 | 654 | unsigned char i; |
|
508 | 655 | |
|
509 | 656 | for (i=0; i<7; i++) |
|
510 | 657 | { |
|
511 | 658 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
512 | 659 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
513 | 660 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
514 | 661 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
515 | 662 | headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
516 | 663 | headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
517 | 664 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
518 | 665 | if (i == 6) |
|
519 | 666 | { |
|
520 | 667 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
521 | 668 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
522 | 669 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
523 | 670 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
524 | 671 | } |
|
525 | 672 | else |
|
526 | 673 | { |
|
527 | 674 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
528 | 675 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
529 | 676 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
530 | 677 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
531 | 678 | } |
|
532 | 679 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
533 | 680 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
534 | 681 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
535 | 682 | // DATA FIELD HEADER |
|
536 | 683 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
537 | 684 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
538 | 685 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
539 | 686 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
540 | 687 | // AUXILIARY DATA HEADER |
|
541 | 688 | headerSWF[ i ].time[0] = 0x00; |
|
542 | 689 | headerSWF[ i ].time[0] = 0x00; |
|
543 | 690 | headerSWF[ i ].time[0] = 0x00; |
|
544 | 691 | headerSWF[ i ].time[0] = 0x00; |
|
545 | 692 | headerSWF[ i ].time[0] = 0x00; |
|
546 | 693 | headerSWF[ i ].time[0] = 0x00; |
|
547 | 694 | headerSWF[ i ].sid = sid; |
|
548 | 695 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
549 | 696 | } |
|
550 | 697 | return LFR_SUCCESSFUL; |
|
551 | 698 | } |
|
552 | 699 | |
|
553 | 700 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
554 | 701 | { |
|
555 | 702 | unsigned int i; |
|
556 | 703 | |
|
557 | 704 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) |
|
558 | 705 | { |
|
559 | 706 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
560 | 707 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
561 | 708 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
562 | 709 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
563 | 710 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
564 | 711 | { |
|
565 | 712 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
566 | 713 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
567 | 714 | } |
|
568 | 715 | else |
|
569 | 716 | { |
|
570 | 717 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
571 | 718 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
572 | 719 | } |
|
573 | 720 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
574 | 721 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
575 | 722 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
576 | 723 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
577 | 724 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
578 | 725 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
579 | 726 | // DATA FIELD HEADER |
|
580 | 727 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
581 | 728 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
582 | 729 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
583 | 730 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
584 | 731 | // AUXILIARY DATA HEADER |
|
585 | 732 | headerCWF[ i ].sid = sid; |
|
586 | 733 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
587 | 734 | headerCWF[ i ].time[0] = 0x00; |
|
588 | 735 | headerCWF[ i ].time[0] = 0x00; |
|
589 | 736 | headerCWF[ i ].time[0] = 0x00; |
|
590 | 737 | headerCWF[ i ].time[0] = 0x00; |
|
591 | 738 | headerCWF[ i ].time[0] = 0x00; |
|
592 | 739 | headerCWF[ i ].time[0] = 0x00; |
|
593 | 740 | } |
|
594 | 741 | return LFR_SUCCESSFUL; |
|
595 | 742 | } |
|
596 | 743 | |
|
597 | 744 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
598 | 745 | { |
|
599 | 746 | unsigned int i; |
|
600 | 747 | |
|
601 | 748 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) |
|
602 | 749 | { |
|
603 | 750 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
604 | 751 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
605 | 752 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
606 | 753 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
607 | 754 | |
|
608 | 755 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
609 | 756 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
610 | 757 | |
|
611 | 758 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
612 | 759 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
613 | 760 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
614 | 761 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
615 | 762 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
616 | 763 | |
|
617 | 764 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
618 | 765 | // DATA FIELD HEADER |
|
619 | 766 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
620 | 767 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
621 | 768 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
622 | 769 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
623 | 770 | // AUXILIARY DATA HEADER |
|
624 | 771 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
625 | 772 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
626 | 773 | headerCWF[ i ].time[0] = 0x00; |
|
627 | 774 | headerCWF[ i ].time[0] = 0x00; |
|
628 | 775 | headerCWF[ i ].time[0] = 0x00; |
|
629 | 776 | headerCWF[ i ].time[0] = 0x00; |
|
630 | 777 | headerCWF[ i ].time[0] = 0x00; |
|
631 | 778 | headerCWF[ i ].time[0] = 0x00; |
|
632 | 779 | } |
|
633 | 780 | return LFR_SUCCESSFUL; |
|
634 | 781 | } |
|
635 | 782 | |
|
636 | 783 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
637 | 784 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
638 | 785 | { |
|
639 | 786 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
640 | 787 | * |
|
641 | 788 | * @param waveform points to the buffer containing the data that will be send. |
|
642 | 789 | * @param sid is the source identifier of the data that will be sent. |
|
643 | 790 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
644 | 791 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
645 | 792 | * contain information to setup the transmission of the data packets. |
|
646 | 793 | * |
|
647 | 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 | 798 | unsigned int i; |
|
652 | 799 | int ret; |
|
653 | 800 | unsigned int coarseTime; |
|
654 | 801 | unsigned int fineTime; |
|
655 | 802 | rtems_status_code status; |
|
656 | 803 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
657 | 804 | |
|
658 | 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 | 806 | spw_ioctl_send_SWF.options = 0; |
|
660 | 807 | |
|
661 | 808 | ret = LFR_DEFAULT; |
|
662 | 809 | |
|
663 | 810 | coarseTime = waveform[0]; |
|
664 | 811 | fineTime = waveform[1]; |
|
665 | 812 | |
|
666 | 813 | for (i=0; i<7; i++) // send waveform |
|
667 | 814 | { |
|
668 | 815 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
669 | 816 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
670 | 817 | // BUILD THE DATA |
|
671 | 818 | if (i==6) { |
|
672 | 819 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
673 | 820 | } |
|
674 | 821 | else { |
|
675 | 822 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
676 | 823 | } |
|
677 | 824 | // SET PACKET SEQUENCE COUNTER |
|
678 | 825 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
679 | 826 | // SET PACKET TIME |
|
680 | 827 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); |
|
681 | 828 | // |
|
682 | 829 | headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0]; |
|
683 | 830 | headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1]; |
|
684 | 831 | headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2]; |
|
685 | 832 | headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3]; |
|
686 | 833 | headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4]; |
|
687 | 834 | headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5]; |
|
688 | 835 | // SEND PACKET |
|
689 | 836 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
690 | 837 | if (status != RTEMS_SUCCESSFUL) { |
|
691 | 838 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
692 | 839 | ret = LFR_DEFAULT; |
|
693 | 840 | } |
|
694 | 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 | 844 | return ret; |
|
698 | 845 | } |
|
699 | 846 | |
|
700 | 847 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
701 | 848 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
702 | 849 | { |
|
703 | 850 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
704 | 851 | * |
|
705 | 852 | * @param waveform points to the buffer containing the data that will be send. |
|
706 | 853 | * @param sid is the source identifier of the data that will be sent. |
|
707 | 854 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
708 | 855 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
709 | 856 | * contain information to setup the transmission of the data packets. |
|
710 | 857 | * |
|
711 | 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 | 862 | unsigned int i; |
|
716 | 863 | int ret; |
|
717 | 864 | unsigned int coarseTime; |
|
718 | 865 | unsigned int fineTime; |
|
719 | 866 | rtems_status_code status; |
|
720 | 867 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
721 | 868 | |
|
722 | 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 | 870 | spw_ioctl_send_CWF.options = 0; |
|
724 | 871 | |
|
725 | 872 | ret = LFR_DEFAULT; |
|
726 | 873 | |
|
727 | 874 | coarseTime = waveform[0]; |
|
728 | 875 | fineTime = waveform[1]; |
|
729 | 876 | |
|
730 | 877 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
731 | 878 | { |
|
732 | 879 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
733 | 880 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
734 | 881 | // BUILD THE DATA |
|
735 | 882 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
736 | 883 | // SET PACKET SEQUENCE COUNTER |
|
737 | 884 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
738 | 885 | // SET PACKET TIME |
|
739 | 886 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); |
|
740 | 887 | // |
|
741 | 888 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
742 | 889 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
743 | 890 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
744 | 891 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
745 | 892 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
746 | 893 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
747 | 894 | // SEND PACKET |
|
748 | 895 | if (sid == SID_NORM_CWF_LONG_F3) |
|
749 | 896 | { |
|
750 | 897 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
751 | 898 | if (status != RTEMS_SUCCESSFUL) { |
|
752 | 899 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
753 | 900 | ret = LFR_DEFAULT; |
|
754 | 901 | } |
|
755 | 902 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
756 | 903 | } |
|
757 | 904 | else |
|
758 | 905 | { |
|
759 | 906 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
760 | 907 | if (status != RTEMS_SUCCESSFUL) { |
|
761 | 908 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
762 | 909 | ret = LFR_DEFAULT; |
|
763 | 910 | } |
|
764 | 911 | } |
|
765 | 912 | } |
|
766 | 913 | |
|
767 | 914 | return ret; |
|
768 | 915 | } |
|
769 | 916 | |
|
770 | 917 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
771 | 918 | { |
|
772 | 919 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
773 | 920 | * |
|
774 | 921 | * @param waveform points to the buffer containing the data that will be send. |
|
775 | 922 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
776 | 923 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
777 | 924 | * contain information to setup the transmission of the data packets. |
|
778 | 925 | * |
|
779 | 926 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
780 | 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 | 931 | unsigned int i; |
|
785 | 932 | int ret; |
|
786 | 933 | unsigned int coarseTime; |
|
787 | 934 | unsigned int fineTime; |
|
788 | 935 | rtems_status_code status; |
|
789 | 936 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
790 | 937 | char *sample; |
|
791 | 938 | |
|
792 | 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 | 940 | spw_ioctl_send_CWF.options = 0; |
|
794 | 941 | |
|
795 | 942 | ret = LFR_DEFAULT; |
|
796 | 943 | |
|
797 | 944 | //********************** |
|
798 | 945 | // BUILD CWF3_light DATA |
|
799 | 946 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
800 | 947 | { |
|
801 | 948 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
802 | 949 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; |
|
803 | 950 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; |
|
804 | 951 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; |
|
805 | 952 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; |
|
806 | 953 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; |
|
807 | 954 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; |
|
808 | 955 | } |
|
809 | 956 | |
|
810 | 957 | coarseTime = waveform[0]; |
|
811 | 958 | fineTime = waveform[1]; |
|
812 | 959 | |
|
813 | 960 | //********************* |
|
814 | 961 | // SEND CWF3_light DATA |
|
815 | 962 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
816 | 963 | { |
|
817 | 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 | 965 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
819 | 966 | // BUILD THE DATA |
|
820 | 967 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
821 | 968 | // SET PACKET SEQUENCE COUNTER |
|
822 | 969 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
823 | 970 | // SET PACKET TIME |
|
824 | 971 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); |
|
825 | 972 | // |
|
826 | 973 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
827 | 974 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
828 | 975 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
829 | 976 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
830 | 977 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
831 | 978 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
832 | 979 | // SEND PACKET |
|
833 | 980 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
834 | 981 | if (status != RTEMS_SUCCESSFUL) { |
|
835 | 982 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
836 | 983 | ret = LFR_DEFAULT; |
|
837 | 984 | } |
|
838 | 985 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
839 | 986 | } |
|
840 | 987 | |
|
841 | 988 | return ret; |
|
842 | 989 | } |
|
843 | 990 | |
|
844 | 991 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
845 | 992 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
846 | 993 | { |
|
847 | 994 | unsigned long long int acquisitionTimeAsLong; |
|
848 | 995 | unsigned char localAcquisitionTime[6]; |
|
849 | 996 | double deltaT; |
|
850 | 997 | |
|
851 | 998 | deltaT = 0.; |
|
852 | 999 | |
|
853 | 1000 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
854 | 1001 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
855 | 1002 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
856 | 1003 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
857 | 1004 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
858 | 1005 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
859 | 1006 | |
|
860 | 1007 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
861 | 1008 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
862 | 1009 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
863 | 1010 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
864 | 1011 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
865 | 1012 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
866 | 1013 | |
|
867 | 1014 | switch( sid ) |
|
868 | 1015 | { |
|
869 | 1016 | case SID_NORM_SWF_F0: |
|
870 | 1017 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
871 | 1018 | break; |
|
872 | 1019 | |
|
873 | 1020 | case SID_NORM_SWF_F1: |
|
874 | 1021 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
875 | 1022 | break; |
|
876 | 1023 | |
|
877 | 1024 | case SID_NORM_SWF_F2: |
|
878 | 1025 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
879 | 1026 | break; |
|
880 | 1027 | |
|
881 | 1028 | case SID_SBM1_CWF_F1: |
|
882 | 1029 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
883 | 1030 | break; |
|
884 | 1031 | |
|
885 | 1032 | case SID_SBM2_CWF_F2: |
|
886 | 1033 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
887 | 1034 | break; |
|
888 | 1035 | |
|
889 | 1036 | case SID_BURST_CWF_F2: |
|
890 | 1037 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
891 | 1038 | break; |
|
892 | 1039 | |
|
893 | 1040 | case SID_NORM_CWF_F3: |
|
894 | 1041 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
895 | 1042 | break; |
|
896 | 1043 | |
|
897 | 1044 | case SID_NORM_CWF_LONG_F3: |
|
898 | 1045 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
899 | 1046 | break; |
|
900 | 1047 | |
|
901 | 1048 | default: |
|
902 | 1049 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid) |
|
903 | 1050 | deltaT = 0.; |
|
904 | 1051 | break; |
|
905 | 1052 | } |
|
906 | 1053 | |
|
907 | 1054 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
908 | 1055 | // |
|
909 | 1056 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
910 | 1057 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
911 | 1058 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
912 | 1059 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
913 | 1060 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
914 | 1061 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
915 | 1062 | |
|
916 | 1063 | } |
|
917 | 1064 | |
|
918 | 1065 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel ) |
|
919 | 1066 | { |
|
920 | 1067 | unsigned int i; |
|
921 | 1068 | unsigned long long int centerTime_asLong; |
|
922 | 1069 | unsigned long long int acquisitionTimeF0_asLong; |
|
923 | 1070 | unsigned long long int acquisitionTime_asLong; |
|
924 | 1071 | unsigned long long int bufferAcquisitionTime_asLong; |
|
925 | 1072 | unsigned char *ptr1; |
|
926 | 1073 | unsigned char *ptr2; |
|
927 | 1074 | unsigned char *timeCharPtr; |
|
928 | 1075 | unsigned char nb_ring_nodes; |
|
929 | 1076 | unsigned long long int frequency_asLong; |
|
930 | 1077 | unsigned long long int nbTicksPerSample_asLong; |
|
931 | 1078 | unsigned long long int nbSamplesPart1_asLong; |
|
932 | 1079 | unsigned long long int sampleOffset_asLong; |
|
933 | 1080 | |
|
934 | 1081 | unsigned int deltaT_F0; |
|
935 | 1082 | unsigned int deltaT_F1; |
|
936 | 1083 | unsigned long long int deltaT_F2; |
|
937 | 1084 | |
|
938 | 1085 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
939 | 1086 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
940 | 1087 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
941 | 1088 | sampleOffset_asLong = 0x00; |
|
942 | 1089 | |
|
943 | 1090 | // (1) get the f0 acquisition time |
|
944 | 1091 | build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 ); |
|
945 | 1092 | |
|
946 | 1093 | // (2) compute the central reference time |
|
947 | 1094 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
948 | 1095 | |
|
949 | 1096 | // (3) compute the acquisition time of the current snapshot |
|
950 | 1097 | switch(frequencyChannel) |
|
951 | 1098 | { |
|
952 | 1099 | case 1: // 1 is for F1 = 4096 Hz |
|
953 | 1100 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
954 | 1101 | nb_ring_nodes = NB_RING_NODES_F1; |
|
955 | 1102 | frequency_asLong = 4096; |
|
956 | 1103 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
957 | 1104 | break; |
|
958 | 1105 | case 2: // 2 is for F2 = 256 Hz |
|
959 | 1106 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
960 | 1107 | nb_ring_nodes = NB_RING_NODES_F2; |
|
961 | 1108 | frequency_asLong = 256; |
|
962 | 1109 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
963 | 1110 | break; |
|
964 | 1111 | default: |
|
965 | 1112 | acquisitionTime_asLong = centerTime_asLong; |
|
966 | 1113 | frequency_asLong = 256; |
|
967 | 1114 | nbTicksPerSample_asLong = 256; |
|
968 | 1115 | break; |
|
969 | 1116 | } |
|
970 | 1117 | |
|
971 | 1118 | //**************************************************************************** |
|
972 | 1119 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
973 | 1120 | for (i=0; i<nb_ring_nodes; i++) |
|
974 | 1121 | { |
|
975 | 1122 | PRINTF1("%d ... ", i) |
|
976 | 1123 | build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send ); |
|
977 | 1124 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
978 | 1125 | { |
|
979 | 1126 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
980 | 1127 | break; |
|
981 | 1128 | } |
|
982 | 1129 | ring_node_to_send = ring_node_to_send->previous; |
|
983 | 1130 | } |
|
984 | 1131 | |
|
985 | 1132 | // (5) compute the number of samples to take in the current buffer |
|
986 | 1133 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
987 | 1134 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
988 | 1135 | PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
989 | 1136 | |
|
990 | 1137 | // (6) compute the final acquisition time |
|
991 | 1138 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
992 | 1139 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
993 | 1140 | |
|
994 | 1141 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
995 | 1142 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
996 | 1143 | ptr2 = (unsigned char*) wf_snap_extracted; |
|
997 | 1144 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
998 | 1145 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
999 | 1146 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
1000 | 1147 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
1001 | 1148 | ptr2[6] = ptr1[ 4 + 2 ]; |
|
1002 | 1149 | ptr2[7] = ptr1[ 5 + 2 ]; |
|
1003 | 1150 | |
|
1004 | 1151 | // re set the synchronization bit |
|
1005 | 1152 | timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address; |
|
1006 | 1153 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
1007 | 1154 | |
|
1008 | 1155 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
1009 | 1156 | { |
|
1010 | 1157 | nbSamplesPart1_asLong = 0; |
|
1011 | 1158 | } |
|
1012 | 1159 | // copy the part 1 of the snapshot in the extracted buffer |
|
1013 | 1160 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1014 | 1161 | { |
|
1015 | 1162 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1016 | 1163 | ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
1017 | 1164 | } |
|
1018 | 1165 | // copy the part 2 of the snapshot in the extracted buffer |
|
1019 | 1166 | ring_node_to_send = ring_node_to_send->next; |
|
1020 | 1167 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1021 | 1168 | { |
|
1022 | 1169 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1023 | 1170 | ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET]; |
|
1024 | 1171 | } |
|
1025 | 1172 | } |
|
1026 | 1173 | |
|
1027 | 1174 | void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) |
|
1028 | 1175 | { |
|
1029 | 1176 | unsigned char *acquisitionTimeCharPtr; |
|
1030 | 1177 | |
|
1031 | 1178 | acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address; |
|
1032 | 1179 | |
|
1033 | 1180 | *acquisitionTimeAslong = 0x00; |
|
1034 | 1181 | *acquisitionTimeAslong = ( (unsigned long long int) (acquisitionTimeCharPtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
1035 | 1182 | + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 ) |
|
1036 | 1183 | + ( (unsigned long long int) acquisitionTimeCharPtr[2] << 24 ) |
|
1037 | 1184 | + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 16 ) |
|
1038 | 1185 | + ( (unsigned long long int) acquisitionTimeCharPtr[6] << 8 ) |
|
1039 | 1186 | + ( (unsigned long long int) acquisitionTimeCharPtr[7] ); |
|
1040 | 1187 | } |
|
1041 | 1188 | |
|
1042 | 1189 | //************** |
|
1043 | 1190 | // wfp registers |
|
1044 | 1191 | void reset_wfp_burst_enable(void) |
|
1045 | 1192 | { |
|
1046 | 1193 | /** This function resets the waveform picker burst_enable register. |
|
1047 | 1194 | * |
|
1048 | 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 | 1199 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1053 | 1200 | } |
|
1054 | 1201 | |
|
1055 | 1202 | void reset_wfp_status( void ) |
|
1056 | 1203 | { |
|
1057 | 1204 | /** This function resets the waveform picker status register. |
|
1058 | 1205 | * |
|
1059 | 1206 | * All status bits are set to 0 [new_err full_err full]. |
|
1060 | 1207 | * |
|
1061 | 1208 | */ |
|
1062 | 1209 | |
|
1063 | 1210 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1064 | 1211 | } |
|
1065 | 1212 | |
|
1066 | 1213 | void reset_waveform_picker_regs(void) |
|
1067 | 1214 | { |
|
1068 | 1215 | /** This function resets the waveform picker module registers. |
|
1069 | 1216 | * |
|
1070 | 1217 | * The registers affected by this function are located at the following offset addresses: |
|
1071 | 1218 | * - 0x00 data_shaping |
|
1072 | 1219 | * - 0x04 run_burst_enable |
|
1073 | 1220 | * - 0x08 addr_data_f0 |
|
1074 | 1221 | * - 0x0C addr_data_f1 |
|
1075 | 1222 | * - 0x10 addr_data_f2 |
|
1076 | 1223 | * - 0x14 addr_data_f3 |
|
1077 | 1224 | * - 0x18 status |
|
1078 | 1225 | * - 0x1C delta_snapshot |
|
1079 | 1226 | * - 0x20 delta_f0 |
|
1080 | 1227 | * - 0x24 delta_f0_2 |
|
1081 | 1228 | * - 0x28 delta_f1 |
|
1082 | 1229 | * - 0x2c delta_f2 |
|
1083 | 1230 | * - 0x30 nb_data_by_buffer |
|
1084 | 1231 | * - 0x34 nb_snapshot_param |
|
1085 | 1232 | * - 0x38 start_date |
|
1086 | 1233 | * - 0x3c nb_word_in_buffer |
|
1087 | 1234 | * |
|
1088 | 1235 | */ |
|
1089 | 1236 | |
|
1090 | 1237 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1091 | 1238 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1092 | 1239 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 |
|
1093 | 1240 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c |
|
1094 | 1241 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 |
|
1095 | 1242 | waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14 |
|
1096 | 1243 | reset_wfp_status(); // 0x18 |
|
1097 | 1244 | // |
|
1098 | 1245 | set_wfp_delta_snapshot(); // 0x1c |
|
1099 | 1246 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1100 | 1247 | set_wfp_delta_f1(); // 0x28 |
|
1101 | 1248 | set_wfp_delta_f2(); // 0x2c |
|
1102 | 1249 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1103 | 1250 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1104 | 1251 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1105 | 1252 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1106 | 1253 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1107 | 1254 | // 2688 = 8 * 336 |
|
1108 | 1255 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1109 | 1256 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1110 | 1257 | waveform_picker_regs->start_date = 0x00; // 0x38 |
|
1111 | 1258 | waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 |
|
1112 | 1259 | } |
|
1113 | 1260 | |
|
1114 | 1261 | void set_wfp_data_shaping( void ) |
|
1115 | 1262 | { |
|
1116 | 1263 | /** This function sets the data_shaping register of the waveform picker module. |
|
1117 | 1264 | * |
|
1118 | 1265 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1119 | 1266 | * bw_sp0_sp1_r0_r1 |
|
1120 | 1267 | * |
|
1121 | 1268 | */ |
|
1122 | 1269 | |
|
1123 | 1270 | unsigned char data_shaping; |
|
1124 | 1271 | |
|
1125 | 1272 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1126 | 1273 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1127 | 1274 | |
|
1128 | 1275 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
1129 | 1276 | |
|
1130 | 1277 | waveform_picker_regs->data_shaping = |
|
1131 | 1278 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
1132 | 1279 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
1133 | 1280 | + ( (data_shaping & 0x04) ) // SP1 |
|
1134 | 1281 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
1135 | 1282 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
1136 | 1283 | } |
|
1137 | 1284 | |
|
1138 | 1285 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1139 | 1286 | { |
|
1140 | 1287 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1141 | 1288 | * |
|
1142 | 1289 | * @param mode is the LFR mode to launch. |
|
1143 | 1290 | * |
|
1144 | 1291 | * The burst bits shall be before the enable bits. |
|
1145 | 1292 | * |
|
1146 | 1293 | */ |
|
1147 | 1294 | |
|
1148 | 1295 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1149 | 1296 | // the burst bits shall be set first, before the enable bits |
|
1150 | 1297 | switch(mode) { |
|
1151 | 1298 | case(LFR_MODE_NORMAL): |
|
1152 | 1299 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1153 | 1300 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1154 | 1301 | break; |
|
1155 | 1302 | case(LFR_MODE_BURST): |
|
1156 | 1303 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1157 | 1304 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1158 | 1305 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 |
|
1159 | 1306 | break; |
|
1160 | 1307 | case(LFR_MODE_SBM1): |
|
1161 | 1308 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1162 | 1309 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1163 | 1310 | break; |
|
1164 | 1311 | case(LFR_MODE_SBM2): |
|
1165 | 1312 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1166 | 1313 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1167 | 1314 | break; |
|
1168 | 1315 | default: |
|
1169 | 1316 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1170 | 1317 | break; |
|
1171 | 1318 | } |
|
1172 | 1319 | } |
|
1173 | 1320 | |
|
1174 | 1321 | void set_wfp_delta_snapshot( void ) |
|
1175 | 1322 | { |
|
1176 | 1323 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1177 | 1324 | * |
|
1178 | 1325 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1179 | 1326 | * - sy_lfr_n_swf_p[0] |
|
1180 | 1327 | * - sy_lfr_n_swf_p[1] |
|
1181 | 1328 | * |
|
1182 | 1329 | */ |
|
1183 | 1330 | |
|
1184 | 1331 | unsigned int delta_snapshot; |
|
1185 | 1332 | unsigned int delta_snapshot_in_T2; |
|
1186 | 1333 | |
|
1187 | 1334 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1188 | 1335 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1189 | 1336 | |
|
1190 | 1337 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1191 | 1338 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1192 | 1339 | } |
|
1193 | 1340 | |
|
1194 | 1341 | void set_wfp_delta_f0_f0_2( void ) |
|
1195 | 1342 | { |
|
1196 | 1343 | unsigned int delta_snapshot; |
|
1197 | 1344 | unsigned int nb_samples_per_snapshot; |
|
1198 | 1345 | float delta_f0_in_float; |
|
1199 | 1346 | |
|
1200 | 1347 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1201 | 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 | 1349 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1203 | 1350 | |
|
1204 | 1351 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1205 | 1352 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits |
|
1206 | 1353 | } |
|
1207 | 1354 | |
|
1208 | 1355 | void set_wfp_delta_f1( void ) |
|
1209 | 1356 | { |
|
1210 | 1357 | unsigned int delta_snapshot; |
|
1211 | 1358 | unsigned int nb_samples_per_snapshot; |
|
1212 | 1359 | float delta_f1_in_float; |
|
1213 | 1360 | |
|
1214 | 1361 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1215 | 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 | 1363 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1217 | 1364 | |
|
1218 | 1365 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1219 | 1366 | } |
|
1220 | 1367 | |
|
1221 | 1368 | void set_wfp_delta_f2() |
|
1222 | 1369 | { |
|
1223 | 1370 | unsigned int delta_snapshot; |
|
1224 | 1371 | unsigned int nb_samples_per_snapshot; |
|
1225 | 1372 | |
|
1226 | 1373 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1227 | 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 | 1376 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1230 | 1377 | } |
|
1231 | 1378 | |
|
1232 | 1379 | //***************** |
|
1233 | 1380 | // local parameters |
|
1234 | 1381 | |
|
1235 | 1382 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1236 | 1383 | { |
|
1237 | 1384 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1238 | 1385 | * |
|
1239 | 1386 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1240 | 1387 | * @param sid is the source identifier of the packet being updated. |
|
1241 | 1388 | * |
|
1242 | 1389 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1243 | 1390 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1244 | 1391 | * The sequence counter shall start at zero at startup. |
|
1245 | 1392 | * |
|
1246 | 1393 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1247 | 1394 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1248 | 1395 | * |
|
1249 | 1396 | */ |
|
1250 | 1397 | |
|
1251 | 1398 | unsigned short *sequence_cnt; |
|
1252 | 1399 | unsigned short segmentation_grouping_flag; |
|
1253 | 1400 | unsigned short new_packet_sequence_control; |
|
1254 | 1401 | rtems_mode initial_mode_set; |
|
1255 | 1402 | rtems_mode current_mode_set; |
|
1256 | 1403 | rtems_status_code status; |
|
1257 | 1404 | |
|
1258 | 1405 | //****************************************** |
|
1259 | 1406 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1260 | 1407 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1261 | 1408 | |
|
1262 | 1409 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1263 | 1410 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1264 | 1411 | || (sid == SID_BURST_CWF_F2) |
|
1265 | 1412 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1266 | 1413 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1267 | 1414 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1268 | 1415 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1269 | 1416 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1270 | 1417 | { |
|
1271 | 1418 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1272 | 1419 | } |
|
1273 | 1420 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1274 | 1421 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1275 | 1422 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1276 | 1423 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1277 | 1424 | { |
|
1278 | 1425 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1279 | 1426 | } |
|
1280 | 1427 | else |
|
1281 | 1428 | { |
|
1282 | 1429 | sequence_cnt = (unsigned short *) NULL; |
|
1283 | 1430 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1284 | 1431 | } |
|
1285 | 1432 | |
|
1286 | 1433 | if (sequence_cnt != NULL) |
|
1287 | 1434 | { |
|
1288 | 1435 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1289 | 1436 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1290 | 1437 | |
|
1291 | 1438 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1292 | 1439 | |
|
1293 | 1440 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1294 | 1441 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1295 | 1442 | |
|
1296 | 1443 | // increment the sequence counter |
|
1297 | 1444 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1298 | 1445 | { |
|
1299 | 1446 | *sequence_cnt = *sequence_cnt + 1; |
|
1300 | 1447 | } |
|
1301 | 1448 | else |
|
1302 | 1449 | { |
|
1303 | 1450 | *sequence_cnt = 0; |
|
1304 | 1451 | } |
|
1305 | 1452 | } |
|
1306 | 1453 | |
|
1307 | 1454 | //*********************************** |
|
1308 | 1455 | // RESET THE MODE OF THE CALLING TASK |
|
1309 | 1456 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1310 | 1457 | } |
General Comments 0
You need to be logged in to leave comments.
Login now