##// END OF EJS Templates
Draft implementation of the TC_LFR_LOAD_NORMAL_PAR
admin@pc-p-leroy3.LAB-LPP.LOCAL -
r10:4baf2642cd31 default
parent child
Show More
@@ -1,69 +1,69
1 1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 2 <CodeBlocks_project_file>
3 3 <FileVersion major="1" minor="6" />
4 4 <Project>
5 5 <Option title="FSW-rtems" />
6 6 <Option pch_mode="2" />
7 7 <Option compiler="sparcrtemsgcc446" />
8 8 <Build>
9 9 <Target title="Debug">
10 10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
11 11 <Option object_output="obj/Debug/" />
12 12 <Option type="1" />
13 <Option compiler="sparcrtemsgcc446" />
13 <Option compiler="sparcrtems446" />
14 14 <Compiler>
15 15 <Add option="-fexpensive-optimizations" />
16 16 <Add option="-O3" />
17 17 <Add option="-g" />
18 18 <Add directory="../header" />
19 19 <Add directory="../src" />
20 20 </Compiler>
21 21 </Target>
22 22 <Target title="Release">
23 23 <Option output="bin/Release/FSW-rtems" prefix_auto="1" extension_auto="1" />
24 24 <Option object_output="obj/Release/" />
25 25 <Option type="1" />
26 26 <Option compiler="sparcrtemsgcc446" />
27 27 <Compiler>
28 28 <Add option="-O2" />
29 29 </Compiler>
30 30 <Linker>
31 31 <Add option="-s" />
32 32 </Linker>
33 33 </Target>
34 34 </Build>
35 35 <Compiler>
36 36 <Add option="-Wall" />
37 37 </Compiler>
38 38 <Unit filename="../header/ccsds_types.h" />
39 39 <Unit filename="../header/fsw_init.h" />
40 40 <Unit filename="../header/fsw_misc.h" />
41 41 <Unit filename="../header/fsw_params.h" />
42 42 <Unit filename="../header/fsw_processing.h" />
43 43 <Unit filename="../header/grlib_regs.h" />
44 44 <Unit filename="../header/tc_handler.h" />
45 45 <Unit filename="../header/wf_handler.h" />
46 46 <Unit filename="../src/fsw_globals.c">
47 47 <Option compilerVar="CC" />
48 48 </Unit>
49 49 <Unit filename="../src/fsw_init.c">
50 50 <Option compilerVar="CC" />
51 51 </Unit>
52 52 <Unit filename="../src/fsw_misc.c">
53 53 <Option compilerVar="CC" />
54 54 </Unit>
55 55 <Unit filename="../src/fsw_processing.c">
56 56 <Option compilerVar="CC" />
57 57 </Unit>
58 58 <Unit filename="../src/tc_handler.c">
59 59 <Option compilerVar="CC" />
60 60 </Unit>
61 61 <Unit filename="../src/wf_handler.c">
62 62 <Option compilerVar="CC" />
63 63 </Unit>
64 64 <Extensions>
65 65 <code_completion />
66 66 <debugger />
67 67 </Extensions>
68 68 </Project>
69 69 </CodeBlocks_project_file>
@@ -1,226 +1,310
1 1 # depslib dependency file v1.0
2 2 1355231335 source:e:\missions\solo\dev_ple\src\fsw-rtems.c
3 3 <rtems.h>
4 4 <bsp.h>
5 5 <rtems/confdefs.h>
6 6 <drvmgr/drvmgr_confdefs.h>
7 7 <rtems.h>
8 8 <errno.h>
9 9 <fcntl.h>
10 10 <stdio.h>
11 11 <stdlib.h>
12 12 <FSW-config.c>
13 13 <grspw.h>
14 14 <apbuart.h>
15 15 <FSW-rtems-processing.h>
16 16
17 17 1355231335 -processing.h>
18 18
19 19 1350983928 source:e:\missions\solo\dev_ple\src\grspw.c
20 20 <..\header\grspw.h>
21 21 <stdio.h>
22 22
23 23 1354190601
24 24
25 25 1350983928 e:\missions\solo\dev_ple\header\grspw.h
26 26
27 27 1351173364 source:e:\missions\solo\dev_ple\src\fsw-config.c
28 28 <drvmgr/ambapp_bus.h>
29 29
30 30 1354190602 bapp_bus.h>
31 31
32 32 1354190602 e:\missions\solo\dev_ple\src\fsw-config.c
33 33 <drvmgr/ambapp_bus.h>
34 34
35 35 1354190602 source:e:\missions\solo\dev_ple\src\fsw-rtems-processing.c
36 36 <FSW-rtems-processing.h>
37 37 <math.h>
38 38 <stdio.h>
39 39 <leon.h>
40 40
41 41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
42 42 <rtems.h>
43 43
44 44 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
45 45 <FSW-rtems-processing.h>
46 46 <math.h>
47 47 <stdio.h>
48 48 <leon.h>
49 49
50 50 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h
51 51 <rtems.h>
52 52 <grlibregs.h>
53 53 <FSW-params.h>
54 54
55 55 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c
56 56 <rtems.h>
57 57 <bsp.h>
58 58 <rtems/confdefs.h>
59 59 <drvmgr/drvmgr_confdefs.h>
60 60 <FSW-rtems.h>
61 61 <FSW-config.c>
62 62
63 63 1359365823 /opt/DEV_PLE/src/FSW-config.c
64 64 <drvmgr/ambapp_bus.h>
65 65
66 66 1359458568 source:/opt/DEV_PLE/src/TC_handler.c
67 67 <TC_handler.h>
68 68 <FSW-params.h>
69 69
70 70 1359377846 /opt/DEV_PLE/header/TC_handler.h
71 71 <stdio.h>
72 72 <ccsds_types.h>
73 73
74 74 1359640245 /opt/DEV_PLE/header/ccsds_types.h
75 75
76 76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
77 77 <drvmgr/ambapp_bus.h>
78 78
79 79 1359452642 /opt/DEV_PLE/header/FSW-config.h
80 80
81 81 1359440704 /opt/DEV_PLE/header/grlibregs.h
82 82
83 83 1359382989 source:/opt/DEV_PLE/src/WF_handler.c
84 84
85 85 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c
86 86 <FSW-misc.h>
87 87 <FSW-params.h>
88 88
89 89 1359459330 /opt/DEV_PLE/header/FSW-misc.h
90 90 <rtems.h>
91 91 <stdio.h>
92 92 <FSW-rtems.h>
93 93 <FSW-params.h>
94 94 <grlibregs.h>
95 95 <grspw.h>
96 96 <ccsds_types.h>
97 97
98 98 1359459364 /opt/DEV_PLE/header/FSW-rtems.h
99 99 <errno.h>
100 100 <fcntl.h>
101 101 <stdio.h>
102 102 <stdlib.h>
103 103 <grspw.h>
104 104 <apbuart.h>
105 105 <FSW-params.h>
106 106 <FSW-misc.h>
107 107 <FSW-rtems-processing.h>
108 108 <TC_handler.h>
109 109 <WF_handler.h>
110 110 <grlibregs.h>
111 111
112 112 1359458453 /opt/DEV_PLE/header/FSW-params.h
113 113
114 114 1359459642 /opt/DEV_PLE/header/WF_handler.h
115 115 <rtems.h>
116 116 <FSW-params.h>
117 117 <grspw.h>
118 118 <grlibregs.h>
119 119 <ccsds_types.h>
120 120 <stdio.h>
121 121 <FSW-rtems.h>
122 122
123 123 1359464354 source:/opt/DEV_PLE/src/fsw_main.c
124 124 <rtems.h>
125 125 <bsp.h>
126 126 <rtems/confdefs.h>
127 127 <drvmgr/drvmgr_confdefs.h>
128 128 <fsw_main.h>
129 129 <fsw_config.c>
130 130
131 131 1359464346 /opt/DEV_PLE/header/fsw_main.h
132 132 <errno.h>
133 133 <fcntl.h>
134 134 <stdio.h>
135 135 <stdlib.h>
136 136 <grspw.h>
137 137 <apbuart.h>
138 138 <fsw_params.h>
139 139 <fsw_misc.h>
140 140 <fsw_processing.h>
141 141 <tc_handler.h>
142 142 <wf_handler.h>
143 143 <grlib_regs.h>
144 144
145 145 1359616894 /opt/DEV_PLE/header/fsw_params.h
146 146
147 147 1359614518 /opt/DEV_PLE/header/fsw_misc.h
148 148 <rtems.h>
149 149 <stdio.h>
150 150 <fsw_init.h>
151 151 <fsw_params.h>
152 152 <grlib_regs.h>
153 153 <grspw.h>
154 154 <ccsds_types.h>
155 155
156 156 1359440704 /opt/DEV_PLE/header/grlib_regs.h
157 157
158 158 1359614517 /opt/DEV_PLE/header/fsw_processing.h
159 159 <rtems.h>
160 160 <grlib_regs.h>
161 161 <fsw_params.h>
162 162
163 163 1359643450 /opt/DEV_PLE/header/tc_handler.h
164 164 <rtems.h>
165 165 <stdio.h>
166 166 <unistd.h>
167 167 <sys/ioctl.h>
168 168 <ccsds_types.h>
169 169 <grspw.h>
170 170 <fsw_init.h>
171 171
172 172 1359614518 /opt/DEV_PLE/header/wf_handler.h
173 173 <rtems.h>
174 174 <fsw_params.h>
175 175 <grspw.h>
176 176 <grlib_regs.h>
177 177 <ccsds_types.h>
178 178 <stdio.h>
179 179 <fsw_init.h>
180 180
181 181 1359365823 /opt/DEV_PLE/src/fsw_config.c
182 182 <drvmgr/ambapp_bus.h>
183 183
184 184 1359614518 source:/opt/DEV_PLE/src/fsw_misc.c
185 185 <fsw_misc.h>
186 186 <fsw_params.h>
187 187
188 188 1359643720 source:/opt/DEV_PLE/src/tc_handler.c
189 189 <tc_handler.h>
190 190 <fsw_params.h>
191 191
192 192 1359614518 source:/opt/DEV_PLE/src/wf_handler.c
193 193 <wf_handler.h>
194 194
195 195 1359615705 source:/opt/DEV_PLE/src/fsw_globals.c
196 196 <fsw_processing.h>
197 197 <rtems.h>
198 198
199 199 1359622160 source:/opt/DEV_PLE/src/fsw_init.c
200 200 <rtems.h>
201 201 <bsp.h>
202 202 <rtems/confdefs.h>
203 203 <drvmgr/drvmgr_confdefs.h>
204 204 <fsw_init.h>
205 205 <fsw_config.c>
206 206
207 207 1359615705 /opt/DEV_PLE/header/fsw_init.h
208 208 <errno.h>
209 209 <fcntl.h>
210 210 <stdio.h>
211 211 <stdlib.h>
212 212 <grspw.h>
213 213 <apbuart.h>
214 214 <fsw_params.h>
215 215 <fsw_misc.h>
216 216 <fsw_processing.h>
217 217 <tc_handler.h>
218 218 <wf_handler.h>
219 219 <grlib_regs.h>
220 220
221 221 1359614518 source:/opt/DEV_PLE/src/fsw_processing.c
222 222 <fsw_processing.h>
223 223 <math.h>
224 224 <stdio.h>
225 225 <leon.h>
226 226
227 1359665502 source:/home/admin/opt/DEV_PLE/src/fsw_globals.c
228 <fsw_processing.h>
229 <rtems.h>
230
231 1359663364 /home/admin/opt/DEV_PLE/header/fsw_processing.h
232 <rtems.h>
233 <grlib_regs.h>
234 <fsw_params.h>
235
236 1359470426 /home/admin/opt/DEV_PLE/header/grlib_regs.h
237
238 1359665475 /home/admin/opt/DEV_PLE/header/fsw_params.h
239
240 1359666330 source:/home/admin/opt/DEV_PLE/src/fsw_init.c
241 <rtems.h>
242 <bsp.h>
243 <rtems/confdefs.h>
244 <drvmgr/drvmgr_confdefs.h>
245 <fsw_init.h>
246 <fsw_config.c>
247
248 1359666373 /home/admin/opt/DEV_PLE/header/fsw_init.h
249 <errno.h>
250 <fcntl.h>
251 <stdio.h>
252 <stdlib.h>
253 <grspw.h>
254 <apbuart.h>
255 <fsw_params.h>
256 <fsw_misc.h>
257 <fsw_processing.h>
258 <tc_handler.h>
259 <wf_handler.h>
260 <grlib_regs.h>
261
262 1359663364 /home/admin/opt/DEV_PLE/header/fsw_misc.h
263 <rtems.h>
264 <stdio.h>
265 <fsw_init.h>
266 <fsw_params.h>
267 <grlib_regs.h>
268 <grspw.h>
269 <ccsds_types.h>
270
271 1359663364 /home/admin/opt/DEV_PLE/header/ccsds_types.h
272
273 1359665643 /home/admin/opt/DEV_PLE/header/tc_handler.h
274 <rtems.h>
275 <stdio.h>
276 <unistd.h>
277 <sys/ioctl.h>
278 <ccsds_types.h>
279 <grspw.h>
280 <fsw_init.h>
281
282 1359663364 /home/admin/opt/DEV_PLE/header/wf_handler.h
283 <rtems.h>
284 <fsw_params.h>
285 <grspw.h>
286 <grlib_regs.h>
287 <ccsds_types.h>
288 <stdio.h>
289 <fsw_init.h>
290
291 1359470426 /home/admin/opt/DEV_PLE/src/fsw_config.c
292 <drvmgr/ambapp_bus.h>
293
294 1359663364 source:/home/admin/opt/DEV_PLE/src/fsw_misc.c
295 <fsw_misc.h>
296 <fsw_params.h>
297
298 1359663364 source:/home/admin/opt/DEV_PLE/src/fsw_processing.c
299 <fsw_processing.h>
300 <math.h>
301 <stdio.h>
302 <leon.h>
303
304 1359663364 source:/home/admin/opt/DEV_PLE/src/wf_handler.c
305 <wf_handler.h>
306
307 1359665083 source:/home/admin/opt/DEV_PLE/src/tc_handler.c
308 <tc_handler.h>
309 <fsw_params.h>
310
@@ -1,53 +1,43
1 1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 2 <CodeBlocks_layout_file>
3 3 <ActiveTarget name="Debug" />
4 4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="5">
5 <Cursor position="1172" topLine="24" />
5 <Cursor position="4079" topLine="120" />
6 6 </File>
7 <File name="../header/fsw_init.h" open="1" top="0" tabpos="3">
8 <Cursor position="410" topLine="16" />
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="3">
8 <Cursor position="1128" topLine="26" />
9 9 </File>
10 10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
11 11 <Cursor position="114" topLine="0" />
12 12 </File>
13 13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="0">
14 <Cursor position="1320" topLine="8" />
14 <Cursor position="1374" topLine="49" />
15 15 </File>
16 16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
17 <Cursor position="510" topLine="0" />
17 <Cursor position="576" topLine="0" />
18 18 </File>
19 19 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
20 <Cursor position="634" topLine="0" />
20 <Cursor position="437" topLine="35" />
21 21 </File>
22 22 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
23 23 <Cursor position="212" topLine="0" />
24 24 </File>
25 <File name="../src/fsw_globals.c" open="1" top="0" tabpos="4">
26 <Cursor position="46" topLine="0" />
25 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="4">
26 <Cursor position="1271" topLine="18" />
27 27 </File>
28 <<<<<<< local
29 <File name="../src/fsw_init.c" open="1" top="1" tabpos="0">
30 <Cursor position="1703" topLine="36" />
31 =======
32 <File name="../src/fsw_init.c" open="1" top="1" tabpos="2">
33 <Cursor position="3361" topLine="60" />
34 >>>>>>> other
28 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
29 <Cursor position="1814" topLine="48" />
35 30 </File>
36 31 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
37 32 <Cursor position="20" topLine="0" />
38 33 </File>
39 34 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2">
40 35 <Cursor position="1175" topLine="46" />
41 36 </File>
42 <<<<<<< local
43 <File name="../src/tc_handler.c" open="0" top="0" tabpos="3">
44 <Cursor position="2672" topLine="26" />
45 =======
46 <File name="../src/tc_handler.c" open="1" top="0" tabpos="1">
47 <Cursor position="11070" topLine="270" />
48 >>>>>>> other
37 <File name="../src/tc_handler.c" open="1" top="1" tabpos="2">
38 <Cursor position="13133" topLine="89" />
49 39 </File>
50 40 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
51 41 <Cursor position="3936" topLine="62" />
52 42 </File>
53 43 </CodeBlocks_layout_file>
1 NO CONTENT: modified file, binary diff hidden
@@ -1,45 +1,47
1 1 #ifndef FSW_RTEMS_H_INCLUDED
2 2 #define FSW_RTEMS_H_INCLUDED
3 3
4 4 #include <errno.h>
5 5 #include <fcntl.h>
6 6 #include <stdio.h>
7 7 #include <stdlib.h>
8 8
9 9 #include <grspw.h>
10 10 #include <apbuart.h>
11 11
12 12 #include <fsw_params.h>
13 13 #include <fsw_misc.h>
14 14 #include <fsw_processing.h>
15 15 #include <tc_handler.h>
16 16 #include <wf_handler.h>
17 17 #include <grlib_regs.h>
18 18
19 19 extern int sched_yield();
20 20 extern int errno;
21 21 extern rtems_id Task_id[ ]; /* array of task ids */
22 22 extern rtems_name Task_name[ ]; /* array of task names */
23 23 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
24 24 extern int fdSPW; // grspw file descriptor
25 25 extern int fdUART; // uart file descriptor
26 extern struct param_norm_str param_norm;
26 27
27 28 // RTEMS TASKS
28 29 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
29 30 rtems_task recv_task(rtems_task_argument argument);
30 31 rtems_task spiq_task(rtems_task_argument argument);
31 32 rtems_task stat_task(rtems_task_argument argument);
32 33 rtems_task wfrm_task(rtems_task_argument argument);
33 34 int create_all_tasks();
34 35 int start_all_tasks();
35 36 int create_message_queue();
36 37
37 38 // OTHER functions
39 void init_default_mode_parameters();
38 40 int configure_spw_link();
39 41 int send_console_outputs_on_serial_port();
40 42 extern int rtems_cpu_usage_report();
41 43 extern int rtems_cpu_usage_reset();
42 44 void print_statistics(spw_stats *);
43 45 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
44 46
45 47 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,60 +1,68
1 1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3 3
4 4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 5 #define UART_DEVICE_NAME "/dev/console"
6 6
7 7 //*****************************
8 8 // APB REGISTERS BASE ADDRESSES
9 9 #define REGS_ADDR_APBUART 0x80000100
10 10 #define REGS_ADDR_GPTIMER 0x80000300
11 11 #define REGS_ADDR_GRSPW 0x80000500
12 12 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
13 13
14 14 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
15 15
16 16 #define IRQ_SM 9
17 17 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
18 18 #define IRQ_WF 10
19 19 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
20 20
21 21 #define CLKDIV_SM_SIMULATOR 9999
22 22 #define CLKDIV_WF_SIMULATOR 9999999
23 23 #define TIMER_SM_SIMULATOR 1
24 24 #define TIMER_WF_SIMULATOR 2
25 25
26 26 //******
27 27 // RTEMS
28 28 #define TASKID_RECV 1
29 29 #define TASKID_ACTN 1
30 30 #define TASKID_SPIQ 3
31 31 #define TASKID_SMIQ 4
32 32 #define TASKID_STAT 5
33 33 #define TASKID_AVF0 6
34 34 #define TASKID_BPF0 7
35 35 #define TASKID_WFRM 8
36 36
37 37 #define ACTION_MSG_QUEUE_COUNT 10
38 38
39 39 //*******
40 40 // MACROS
41 41 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
42 42 #ifdef PRINT_MESSAGES_ON_CONSOLE
43 43 #define PRINTF(x) printf(x);
44 44 #define PRINTF1(x,y) printf(x,y);
45 45 #define PRINTF2(x,y,z) printf(x,y,z);
46 46 #else
47 47 #define PRINTF(x) ;
48 48 #define PRINTF1(x,y) ;
49 49 #define PRINTF2(x,y,z) ;
50 50 #endif
51 51
52 52 #define NB_SAMPLES_PER_SNAPSHOT 2048
53 53 #define NB_BYTES_SWF_BLK 2 * 6
54 54
55 struct param_norm_str{
56 unsigned int sy_lfr_n_swf_l; // length of the snapshots
57 unsigned int sy_lfr_n_swf_p; // time between two snapshots
58 unsigned int sy_lfr_n_asm_p; // time between two asm
59 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
60 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
61 };
62
55 63 extern volatile int wf_snap_f0[ ]; // 24576 bytes
56 64 extern volatile int wf_snap_f1[ ]; // 24576 bytes
57 65 extern volatile int wf_snap_f2[ ]; // 24576 bytes
58 66 extern volatile int wf_cont_f3[ ]; // 24576 bytes
59 67
60 68 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,48 +1,54
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6 #include <unistd.h> // for the read call
7 7 #include <sys/ioctl.h> // for the ioctl call
8 8 #include <ccsds_types.h>
9 9 #include <grspw.h>
10 10 #include <fsw_init.h>
11 11
12 12 extern int fdSPW;
13 13 extern rtems_name misc_name[ ];
14 14 extern rtems_name misc_id[ ];
15 extern rtems_id Task_id[ ]; /* array of task ids */
15 extern rtems_id Task_id[ ]; // array of task ids
16 extern struct param_norm_str param_norm;
16 17
17 18 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
18 19 unsigned char currentTC_COMPUTED_CRC[2];
19 20 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
20 21 unsigned int currentTM_length;
21 22 unsigned char currentTC_processedFlag;
22 23
23 24 //**********************
24 25 // GENERAL USE FUNCTIONS
25 26 unsigned int lookUpTableForCRC[256];
26 27 void InitLookUpTableForCRC();
27 28 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
28 29
29 30 //*********************
30 31 // ACCEPTANCE FUNCTIONS
31 32 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
32 33
33 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength,
34 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
34 35 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
35 36 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
36 37 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
37 38
38 39 //***********
39 40 // RTEMS TASK
40 41 rtems_task recv_task( rtems_task_argument unused );
41 42 rtems_task actn_task( rtems_task_argument unused );
42 43 int create_message_queue();
43 44
44 45 //***********
45 46 // TC ACTIONS
46 int default_action(ccsdsTelecommandPacket_t *TC);
47 int action_default(ccsdsTelecommandPacket_t *TC);
48 int action_load_norm(ccsdsTelecommandPacket_t *TC);
49 int action_enter(ccsdsTelecommandPacket_t *TC);
47 50
48 51 #endif // TC_HANDLER_H_INCLUDED
52
53
54
@@ -1,34 +1,37
1 1 #include <fsw_processing.h>
2 2 #include <rtems.h>
3 3
4 4 // RTEMS GLOBAL VARIABLES
5 5 rtems_name misc_name[5];
6 6 rtems_name misc_id[5];
7 7 rtems_id Task_id[10]; /* array of task ids */
8 8 rtems_name Task_name[10]; /* array of task names */
9 9 int fdSPW;
10 10 int fdUART;
11 11
12 12 // WAVEFORMS GLOBAL VARIABLES
13 13 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
14 14 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
15 15 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
16 16 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
17 17
18 18 // SPECTRAL MATRICES GLOBAL VARIABLES
19 19 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
20 20 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
21 21 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
22 22 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
23 23 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
24 24 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
25 25 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
26 26 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
27 27 //
28 28 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
29 29 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
30 30
31 // BASIC PARAMETERS GLOBAL VAIRABLES
31 // NORMAL MODE PARAMETERS
32 struct param_norm_str param_norm;
33
34 // BASIC PARAMETERS GLOBAL VARIABLES
32 35 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
33 36
34 37 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
@@ -1,255 +1,264
1 1 //*************************
2 2 // GPL reminder to be added
3 3 //*************************
4 4
5 5 #include <rtems.h>
6 6
7 7 /* configuration information */
8 8
9 9 #define CONFIGURE_INIT
10 10
11 11 #include <bsp.h> /* for device driver prototypes */
12 12
13 13 /* configuration information */
14 14
15 15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17 17
18 18 #define CONFIGURE_MAXIMUM_TASKS 10
19 19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 24 #define CONFIGURE_MAXIMUM_PERIODS 1
25 25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
26 26
27 27 #include <rtems/confdefs.h>
28 28
29 29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
30 30 #ifdef RTEMS_DRVMGR_STARTUP
31 31 #ifdef LEON3
32 32 /* Add Timer and UART Driver */
33 33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
34 34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
35 35 #endif
36 36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
37 37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
38 38 #endif
39 39 #endif
40 40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
41 41 #include <drvmgr/drvmgr_confdefs.h>
42 42 #endif
43 43
44 44 #include <fsw_init.h>
45 45 #include <fsw_config.c>
46 46
47 47 char *link_status(int status);
48 48
49 49 char *lstates[6] = {"Error-reset",
50 50 "Error-wait",
51 51 "Ready",
52 52 "Started",
53 53 "Connecting",
54 54 "Run"
55 55 };
56 56
57 57 rtems_task Init( rtems_task_argument ignored )
58 58 {
59 59 rtems_status_code status;
60 60
61 61 //send_console_outputs_on_serial_port();
62 62
63 63 InitLookUpTableForCRC(); // in tc_handler.h
64
64 init_default_mode_parameters();
65 65 create_message_queue();
66 66 create_all_tasks();
67 67 start_all_tasks();
68 68
69 69 configure_spw_link();
70 70 // configure timer for spectral matrices simulation
71 71 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
72 72 IRQ_SPARC_SM, spectral_matrices_isr );
73 73 // configure timer for waveforms simulation
74 74 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
75 75 IRQ_SPARC_WF, waveforms_isr );
76 76
77 77 LEON_Unmask_interrupt( IRQ_SM );
78 78 LEON_Unmask_interrupt( IRQ_WF );
79 79
80 80 status = rtems_task_delete(RTEMS_SELF);
81 81 }
82 82
83 83 rtems_task spiq_task(rtems_task_argument unused)
84 84 {
85 85 rtems_event_set event_out;
86 86 struct grspw_regs_str *grspw_regs;
87 87 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
88 88
89 89 while(1){
90 90 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
91 91 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
92 92
93 93 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
94 94 PRINTF("In SPIQ *** Error suspending RECV Task\n")
95 95
96 96 configure_spw_link();
97 97
98 98 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
99 99 PRINTF("In SPIQ *** Error resume RECV Task\n")
100 100 }
101 101 }
102 102
103 void init_default_mode_parameters()
104 {
105 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
106 param_norm.sy_lfr_n_swf_p = 300; // sec
107 param_norm.sy_lfr_n_asm_p = 3600; // sec
108 param_norm.sy_lfr_n_bp_p0 = 4; // sec
109 param_norm.sy_lfr_n_bp_p1 = 20; // sec
110 }
111
103 112 int create_all_tasks()
104 113 {
105 114 rtems_status_code status;
106 115
107 116 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
108 117 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
109 118 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
110 119 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
111 120 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
112 121 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
113 122 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
114 123 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
115 124
116 125 // RECV
117 126 status = rtems_task_create(
118 127 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
119 128 RTEMS_DEFAULT_MODES,
120 129 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
121 130 );
122 131 // ACTN
123 132 status = rtems_task_create(
124 133 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
125 134 RTEMS_DEFAULT_MODES,
126 135 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
127 136 );
128 137 // SPIQ
129 138 status = rtems_task_create(
130 139 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
131 140 RTEMS_DEFAULT_MODES,
132 141 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
133 142 );
134 143 // SMIQ
135 144 status = rtems_task_create(
136 145 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
137 146 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
138 147 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
139 148 );
140 149 // STAT
141 150 status = rtems_task_create(
142 151 Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
143 152 RTEMS_DEFAULT_MODES,
144 153 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
145 154 );
146 155 // AVF0
147 156 status = rtems_task_create(
148 157 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
149 158 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
150 159 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
151 160 );
152 161 // BPF0
153 162 status = rtems_task_create(
154 163 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
155 164 RTEMS_DEFAULT_MODES,
156 165 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
157 166 );
158 167 // WFRM
159 168 status = rtems_task_create(
160 169 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
161 170 RTEMS_DEFAULT_MODES,
162 171 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
163 172 );
164 173
165 174 return 0;
166 175 }
167 176
168 177 int start_all_tasks()
169 178 {
170 179 rtems_status_code status;
171 180
172 181 status = rtems_task_start( Task_id[3], spiq_task, 1 );
173 182 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
174 183
175 184 status = rtems_task_start( Task_id[1], recv_task, 1 );
176 185 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
177 186
178 187 status = rtems_task_start( Task_id[2], actn_task, 1 );
179 188 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
180 189
181 190 status = rtems_task_start( Task_id[4], smiq_task, 1 );
182 191 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
183 192
184 193 status = rtems_task_start( Task_id[5], stat_task, 1 );
185 194 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
186 195
187 196 status = rtems_task_start( Task_id[6], avf0_task, 1 );
188 197 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
189 198
190 199 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
191 200 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
192 201
193 202 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
194 203 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
195 204
196 205 return 0;
197 206 }
198 207
199 208 int configure_spw_link()
200 209 {
201 210 rtems_status_code status;
202 211
203 212 close(fdSPW); // close the device if it is already open
204 213 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
205 214 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
206 215 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
207 216 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
208 217 close(fdSPW); // close the device
209 218 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
210 219 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
211 220 rtems_task_wake_after(100);
212 221 }
213 222
214 223 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
215 224
216 225 // sets a few parameters of the link
217 226 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
218 227 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
219 228 //
220 229 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
221 230 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
222 231 //
223 232 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
224 233 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
225 234 //
226 235 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
227 236 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
228 237 //
229 238 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
230 239 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
231 240
232 241 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
233 242 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
234 243 //
235 244 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
236 245 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
237 246 //
238 247 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
239 248
240 249 return RTEMS_SUCCESSFUL;
241 250 }
242 251
243 252 char *link_status(int status){
244 253 return lstates[status];
245 254 }
246 255
247 256 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
248 257 {
249 258 rtems_status_code status;
250 259 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
251 260 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
252 261 return status;
253 262 }
254 263
255 264
@@ -1,396 +1,414
1 1 #include <tc_handler.h>
2 2 #include <fsw_params.h>
3 3
4 4 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
5 5 "WRONG_LEN_PACKET 1",
6 6 "INCOR_CHECKSUM 2",
7 7 "ILL_TYPE 3",
8 8 "ILL_SUBTYPE 4",
9 9 "WRONG_APP_DATA 5",
10 10 "WRONG_CMD_CODE 6",
11 11 "CCSDS_TM_VALID 7"
12 12 };
13 13
14 14 //**********************
15 15 // GENERAL USE FUNCTIONS
16 16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
17 17 {
18 18 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
19 19 }
20 20
21 21 void InitLookUpTableForCRC()
22 22 {
23 23 unsigned int i, tmp;
24 24 for (i=0; i<256; i++)
25 25 {
26 26 tmp = 0;
27 27 if((i & 1) != 0) tmp = tmp ^ 0x1021;
28 28 if((i & 2) != 0) tmp = tmp ^ 0x2042;
29 29 if((i & 4) != 0) tmp = tmp ^ 0x4084;
30 30 if((i & 8) != 0) tmp = tmp ^ 0x8108;
31 31 if((i & 16) != 0) tmp = tmp ^ 0x1231;
32 32 if((i & 32) != 0) tmp = tmp ^ 0x2462;
33 33