##// END OF EJS Templates
Several TC actions added...
paul@pc-solar1.lab-lpp.local -
r11:84136ad726a3 default
parent child
Show More
@@ -1,69 +1,69
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_project_file>
2 <CodeBlocks_project_file>
3 <FileVersion major="1" minor="6" />
3 <FileVersion major="1" minor="6" />
4 <Project>
4 <Project>
5 <Option title="FSW-rtems" />
5 <Option title="FSW-rtems" />
6 <Option pch_mode="2" />
6 <Option pch_mode="2" />
7 <Option compiler="sparcrtemsgcc446" />
7 <Option compiler="sparcrtemsgcc446" />
8 <Build>
8 <Build>
9 <Target title="Debug">
9 <Target title="Debug">
10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
10 <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" />
11 <Option object_output="obj/Debug/" />
11 <Option object_output="obj/Debug/" />
12 <Option type="1" />
12 <Option type="1" />
13 <Option compiler="sparcrtems446" />
13 <Option compiler="sparcrtemsgcc446" />
14 <Compiler>
14 <Compiler>
15 <Add option="-fexpensive-optimizations" />
15 <Add option="-fexpensive-optimizations" />
16 <Add option="-O3" />
16 <Add option="-O3" />
17 <Add option="-g" />
17 <Add option="-g" />
18 <Add directory="../header" />
18 <Add directory="../header" />
19 <Add directory="../src" />
19 <Add directory="../src" />
20 </Compiler>
20 </Compiler>
21 </Target>
21 </Target>
22 <Target title="Release">
22 <Target title="Release">
23 <Option output="bin/Release/FSW-rtems" prefix_auto="1" extension_auto="1" />
23 <Option output="bin/Release/FSW-rtems" prefix_auto="1" extension_auto="1" />
24 <Option object_output="obj/Release/" />
24 <Option object_output="obj/Release/" />
25 <Option type="1" />
25 <Option type="1" />
26 <Option compiler="sparcrtemsgcc446" />
26 <Option compiler="sparcrtemsgcc446" />
27 <Compiler>
27 <Compiler>
28 <Add option="-O2" />
28 <Add option="-O2" />
29 </Compiler>
29 </Compiler>
30 <Linker>
30 <Linker>
31 <Add option="-s" />
31 <Add option="-s" />
32 </Linker>
32 </Linker>
33 </Target>
33 </Target>
34 </Build>
34 </Build>
35 <Compiler>
35 <Compiler>
36 <Add option="-Wall" />
36 <Add option="-Wall" />
37 </Compiler>
37 </Compiler>
38 <Unit filename="../header/ccsds_types.h" />
38 <Unit filename="../header/ccsds_types.h" />
39 <Unit filename="../header/fsw_init.h" />
39 <Unit filename="../header/fsw_init.h" />
40 <Unit filename="../header/fsw_misc.h" />
40 <Unit filename="../header/fsw_misc.h" />
41 <Unit filename="../header/fsw_params.h" />
41 <Unit filename="../header/fsw_params.h" />
42 <Unit filename="../header/fsw_processing.h" />
42 <Unit filename="../header/fsw_processing.h" />
43 <Unit filename="../header/grlib_regs.h" />
43 <Unit filename="../header/grlib_regs.h" />
44 <Unit filename="../header/tc_handler.h" />
44 <Unit filename="../header/tc_handler.h" />
45 <Unit filename="../header/wf_handler.h" />
45 <Unit filename="../header/wf_handler.h" />
46 <Unit filename="../src/fsw_globals.c">
46 <Unit filename="../src/fsw_globals.c">
47 <Option compilerVar="CC" />
47 <Option compilerVar="CC" />
48 </Unit>
48 </Unit>
49 <Unit filename="../src/fsw_init.c">
49 <Unit filename="../src/fsw_init.c">
50 <Option compilerVar="CC" />
50 <Option compilerVar="CC" />
51 </Unit>
51 </Unit>
52 <Unit filename="../src/fsw_misc.c">
52 <Unit filename="../src/fsw_misc.c">
53 <Option compilerVar="CC" />
53 <Option compilerVar="CC" />
54 </Unit>
54 </Unit>
55 <Unit filename="../src/fsw_processing.c">
55 <Unit filename="../src/fsw_processing.c">
56 <Option compilerVar="CC" />
56 <Option compilerVar="CC" />
57 </Unit>
57 </Unit>
58 <Unit filename="../src/tc_handler.c">
58 <Unit filename="../src/tc_handler.c">
59 <Option compilerVar="CC" />
59 <Option compilerVar="CC" />
60 </Unit>
60 </Unit>
61 <Unit filename="../src/wf_handler.c">
61 <Unit filename="../src/wf_handler.c">
62 <Option compilerVar="CC" />
62 <Option compilerVar="CC" />
63 </Unit>
63 </Unit>
64 <Extensions>
64 <Extensions>
65 <code_completion />
65 <code_completion />
66 <debugger />
66 <debugger />
67 </Extensions>
67 </Extensions>
68 </Project>
68 </Project>
69 </CodeBlocks_project_file>
69 </CodeBlocks_project_file>
@@ -1,310 +1,310
1 # depslib dependency file v1.0
1 # depslib dependency file v1.0
2 1355231335 source:e:\missions\solo\dev_ple\src\fsw-rtems.c
2 1355231335 source:e:\missions\solo\dev_ple\src\fsw-rtems.c
3 <rtems.h>
3 <rtems.h>
4 <bsp.h>
4 <bsp.h>
5 <rtems/confdefs.h>
5 <rtems/confdefs.h>
6 <drvmgr/drvmgr_confdefs.h>
6 <drvmgr/drvmgr_confdefs.h>
7 <rtems.h>
7 <rtems.h>
8 <errno.h>
8 <errno.h>
9 <fcntl.h>
9 <fcntl.h>
10 <stdio.h>
10 <stdio.h>
11 <stdlib.h>
11 <stdlib.h>
12 <FSW-config.c>
12 <FSW-config.c>
13 <grspw.h>
13 <grspw.h>
14 <apbuart.h>
14 <apbuart.h>
15 <FSW-rtems-processing.h>
15 <FSW-rtems-processing.h>
16
16
17 1355231335 -processing.h>
17 1355231335 -processing.h>
18
18
19 1350983928 source:e:\missions\solo\dev_ple\src\grspw.c
19 1350983928 source:e:\missions\solo\dev_ple\src\grspw.c
20 <..\header\grspw.h>
20 <..\header\grspw.h>
21 <stdio.h>
21 <stdio.h>
22
22
23 1354190601
23 1354190601
24
24
25 1350983928 e:\missions\solo\dev_ple\header\grspw.h
25 1350983928 e:\missions\solo\dev_ple\header\grspw.h
26
26
27 1351173364 source:e:\missions\solo\dev_ple\src\fsw-config.c
27 1351173364 source:e:\missions\solo\dev_ple\src\fsw-config.c
28 <drvmgr/ambapp_bus.h>
28 <drvmgr/ambapp_bus.h>
29
29
30 1354190602 bapp_bus.h>
30 1354190602 bapp_bus.h>
31
31
32 1354190602 e:\missions\solo\dev_ple\src\fsw-config.c
32 1354190602 e:\missions\solo\dev_ple\src\fsw-config.c
33 <drvmgr/ambapp_bus.h>
33 <drvmgr/ambapp_bus.h>
34
34
35 1354190602 source:e:\missions\solo\dev_ple\src\fsw-rtems-processing.c
35 1354190602 source:e:\missions\solo\dev_ple\src\fsw-rtems-processing.c
36 <FSW-rtems-processing.h>
36 <FSW-rtems-processing.h>
37 <math.h>
37 <math.h>
38 <stdio.h>
38 <stdio.h>
39 <leon.h>
39 <leon.h>
40
40
41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
41 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h
42 <rtems.h>
42 <rtems.h>
43
43
44 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
44 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c
45 <FSW-rtems-processing.h>
45 <FSW-rtems-processing.h>
46 <math.h>
46 <math.h>
47 <stdio.h>
47 <stdio.h>
48 <leon.h>
48 <leon.h>
49
49
50 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h
50 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h
51 <rtems.h>
51 <rtems.h>
52 <grlibregs.h>
52 <grlibregs.h>
53 <FSW-params.h>
53 <FSW-params.h>
54
54
55 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c
55 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c
56 <rtems.h>
56 <rtems.h>
57 <bsp.h>
57 <bsp.h>
58 <rtems/confdefs.h>
58 <rtems/confdefs.h>
59 <drvmgr/drvmgr_confdefs.h>
59 <drvmgr/drvmgr_confdefs.h>
60 <FSW-rtems.h>
60 <FSW-rtems.h>
61 <FSW-config.c>
61 <FSW-config.c>
62
62
63 1359365823 /opt/DEV_PLE/src/FSW-config.c
63 1359365823 /opt/DEV_PLE/src/FSW-config.c
64 <drvmgr/ambapp_bus.h>
64 <drvmgr/ambapp_bus.h>
65
65
66 1359458568 source:/opt/DEV_PLE/src/TC_handler.c
66 1359458568 source:/opt/DEV_PLE/src/TC_handler.c
67 <TC_handler.h>
67 <TC_handler.h>
68 <FSW-params.h>
68 <FSW-params.h>
69
69
70 1359377846 /opt/DEV_PLE/header/TC_handler.h
70 1359377846 /opt/DEV_PLE/header/TC_handler.h
71 <stdio.h>
71 <stdio.h>
72 <ccsds_types.h>
72 <ccsds_types.h>
73
73
74 1359640245 /opt/DEV_PLE/header/ccsds_types.h
74 1359640245 /opt/DEV_PLE/header/ccsds_types.h
75
75
76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
76 1359365823 source:/opt/DEV_PLE/src/FSW-config.c
77 <drvmgr/ambapp_bus.h>
77 <drvmgr/ambapp_bus.h>
78
78
79 1359452642 /opt/DEV_PLE/header/FSW-config.h
79 1359452642 /opt/DEV_PLE/header/FSW-config.h
80
80
81 1359440704 /opt/DEV_PLE/header/grlibregs.h
81 1359440704 /opt/DEV_PLE/header/grlibregs.h
82
82
83 1359382989 source:/opt/DEV_PLE/src/WF_handler.c
83 1359382989 source:/opt/DEV_PLE/src/WF_handler.c
84
84
85 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c
85 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c
86 <FSW-misc.h>
86 <FSW-misc.h>
87 <FSW-params.h>
87 <FSW-params.h>
88
88
89 1359459330 /opt/DEV_PLE/header/FSW-misc.h
89 1359459330 /opt/DEV_PLE/header/FSW-misc.h
90 <rtems.h>
90 <rtems.h>
91 <stdio.h>
91 <stdio.h>
92 <FSW-rtems.h>
92 <FSW-rtems.h>
93 <FSW-params.h>
93 <FSW-params.h>
94 <grlibregs.h>
94 <grlibregs.h>
95 <grspw.h>
95 <grspw.h>
96 <ccsds_types.h>
96 <ccsds_types.h>
97
97
98 1359459364 /opt/DEV_PLE/header/FSW-rtems.h
98 1359459364 /opt/DEV_PLE/header/FSW-rtems.h
99 <errno.h>
99 <errno.h>
100 <fcntl.h>
100 <fcntl.h>
101 <stdio.h>
101 <stdio.h>
102 <stdlib.h>
102 <stdlib.h>
103 <grspw.h>
103 <grspw.h>
104 <apbuart.h>
104 <apbuart.h>
105 <FSW-params.h>
105 <FSW-params.h>
106 <FSW-misc.h>
106 <FSW-misc.h>
107 <FSW-rtems-processing.h>
107 <FSW-rtems-processing.h>
108 <TC_handler.h>
108 <TC_handler.h>
109 <WF_handler.h>
109 <WF_handler.h>
110 <grlibregs.h>
110 <grlibregs.h>
111
111
112 1359458453 /opt/DEV_PLE/header/FSW-params.h
112 1359458453 /opt/DEV_PLE/header/FSW-params.h
113
113
114 1359459642 /opt/DEV_PLE/header/WF_handler.h
114 1359459642 /opt/DEV_PLE/header/WF_handler.h
115 <rtems.h>
115 <rtems.h>
116 <FSW-params.h>
116 <FSW-params.h>
117 <grspw.h>
117 <grspw.h>
118 <grlibregs.h>
118 <grlibregs.h>
119 <ccsds_types.h>
119 <ccsds_types.h>
120 <stdio.h>
120 <stdio.h>
121 <FSW-rtems.h>
121 <FSW-rtems.h>
122
122
123 1359464354 source:/opt/DEV_PLE/src/fsw_main.c
123 1359464354 source:/opt/DEV_PLE/src/fsw_main.c
124 <rtems.h>
124 <rtems.h>
125 <bsp.h>
125 <bsp.h>
126 <rtems/confdefs.h>
126 <rtems/confdefs.h>
127 <drvmgr/drvmgr_confdefs.h>
127 <drvmgr/drvmgr_confdefs.h>
128 <fsw_main.h>
128 <fsw_main.h>
129 <fsw_config.c>
129 <fsw_config.c>
130
130
131 1359464346 /opt/DEV_PLE/header/fsw_main.h
131 1359464346 /opt/DEV_PLE/header/fsw_main.h
132 <errno.h>
132 <errno.h>
133 <fcntl.h>
133 <fcntl.h>
134 <stdio.h>
134 <stdio.h>
135 <stdlib.h>
135 <stdlib.h>
136 <grspw.h>
136 <grspw.h>
137 <apbuart.h>
137 <apbuart.h>
138 <fsw_params.h>
138 <fsw_params.h>
139 <fsw_misc.h>
139 <fsw_misc.h>
140 <fsw_processing.h>
140 <fsw_processing.h>
141 <tc_handler.h>
141 <tc_handler.h>
142 <wf_handler.h>
142 <wf_handler.h>
143 <grlib_regs.h>
143 <grlib_regs.h>
144
144
145 1359616894 /opt/DEV_PLE/header/fsw_params.h
145 1359959307 /opt/DEV_PLE/header/fsw_params.h
146
146
147 1359614518 /opt/DEV_PLE/header/fsw_misc.h
147 1359614518 /opt/DEV_PLE/header/fsw_misc.h
148 <rtems.h>
148 <rtems.h>
149 <stdio.h>
149 <stdio.h>
150 <fsw_init.h>
150 <fsw_init.h>
151 <fsw_params.h>
151 <fsw_params.h>
152 <grlib_regs.h>
152 <grlib_regs.h>
153 <grspw.h>
153 <grspw.h>
154 <ccsds_types.h>
154 <ccsds_types.h>
155
155
156 1359440704 /opt/DEV_PLE/header/grlib_regs.h
156 1359959822 /opt/DEV_PLE/header/grlib_regs.h
157
157
158 1359614517 /opt/DEV_PLE/header/fsw_processing.h
158 1359614517 /opt/DEV_PLE/header/fsw_processing.h
159 <rtems.h>
159 <rtems.h>
160 <grlib_regs.h>
160 <grlib_regs.h>
161 <fsw_params.h>
161 <fsw_params.h>
162
162
163 1359643450 /opt/DEV_PLE/header/tc_handler.h
163 1359959377 /opt/DEV_PLE/header/tc_handler.h
164 <rtems.h>
164 <rtems.h>
165 <stdio.h>
165 <stdio.h>
166 <unistd.h>
166 <unistd.h>
167 <sys/ioctl.h>
167 <sys/ioctl.h>
168 <ccsds_types.h>
168 <ccsds_types.h>
169 <grspw.h>
169 <grspw.h>
170 <fsw_init.h>
170 <fsw_init.h>
171
171
172 1359614518 /opt/DEV_PLE/header/wf_handler.h
172 1359614518 /opt/DEV_PLE/header/wf_handler.h
173 <rtems.h>
173 <rtems.h>
174 <fsw_params.h>
174 <fsw_params.h>
175 <grspw.h>
175 <grspw.h>
176 <grlib_regs.h>
176 <grlib_regs.h>
177 <ccsds_types.h>
177 <ccsds_types.h>
178 <stdio.h>
178 <stdio.h>
179 <fsw_init.h>
179 <fsw_init.h>
180
180
181 1359365823 /opt/DEV_PLE/src/fsw_config.c
181 1359365823 /opt/DEV_PLE/src/fsw_config.c
182 <drvmgr/ambapp_bus.h>
182 <drvmgr/ambapp_bus.h>
183
183
184 1359614518 source:/opt/DEV_PLE/src/fsw_misc.c
184 1359614518 source:/opt/DEV_PLE/src/fsw_misc.c
185 <fsw_misc.h>
185 <fsw_misc.h>
186 <fsw_params.h>
186 <fsw_params.h>
187
187
188 1359643720 source:/opt/DEV_PLE/src/tc_handler.c
188 1359715931 source:/opt/DEV_PLE/src/tc_handler.c
189 <tc_handler.h>
189 <tc_handler.h>
190 <fsw_params.h>
190 <fsw_params.h>
191
191
192 1359614518 source:/opt/DEV_PLE/src/wf_handler.c
192 1359715982 source:/opt/DEV_PLE/src/wf_handler.c
193 <wf_handler.h>
193 <wf_handler.h>
194
194
195 1359615705 source:/opt/DEV_PLE/src/fsw_globals.c
195 1359959319 source:/opt/DEV_PLE/src/fsw_globals.c
196 <fsw_processing.h>
196 <fsw_processing.h>
197 <rtems.h>
197 <rtems.h>
198
198
199 1359622160 source:/opt/DEV_PLE/src/fsw_init.c
199 1359959173 source:/opt/DEV_PLE/src/fsw_init.c
200 <rtems.h>
200 <rtems.h>
201 <bsp.h>
201 <bsp.h>
202 <rtems/confdefs.h>
202 <rtems/confdefs.h>
203 <drvmgr/drvmgr_confdefs.h>
203 <drvmgr/drvmgr_confdefs.h>
204 <fsw_init.h>
204 <fsw_init.h>
205 <fsw_config.c>
205 <fsw_config.c>
206
206
207 1359615705 /opt/DEV_PLE/header/fsw_init.h
207 1359714779 /opt/DEV_PLE/header/fsw_init.h
208 <errno.h>
208 <errno.h>
209 <fcntl.h>
209 <fcntl.h>
210 <stdio.h>
210 <stdio.h>
211 <stdlib.h>
211 <stdlib.h>
212 <grspw.h>
212 <grspw.h>
213 <apbuart.h>
213 <apbuart.h>
214 <fsw_params.h>
214 <fsw_params.h>
215 <fsw_misc.h>
215 <fsw_misc.h>
216 <fsw_processing.h>
216 <fsw_processing.h>
217 <tc_handler.h>
217 <tc_handler.h>
218 <wf_handler.h>
218 <wf_handler.h>
219 <grlib_regs.h>
219 <grlib_regs.h>
220
220
221 1359614518 source:/opt/DEV_PLE/src/fsw_processing.c
221 1359715903 source:/opt/DEV_PLE/src/fsw_processing.c
222 <fsw_processing.h>
222 <fsw_processing.h>
223 <math.h>
223 <math.h>
224 <stdio.h>
224 <stdio.h>
225 <leon.h>
225 <leon.h>
226
226
227 1359665502 source:/home/admin/opt/DEV_PLE/src/fsw_globals.c
227 1359665502 source:/home/admin/opt/DEV_PLE/src/fsw_globals.c
228 <fsw_processing.h>
228 <fsw_processing.h>
229 <rtems.h>
229 <rtems.h>
230
230
231 1359663364 /home/admin/opt/DEV_PLE/header/fsw_processing.h
231 1359663364 /home/admin/opt/DEV_PLE/header/fsw_processing.h
232 <rtems.h>
232 <rtems.h>
233 <grlib_regs.h>
233 <grlib_regs.h>
234 <fsw_params.h>
234 <fsw_params.h>
235
235
236 1359470426 /home/admin/opt/DEV_PLE/header/grlib_regs.h
236 1359470426 /home/admin/opt/DEV_PLE/header/grlib_regs.h
237
237
238 1359665475 /home/admin/opt/DEV_PLE/header/fsw_params.h
238 1359665475 /home/admin/opt/DEV_PLE/header/fsw_params.h
239
239
240 1359666330 source:/home/admin/opt/DEV_PLE/src/fsw_init.c
240 1359666330 source:/home/admin/opt/DEV_PLE/src/fsw_init.c
241 <rtems.h>
241 <rtems.h>
242 <bsp.h>
242 <bsp.h>
243 <rtems/confdefs.h>
243 <rtems/confdefs.h>
244 <drvmgr/drvmgr_confdefs.h>
244 <drvmgr/drvmgr_confdefs.h>
245 <fsw_init.h>
245 <fsw_init.h>
246 <fsw_config.c>
246 <fsw_config.c>
247
247
248 1359666373 /home/admin/opt/DEV_PLE/header/fsw_init.h
248 1359666373 /home/admin/opt/DEV_PLE/header/fsw_init.h
249 <errno.h>
249 <errno.h>
250 <fcntl.h>
250 <fcntl.h>
251 <stdio.h>
251 <stdio.h>
252 <stdlib.h>
252 <stdlib.h>
253 <grspw.h>
253 <grspw.h>
254 <apbuart.h>
254 <apbuart.h>
255 <fsw_params.h>
255 <fsw_params.h>
256 <fsw_misc.h>
256 <fsw_misc.h>
257 <fsw_processing.h>
257 <fsw_processing.h>
258 <tc_handler.h>
258 <tc_handler.h>
259 <wf_handler.h>
259 <wf_handler.h>
260 <grlib_regs.h>
260 <grlib_regs.h>
261
261
262 1359663364 /home/admin/opt/DEV_PLE/header/fsw_misc.h
262 1359663364 /home/admin/opt/DEV_PLE/header/fsw_misc.h
263 <rtems.h>
263 <rtems.h>
264 <stdio.h>
264 <stdio.h>
265 <fsw_init.h>
265 <fsw_init.h>
266 <fsw_params.h>
266 <fsw_params.h>
267 <grlib_regs.h>
267 <grlib_regs.h>
268 <grspw.h>
268 <grspw.h>
269 <ccsds_types.h>
269 <ccsds_types.h>
270
270
271 1359663364 /home/admin/opt/DEV_PLE/header/ccsds_types.h
271 1359663364 /home/admin/opt/DEV_PLE/header/ccsds_types.h
272
272
273 1359665643 /home/admin/opt/DEV_PLE/header/tc_handler.h
273 1359665643 /home/admin/opt/DEV_PLE/header/tc_handler.h
274 <rtems.h>
274 <rtems.h>
275 <stdio.h>
275 <stdio.h>
276 <unistd.h>
276 <unistd.h>
277 <sys/ioctl.h>
277 <sys/ioctl.h>
278 <ccsds_types.h>
278 <ccsds_types.h>
279 <grspw.h>
279 <grspw.h>
280 <fsw_init.h>
280 <fsw_init.h>
281
281
282 1359663364 /home/admin/opt/DEV_PLE/header/wf_handler.h
282 1359663364 /home/admin/opt/DEV_PLE/header/wf_handler.h
283 <rtems.h>
283 <rtems.h>
284 <fsw_params.h>
284 <fsw_params.h>
285 <grspw.h>
285 <grspw.h>
286 <grlib_regs.h>
286 <grlib_regs.h>
287 <ccsds_types.h>
287 <ccsds_types.h>
288 <stdio.h>
288 <stdio.h>
289 <fsw_init.h>
289 <fsw_init.h>
290
290
291 1359470426 /home/admin/opt/DEV_PLE/src/fsw_config.c
291 1359470426 /home/admin/opt/DEV_PLE/src/fsw_config.c
292 <drvmgr/ambapp_bus.h>
292 <drvmgr/ambapp_bus.h>
293
293
294 1359663364 source:/home/admin/opt/DEV_PLE/src/fsw_misc.c
294 1359663364 source:/home/admin/opt/DEV_PLE/src/fsw_misc.c
295 <fsw_misc.h>
295 <fsw_misc.h>
296 <fsw_params.h>
296 <fsw_params.h>
297
297
298 1359663364 source:/home/admin/opt/DEV_PLE/src/fsw_processing.c
298 1359663364 source:/home/admin/opt/DEV_PLE/src/fsw_processing.c
299 <fsw_processing.h>
299 <fsw_processing.h>
300 <math.h>
300 <math.h>
301 <stdio.h>
301 <stdio.h>
302 <leon.h>
302 <leon.h>
303
303
304 1359663364 source:/home/admin/opt/DEV_PLE/src/wf_handler.c
304 1359663364 source:/home/admin/opt/DEV_PLE/src/wf_handler.c
305 <wf_handler.h>
305 <wf_handler.h>
306
306
307 1359665083 source:/home/admin/opt/DEV_PLE/src/tc_handler.c
307 1359665083 source:/home/admin/opt/DEV_PLE/src/tc_handler.c
308 <tc_handler.h>
308 <tc_handler.h>
309 <fsw_params.h>
309 <fsw_params.h>
310
310
@@ -1,43 +1,46
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_layout_file>
2 <CodeBlocks_layout_file>
3 <ActiveTarget name="Debug" />
3 <ActiveTarget name="Debug" />
4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="5">
4 <File name="../header/ccsds_types.h" open="1" top="0" tabpos="3">
5 <Cursor position="4079" topLine="120" />
5 <Cursor position="3403" topLine="101" />
6 </File>
6 </File>
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="3">
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="3">
8 <Cursor position="1128" topLine="26" />
8 <Cursor position="899" topLine="0" />
9 </File>
9 </File>
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
11 <Cursor position="114" topLine="0" />
11 <Cursor position="114" topLine="0" />
12 </File>
12 </File>
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="0">
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="0">
14 <Cursor position="1374" topLine="49" />
14 <Cursor position="2405" topLine="52" />
15 </File>
15 </File>
16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
17 <Cursor position="576" topLine="0" />
17 <Cursor position="576" topLine="0" />
18 </File>
18 </File>
19 <File name="../header/grlib_regs.h" open="0" top="0" tabpos="0">
20 <Cursor position="1072" topLine="0" />
21 </File>
19 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
22 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
20 <Cursor position="437" topLine="35" />
23 <Cursor position="481" topLine="0" />
21 </File>
24 </File>
22 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
25 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
23 <Cursor position="212" topLine="0" />
26 <Cursor position="212" topLine="0" />
24 </File>
27 </File>
25 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="4">
28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="4">
26 <Cursor position="1271" topLine="18" />
29 <Cursor position="1531" topLine="1" />
27 </File>
30 </File>
28 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
31 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
29 <Cursor position="1814" topLine="48" />
32 <Cursor position="9387" topLine="83" />
30 </File>
33 </File>
31 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
34 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
32 <Cursor position="20" topLine="0" />
35 <Cursor position="20" topLine="0" />
33 </File>
36 </File>
34 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2">
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="3">
35 <Cursor position="1175" topLine="46" />
38 <Cursor position="1797" topLine="73" />
36 </File>
39 </File>
37 <File name="../src/tc_handler.c" open="1" top="1" tabpos="2">
40 <File name="../src/tc_handler.c" open="1" top="1" tabpos="2">
38 <Cursor position="13133" topLine="89" />
41 <Cursor position="10603" topLine="21" />
39 </File>
42 </File>
40 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
41 <Cursor position="3936" topLine="62" />
44 <Cursor position="542" topLine="0" />
42 </File>
45 </File>
43 </CodeBlocks_layout_file>
46 </CodeBlocks_layout_file>
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,47 +1,52
1 #ifndef FSW_RTEMS_H_INCLUDED
1 #ifndef FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
3
3
4 #include <errno.h>
4 #include <errno.h>
5 #include <fcntl.h>
5 #include <fcntl.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <stdlib.h>
7 #include <stdlib.h>
8
8
9 #include <grspw.h>
9 #include <grspw.h>
10 #include <apbuart.h>
10 #include <apbuart.h>
11
11
12 #include <fsw_params.h>
12 #include <fsw_params.h>
13 #include <fsw_misc.h>
13 #include <fsw_misc.h>
14 #include <fsw_processing.h>
14 #include <fsw_processing.h>
15 #include <tc_handler.h>
15 #include <tc_handler.h>
16 #include <wf_handler.h>
16 #include <wf_handler.h>
17 #include <grlib_regs.h>
17 #include <grlib_regs.h>
18
18
19 extern int sched_yield();
19 extern int sched_yield();
20 extern int errno;
20 extern int errno;
21 extern rtems_id Task_id[ ]; /* array of task ids */
21 extern rtems_id Task_id[ ]; /* array of task ids */
22 extern rtems_name Task_name[ ]; /* array of task names */
22 extern rtems_name Task_name[ ]; /* array of task names */
23 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
23 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
24 extern int fdSPW; // grspw file descriptor
24 extern int fdSPW; // grspw file descriptor
25 extern int fdUART; // uart file descriptor
25 extern int fdUART; // uart file descriptor
26 // MODE PARAMETERS
26 extern struct param_norm_str param_norm;
27 extern struct param_norm_str param_norm;
28 extern struct param_burst_str param_burst;
29 extern struct param_sbm1_str param_sbm1;
30 extern struct param_sbm2_str param_sbm2;
31 extern unsigned char param_common[];
27
32
28 // RTEMS TASKS
33 // RTEMS TASKS
29 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
34 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
30 rtems_task recv_task(rtems_task_argument argument);
35 rtems_task recv_task(rtems_task_argument argument);
31 rtems_task spiq_task(rtems_task_argument argument);
36 rtems_task spiq_task(rtems_task_argument argument);
32 rtems_task stat_task(rtems_task_argument argument);
37 rtems_task stat_task(rtems_task_argument argument);
33 rtems_task wfrm_task(rtems_task_argument argument);
38 rtems_task wfrm_task(rtems_task_argument argument);
34 int create_all_tasks();
39 int create_all_tasks();
35 int start_all_tasks();
40 int start_all_tasks();
36 int create_message_queue();
41 int create_message_queue();
37
42
38 // OTHER functions
43 // OTHER functions
39 void init_default_mode_parameters();
44 void init_default_mode_parameters();
40 int configure_spw_link();
45 int configure_spw_link();
41 int send_console_outputs_on_serial_port();
46 int send_console_outputs_on_serial_port();
42 extern int rtems_cpu_usage_report();
47 extern int rtems_cpu_usage_report();
43 extern int rtems_cpu_usage_reset();
48 extern int rtems_cpu_usage_reset();
44 void print_statistics(spw_stats *);
49 void print_statistics(spw_stats *);
45 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
50 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
46
51
47 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
52 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,68 +1,92
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3
3
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 #define UART_DEVICE_NAME "/dev/console"
5 #define UART_DEVICE_NAME "/dev/console"
6
6
7 //**********
8 // LFR MODES
9 #define LFR_MODE_STANDBY 0
10 #define LFR_MODE_NORMAL 1
11 #define LFR_MODE_BURST 2
12 #define LFR_MODE_SBM1 3
13 #define LFR_MODE_SBM2 4
14
7 //*****************************
15 //*****************************
8 // APB REGISTERS BASE ADDRESSES
16 // APB REGISTERS BASE ADDRESSES
9 #define REGS_ADDR_APBUART 0x80000100
17 #define REGS_ADDR_APBUART 0x80000100
10 #define REGS_ADDR_GPTIMER 0x80000300
18 #define REGS_ADDR_GPTIMER 0x80000300
11 #define REGS_ADDR_GRSPW 0x80000500
19 #define REGS_ADDR_GRSPW 0x80000500
20 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
12 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
21 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
13
22
14 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
23 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
15
24
16 #define IRQ_SM 9
25 #define IRQ_SM 9
17 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
26 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
18 #define IRQ_WF 10
27 #define IRQ_WF 10
19 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
28 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
20
29
21 #define CLKDIV_SM_SIMULATOR 9999
30 #define CLKDIV_SM_SIMULATOR 9999
22 #define CLKDIV_WF_SIMULATOR 9999999
31 #define CLKDIV_WF_SIMULATOR 9999999
23 #define TIMER_SM_SIMULATOR 1
32 #define TIMER_SM_SIMULATOR 1
24 #define TIMER_WF_SIMULATOR 2
33 #define TIMER_WF_SIMULATOR 2
25
34
26 //******
35 //******
27 // RTEMS
36 // RTEMS
28 #define TASKID_RECV 1
37 #define TASKID_RECV 1
29 #define TASKID_ACTN 1
38 #define TASKID_ACTN 1
30 #define TASKID_SPIQ 3
39 #define TASKID_SPIQ 3
31 #define TASKID_SMIQ 4
40 #define TASKID_SMIQ 4
32 #define TASKID_STAT 5
41 #define TASKID_STAT 5
33 #define TASKID_AVF0 6
42 #define TASKID_AVF0 6
34 #define TASKID_BPF0 7
43 #define TASKID_BPF0 7
35 #define TASKID_WFRM 8
44 #define TASKID_WFRM 8
36
45
37 #define ACTION_MSG_QUEUE_COUNT 10
46 #define ACTION_MSG_QUEUE_COUNT 10
38
47
39 //*******
48 //*******
40 // MACROS
49 // MACROS
41 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
50 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
42 #ifdef PRINT_MESSAGES_ON_CONSOLE
51 #ifdef PRINT_MESSAGES_ON_CONSOLE
43 #define PRINTF(x) printf(x);
52 #define PRINTF(x) printf(x);
44 #define PRINTF1(x,y) printf(x,y);
53 #define PRINTF1(x,y) printf(x,y);
45 #define PRINTF2(x,y,z) printf(x,y,z);
54 #define PRINTF2(x,y,z) printf(x,y,z);
46 #else
55 #else
47 #define PRINTF(x) ;
56 #define PRINTF(x) ;
48 #define PRINTF1(x,y) ;
57 #define PRINTF1(x,y) ;
49 #define PRINTF2(x,y,z) ;
58 #define PRINTF2(x,y,z) ;
50 #endif
59 #endif
51
60
52 #define NB_SAMPLES_PER_SNAPSHOT 2048
61 #define NB_SAMPLES_PER_SNAPSHOT 2048
53 #define NB_BYTES_SWF_BLK 2 * 6
62 #define NB_BYTES_SWF_BLK 2 * 6
54
63
55 struct param_norm_str{
64 struct param_norm_str{
56 unsigned int sy_lfr_n_swf_l; // length of the snapshots
65 unsigned int sy_lfr_n_swf_l; // length of the snapshots
57 unsigned int sy_lfr_n_swf_p; // time between two snapshots
66 unsigned int sy_lfr_n_swf_p; // time between two snapshots
58 unsigned int sy_lfr_n_asm_p; // time between two asm
67 unsigned int sy_lfr_n_asm_p; // time between two asm
59 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
68 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
69 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
61 };
70 };
62
71
72 struct param_burst_str{
73 unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set
74 unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set
75 };
76
77 struct param_sbm1_str{
78 unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set
79 unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set
80 };
81
82 struct param_sbm2_str{
83 unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set
84 unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set
85 };
86
63 extern volatile int wf_snap_f0[ ]; // 24576 bytes
87 extern volatile int wf_snap_f0[ ]; // 24576 bytes
64 extern volatile int wf_snap_f1[ ]; // 24576 bytes
88 extern volatile int wf_snap_f1[ ]; // 24576 bytes
65 extern volatile int wf_snap_f2[ ]; // 24576 bytes
89 extern volatile int wf_snap_f2[ ]; // 24576 bytes
66 extern volatile int wf_cont_f3[ ]; // 24576 bytes
90 extern volatile int wf_cont_f3[ ]; // 24576 bytes
67
91
68 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
92 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,40 +1,48
1 #ifndef GRLIBREGS_H_INCLUDED
1 #ifndef GRLIBREGS_H_INCLUDED
2 #define GRLIBREGS_H_INCLUDED
2 #define GRLIBREGS_H_INCLUDED
3
3
4 #define NB_GPTIMER 3
4 #define NB_GPTIMER 3
5
5
6 struct apbuart_regs_str{
6 struct apbuart_regs_str{
7 volatile unsigned int data;
7 volatile unsigned int data;
8 volatile unsigned int status;
8 volatile unsigned int status;
9 volatile unsigned int ctrl;
9 volatile unsigned int ctrl;
10 volatile unsigned int scaler;
10 volatile unsigned int scaler;
11 volatile unsigned int fifoDebug;
11 volatile unsigned int fifoDebug;
12 };
12 };
13
13
14 struct timer_regs_str
14 struct timer_regs_str
15 {
15 {
16 volatile unsigned int counter;
16 volatile unsigned int counter;
17 volatile unsigned int reload;
17 volatile unsigned int reload;
18 volatile unsigned int ctrl;
18 volatile unsigned int ctrl;
19 volatile unsigned int unused;
19 volatile unsigned int unused;
20 };
20 };
21 typedef struct timer_regs_str timer_regs_t;
21 typedef struct timer_regs_str timer_regs_t;
22
22
23 struct gptimer_regs_str
23 struct gptimer_regs_str
24 {
24 {
25 volatile unsigned int scaler_value;
25 volatile unsigned int scaler_value;
26 volatile unsigned int scaler_reload;
26 volatile unsigned int scaler_reload;
27 volatile unsigned int conf;
27 volatile unsigned int conf;
28 volatile unsigned int unused0;
28 volatile unsigned int unused0;
29 timer_regs_t timer[NB_GPTIMER];
29 timer_regs_t timer[NB_GPTIMER];
30 };
30 };
31 typedef struct gptimer_regs_str gptimer_regs_t;
31 typedef struct gptimer_regs_str gptimer_regs_t;
32
32
33 struct spectral_matrices_regs_str{
33 struct spectral_matrices_regs_str{
34 volatile int ctrl;
34 volatile int ctrl;
35 volatile int address0;
35 volatile int address0;
36 volatile int address1;
36 volatile int address1;
37 };
37 };
38 typedef struct spectral_matrices_regs_str spectral_matrices_regs_t;
38 typedef struct spectral_matrices_regs_str spectral_matrices_regs_t;
39
39
40 struct time_management_regs_str{
41 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 volatile int coarse_time_load;
43 volatile int coarse_time;
44 volatile int fine_time;
45 };
46 typedef struct time_management_regs_str time_management_regs_t;
47
40 #endif // GRLIBREGS_H_INCLUDED
48 #endif // GRLIBREGS_H_INCLUDED
@@ -1,54 +1,63
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <bsp.h> // for the LEON_Unmask_interrupt function
5 #include <stdio.h>
6 #include <stdio.h>
6 #include <unistd.h> // for the read call
7 #include <unistd.h> // for the read call
7 #include <sys/ioctl.h> // for the ioctl call
8 #include <sys/ioctl.h> // for the ioctl call
8 #include <ccsds_types.h>
9 #include <ccsds_types.h>
9 #include <grspw.h>
10 #include <grspw.h>
10 #include <fsw_init.h>
11 #include <fsw_init.h>
11
12
12 extern int fdSPW;
13 extern int fdSPW;
13 extern rtems_name misc_name[ ];
14 extern rtems_name misc_name[ ];
14 extern rtems_name misc_id[ ];
15 extern rtems_name misc_id[ ];
15 extern rtems_id Task_id[ ]; // array of task ids
16 extern rtems_id Task_id[ ]; // array of task ids
17 // MODE PARAMETERS
16 extern struct param_norm_str param_norm;
18 extern struct param_norm_str param_norm;
19 extern struct param_sbm1_str param_sbm1;
20 extern struct param_sbm2_str param_sbm2;
21 extern time_management_regs_t *time_management_regs;
22 extern unsigned char param_common[];
17
23
18 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
24 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
19 unsigned char currentTC_COMPUTED_CRC[2];
25 unsigned char currentTC_COMPUTED_CRC[2];
20 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
26 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
21 unsigned int currentTM_length;
27 unsigned int currentTM_length;
22 unsigned char currentTC_processedFlag;
28 unsigned char currentTC_processedFlag;
23
29
24 //**********************
30 //**********************
25 // GENERAL USE FUNCTIONS
31 // GENERAL USE FUNCTIONS
26 unsigned int lookUpTableForCRC[256];
32 unsigned int lookUpTableForCRC[256];
27 void InitLookUpTableForCRC();
33 void initLookUpTableForCRC();
28 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
34 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
29
35
30 //*********************
36 //*********************
31 // ACCEPTANCE FUNCTIONS
37 // ACCEPTANCE FUNCTIONS
32 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
38 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
33
39
34 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
40 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
35 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
41 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
36 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
42 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
37 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
43 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
38
44
39 //***********
45 //***********
40 // RTEMS TASK
46 // RTEMS TASK
41 rtems_task recv_task( rtems_task_argument unused );
47 rtems_task recv_task( rtems_task_argument unused );
42 rtems_task actn_task( rtems_task_argument unused );
48 rtems_task actn_task( rtems_task_argument unused );
43 int create_message_queue();
49 int create_message_queue();
44
50
45 //***********
51 //***********
46 // TC ACTIONS
52 // TC ACTIONS
47 int action_default(ccsdsTelecommandPacket_t *TC);
53 int action_default(ccsdsTelecommandPacket_t *TC);
54 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
55 //
48 int action_load_norm(ccsdsTelecommandPacket_t *TC);
56 int action_load_norm(ccsdsTelecommandPacket_t *TC);
49 int action_enter(ccsdsTelecommandPacket_t *TC);
57 int action_enter(ccsdsTelecommandPacket_t *TC);
58 int action_updt_time(ccsdsTelecommandPacket_t *TC);
50
59
51 #endif // TC_HANDLER_H_INCLUDED
60 #endif // TC_HANDLER_H_INCLUDED
52
61
53
62
54
63
@@ -1,37 +1,44
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3
3
4 // RTEMS GLOBAL VARIABLES
4 // RTEMS GLOBAL VARIABLES
5 rtems_name misc_name[5];
5 rtems_name misc_name[5];
6 rtems_name misc_id[5];
6 rtems_name misc_id[5];
7 rtems_id Task_id[10]; /* array of task ids */
7 rtems_id Task_id[10]; /* array of task ids */
8 rtems_name Task_name[10]; /* array of task names */
8 rtems_name Task_name[10]; /* array of task names */
9 int fdSPW;
9 int fdSPW;
10 int fdUART;
10 int fdUART;
11
11
12 // APB CONFIGURATION REGISTERS
13 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
14
12 // WAVEFORMS GLOBAL VARIABLES
15 // WAVEFORMS GLOBAL VARIABLES
13 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
16 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
14 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
17 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
15 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
18 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
16 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
19 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
17
20
18 // SPECTRAL MATRICES GLOBAL VARIABLES
21 // SPECTRAL MATRICES GLOBAL VARIABLES
19 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
22 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
20 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
23 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
21 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
24 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
22 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
25 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
23 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
26 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
24 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
27 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
25 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
28 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
26 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
29 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
27 //
30 //
28 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
31 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
29 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
32 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
30
33
31 // NORMAL MODE PARAMETERS
34 // MODE PARAMETERS
32 struct param_norm_str param_norm;
35 struct param_norm_str param_norm;
36 struct param_burst_str param_burst;
37 struct param_sbm1_str param_sbm1;
38 struct param_sbm2_str param_sbm2;
39 unsigned char param_common[2];
33
40
34 // BASIC PARAMETERS GLOBAL VARIABLES
41 // BASIC PARAMETERS GLOBAL VARIABLES
35 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
42 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
36
43
37 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
44 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
@@ -1,264 +1,272
1 //*************************
1 //*************************
2 // GPL reminder to be added
2 // GPL reminder to be added
3 //*************************
3 //*************************
4
4
5 #include <rtems.h>
5 #include <rtems.h>
6
6
7 /* configuration information */
7 /* configuration information */
8
8
9 #define CONFIGURE_INIT
9 #define CONFIGURE_INIT
10
10
11 #include <bsp.h> /* for device driver prototypes */
11 #include <bsp.h> /* for device driver prototypes */
12
12
13 /* configuration information */
13 /* configuration information */
14
14
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17
17
18 #define CONFIGURE_MAXIMUM_TASKS 10
18 #define CONFIGURE_MAXIMUM_TASKS 10
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_PERIODS 1
24 #define CONFIGURE_MAXIMUM_PERIODS 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
26
26
27 #include <rtems/confdefs.h>
27 #include <rtems/confdefs.h>
28
28
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
30 #ifdef RTEMS_DRVMGR_STARTUP
30 #ifdef RTEMS_DRVMGR_STARTUP
31 #ifdef LEON3
31 #ifdef LEON3
32 /* Add Timer and UART Driver */
32 /* Add Timer and UART Driver */
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
35 #endif
35 #endif
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
38 #endif
38 #endif
39 #endif
39 #endif
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
41 #include <drvmgr/drvmgr_confdefs.h>
41 #include <drvmgr/drvmgr_confdefs.h>
42 #endif
42 #endif
43
43
44 #include <fsw_init.h>
44 #include <fsw_init.h>
45 #include <fsw_config.c>
45 #include <fsw_config.c>
46
46
47 char *link_status(int status);
47 char *link_status(int status);
48
48
49 char *lstates[6] = {"Error-reset",
49 char *lstates[6] = {"Error-reset",
50 "Error-wait",
50 "Error-wait",
51 "Ready",
51 "Ready",
52 "Started",
52 "Started",
53 "Connecting",
53 "Connecting",
54 "Run"
54 "Run"
55 };
55 };
56
56
57 rtems_task Init( rtems_task_argument ignored )
57 rtems_task Init( rtems_task_argument ignored )
58 {
58 {
59 rtems_status_code status;
59 rtems_status_code status;
60
60
61 //send_console_outputs_on_serial_port();
61 //send_console_outputs_on_serial_port();
62
62
63 InitLookUpTableForCRC(); // in tc_handler.h
63 initLookUpTableForCRC(); // in tc_handler.h
64 init_default_mode_parameters();
64 init_default_mode_parameters();
65 create_message_queue();
65 create_message_queue();
66 create_all_tasks();
66 create_all_tasks();
67 start_all_tasks();
67 start_all_tasks();
68
68
69 configure_spw_link();
69 configure_spw_link();
70 // configure timer for spectral matrices simulation
71 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
70 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
72 IRQ_SPARC_SM, spectral_matrices_isr );
71 IRQ_SPARC_SM, spectral_matrices_isr );
73 // configure timer for waveforms simulation
74 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
72 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
75 IRQ_SPARC_WF, waveforms_isr );
73 IRQ_SPARC_WF, waveforms_isr );
76
74
77 LEON_Unmask_interrupt( IRQ_SM );
78 LEON_Unmask_interrupt( IRQ_WF );
79
80 status = rtems_task_delete(RTEMS_SELF);
75 status = rtems_task_delete(RTEMS_SELF);
81 }
76 }
82
77
83 rtems_task spiq_task(rtems_task_argument unused)
78 rtems_task spiq_task(rtems_task_argument unused)
84 {
79 {
85 rtems_event_set event_out;
80 rtems_event_set event_out;
86 struct grspw_regs_str *grspw_regs;
81 struct grspw_regs_str *grspw_regs;
87 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
82 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
88
83
89 while(1){
84 while(1){
90 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
85 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
91 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
86 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
92
87
93 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
88 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
94 PRINTF("In SPIQ *** Error suspending RECV Task\n")
89 PRINTF("In SPIQ *** Error suspending RECV Task\n")
95
90
96 configure_spw_link();
91 configure_spw_link();
97
92
98 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
93 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
99 PRINTF("In SPIQ *** Error resume RECV Task\n")
94 PRINTF("In SPIQ *** Error resume RECV Task\n")
100 }
95 }
101 }
96 }
102
97
103 void init_default_mode_parameters()
98 void init_default_mode_parameters()
104 {
99 {
100 // COMMON PARAMETERS
101 param_common[0] = 0x00;
102 param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0
103 // NORMAL MODE
105 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
104 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
106 param_norm.sy_lfr_n_swf_p = 300; // sec
105 param_norm.sy_lfr_n_swf_p = 300; // sec
107 param_norm.sy_lfr_n_asm_p = 3600; // sec
106 param_norm.sy_lfr_n_asm_p = 3600; // sec
108 param_norm.sy_lfr_n_bp_p0 = 4; // sec
107 param_norm.sy_lfr_n_bp_p0 = 4; // sec
109 param_norm.sy_lfr_n_bp_p1 = 20; // sec
108 param_norm.sy_lfr_n_bp_p1 = 20; // sec
109 // BURST MODE
110 param_burst.sy_lfr_b_bp_p0 = 1; // sec
111 param_burst.sy_lfr_b_bp_p1 = 5; // sec
112 // SBM1 MODE
113 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
114 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
115 // SBM2 MODE
116 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
117 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
110 }
118 }
111
119
112 int create_all_tasks()
120 int create_all_tasks()
113 {
121 {
114 rtems_status_code status;
122 rtems_status_code status;
115
123
116 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
124 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
117 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
125 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
118 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
126 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
119 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
127 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
120 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
128 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
121 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
129 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
122 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
130 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
123 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
131 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
124
132
125 // RECV
133 // RECV
126 status = rtems_task_create(
134 status = rtems_task_create(
127 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
135 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
128 RTEMS_DEFAULT_MODES,
136 RTEMS_DEFAULT_MODES,
129 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
137 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
130 );
138 );
131 // ACTN
139 // ACTN
132 status = rtems_task_create(
140 status = rtems_task_create(
133 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
141 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
134 RTEMS_DEFAULT_MODES,
142 RTEMS_DEFAULT_MODES,
135 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
143 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
136 );
144 );
137 // SPIQ
145 // SPIQ
138 status = rtems_task_create(
146 status = rtems_task_create(
139 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
147 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
140 RTEMS_DEFAULT_MODES,
148 RTEMS_DEFAULT_MODES,
141 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
149 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
142 );
150 );
143 // SMIQ
151 // SMIQ
144 status = rtems_task_create(
152 status = rtems_task_create(
145 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
153 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
146 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
154 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
147 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
155 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
148 );
156 );
149 // STAT
157 // STAT
150 status = rtems_task_create(
158 status = rtems_task_create(
151 Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
159 Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
152 RTEMS_DEFAULT_MODES,
160 RTEMS_DEFAULT_MODES,
153 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
161 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
154 );
162 );
155 // AVF0
163 // AVF0
156 status = rtems_task_create(
164 status = rtems_task_create(
157 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
165 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
158 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
166 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
159 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
167 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
160 );
168 );
161 // BPF0
169 // BPF0
162 status = rtems_task_create(
170 status = rtems_task_create(
163 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
171 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
164 RTEMS_DEFAULT_MODES,
172 RTEMS_DEFAULT_MODES,
165 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
173 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
166 );
174 );
167 // WFRM
175 // WFRM
168 status = rtems_task_create(
176 status = rtems_task_create(
169 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
177 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
170 RTEMS_DEFAULT_MODES,
178 RTEMS_DEFAULT_MODES,
171 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
179 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
172 );
180 );
173
181
174 return 0;
182 return 0;
175 }
183 }
176
184
177 int start_all_tasks()
185 int start_all_tasks()
178 {
186 {
179 rtems_status_code status;
187 rtems_status_code status;
180
188
181 status = rtems_task_start( Task_id[3], spiq_task, 1 );
189 status = rtems_task_start( Task_id[3], spiq_task, 1 );
182 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
190 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
183
191
184 status = rtems_task_start( Task_id[1], recv_task, 1 );
192 status = rtems_task_start( Task_id[1], recv_task, 1 );
185 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
193 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
186
194
187 status = rtems_task_start( Task_id[2], actn_task, 1 );
195 status = rtems_task_start( Task_id[2], actn_task, 1 );
188 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
196 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
189
197
190 status = rtems_task_start( Task_id[4], smiq_task, 1 );
198 status = rtems_task_start( Task_id[4], smiq_task, 1 );
191 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
199 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
192
200
193 status = rtems_task_start( Task_id[5], stat_task, 1 );
201 status = rtems_task_start( Task_id[5], stat_task, 1 );
194 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
202 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
195
203
196 status = rtems_task_start( Task_id[6], avf0_task, 1 );
204 status = rtems_task_start( Task_id[6], avf0_task, 1 );
197 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
205 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
198
206
199 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
207 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
200 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
208 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
201
209
202 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
210 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
203 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
211 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
204
212
205 return 0;
213 return 0;
206 }
214 }
207
215
208 int configure_spw_link()
216 int configure_spw_link()
209 {
217 {
210 rtems_status_code status;
218 rtems_status_code status;
211
219
212 close(fdSPW); // close the device if it is already open
220 close(fdSPW); // close the device if it is already open
213 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
221 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
214 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
222 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
215 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
223 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
216 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
224 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
217 close(fdSPW); // close the device
225 close(fdSPW); // close the device
218 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
226 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
219 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
227 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
220 rtems_task_wake_after(100);
228 rtems_task_wake_after(100);
221 }
229 }
222
230
223 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
231 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
224
232
225 // sets a few parameters of the link
233 // sets a few parameters of the link
226 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
234 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
227 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
235 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
228 //
236 //
229 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
237 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
230 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
238 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
231 //
239 //
232 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
240 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
233 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
241 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
234 //
242 //
235 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
243 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
236 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
244 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
237 //
245 //
238 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
246 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
239 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
247 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
240
248
241 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
249 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
242 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
250 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
243 //
251 //
244 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
252 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
245 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
253 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
246 //
254 //
247 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
255 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
248
256
249 return RTEMS_SUCCESSFUL;
257 return RTEMS_SUCCESSFUL;
250 }
258 }
251
259
252 char *link_status(int status){
260 char *link_status(int status){
253 return lstates[status];
261 return lstates[status];
254 }
262 }
255
263
256 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
264 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
257 {
265 {
258 rtems_status_code status;
266 rtems_status_code status;
259 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
267 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
260 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
268 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
261 return status;
269 return status;
262 }
270 }
263
271
264
272
@@ -1,423 +1,427
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <math.h>
2 #include <math.h>
3 #include <stdio.h>
3 #include <stdio.h>
4 #include <leon.h>
4 #include <leon.h>
5
5
6 float k14_re = 1;
6 float k14_re = 1;
7 float k14_im = 1;
7 float k14_im = 1;
8 float k14_bis_re = 1;
8 float k14_bis_re = 1;
9 float k14_bis_im = 1;
9 float k14_bis_im = 1;
10 float k14_tris_re = 1;
10 float k14_tris_re = 1;
11 float k14_tris_im = 1;
11 float k14_tris_im = 1;
12 float k15_re = 1;
12 float k15_re = 1;
13 float k15_im = 1;
13 float k15_im = 1;
14 float k15_bis_re = 1;
14 float k15_bis_re = 1;
15 float k15_bis_im = 1;
15 float k15_bis_im = 1;
16 float k24_re = 1;
16 float k24_re = 1;
17 float k24_im = 1;
17 float k24_im = 1;
18 float k24_bis_re = 1;
18 float k24_bis_re = 1;
19 float k24_bis_im = 1;
19 float k24_bis_im = 1;
20 float k24_tris_re = 1;
20 float k24_tris_re = 1;
21 float k24_tris_im = 1;
21 float k24_tris_im = 1;
22 float k25_re = 1;
22 float k25_re = 1;
23 float k25_im = 1;
23 float k25_im = 1;
24 float k25_bis_re = 1;
24 float k25_bis_re = 1;
25 float k25_bis_im = 1;
25 float k25_bis_im = 1;
26 float k34_re = 1;
26 float k34_re = 1;
27 float k34_im = 1;
27 float k34_im = 1;
28 float k44 = 1;
28 float k44 = 1;
29 float k55 = 1;
29 float k55 = 1;
30 float k45_re = 1;
30 float k45_re = 1;
31 float k45_im = 1;
31 float k45_im = 1;
32 float alpha_M = M_PI/4;
32 float alpha_M = M_PI/4;
33
33
34 extern volatile int spec_mat_f0_a[ ];
34 extern volatile int spec_mat_f0_a[ ];
35 extern volatile int spec_mat_f0_b[ ];
35 extern volatile int spec_mat_f0_b[ ];
36 extern volatile int spec_mat_f0_c[ ];
36 extern volatile int spec_mat_f0_c[ ];
37 extern volatile int spec_mat_f0_d[ ];
37 extern volatile int spec_mat_f0_d[ ];
38 extern volatile int spec_mat_f0_e[ ];
38 extern volatile int spec_mat_f0_e[ ];
39 extern volatile int spec_mat_f0_f[ ];
39 extern volatile int spec_mat_f0_f[ ];
40 extern volatile int spec_mat_f0_g[ ];
40 extern volatile int spec_mat_f0_g[ ];
41 extern volatile int spec_mat_f0_h[ ];
41 extern volatile int spec_mat_f0_h[ ];
42 extern float averaged_spec_mat_f0[ ];
42 extern float averaged_spec_mat_f0[ ];
43 extern float compressed_spec_mat_f0[ ];
43 extern float compressed_spec_mat_f0[ ];
44 extern unsigned char LFR_BP1_F0[ ];
44 extern unsigned char LFR_BP1_F0[ ];
45
45
46 extern BP1_t data_BP1[ ];
46 extern BP1_t data_BP1[ ];
47
47
48 extern rtems_id Task_id[ ]; /* array of task ids */
48 extern rtems_id Task_id[ ]; /* array of task ids */
49
49
50 spectral_matrices_regs_t *spectral_matrices_regs;
50 spectral_matrices_regs_t *spectral_matrices_regs;
51
51
52 // Interrupt Service Routine for spectral matrices processing
52 // Interrupt Service Routine for spectral matrices processing
53 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
53 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
54 {
54 {
55 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
55 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
56 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
57 }
57 }
58
58
59 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
59 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
60 {
60 {
61 rtems_event_set event_out;
61 rtems_event_set event_out;
62 gptimer_regs_t *gptimer_regs;
62 gptimer_regs_t *gptimer_regs;
63 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
63 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
64 unsigned char nb_interrupt_f0 = 0;
64 unsigned char nb_interrupt_f0 = 0;
65
65
66 PRINTF("In SMIQ *** \n")
67
66 while(1){
68 while(1){
67 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
68 nb_interrupt_f0 = nb_interrupt_f0 + 1;
70 nb_interrupt_f0 = nb_interrupt_f0 + 1;
69 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
71 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
70 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
72 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
71 printf("In smiq_task *** Error sending event to AVF0\n");
73 printf("In smiq_task *** Error sending event to AVF0\n");
72 nb_interrupt_f0 = 0;
74 nb_interrupt_f0 = 0;
73 }
75 }
74 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
76 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
75 }
77 }
76 }
78 }
77
79
78 rtems_task spw_bppr_task(rtems_task_argument argument)
80 rtems_task spw_bppr_task(rtems_task_argument argument)
79 {
81 {
80 rtems_status_code status;
82 rtems_status_code status;
81 rtems_event_set event_out;
83 rtems_event_set event_out;
82 static int nb_average_f0 = 0;
84 static int nb_average_f0 = 0;
83 //static int nb_average_f1 = 0;
85 //static int nb_average_f1 = 0;
84 //static int nb_average_f2 = 0;
86 //static int nb_average_f2 = 0;
85
87
86 while(1)
88 while(1)
87
89
88 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
90 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
89 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
91 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
90 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
92 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
91
93
92 printf("In BPPR ***\n");
94 printf("In BPPR ***\n");
93
95
94 while(1){ // wait for an event to begin with the processing
96 while(1){ // wait for an event to begin with the processing
95 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
97 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
96 if (status == RTEMS_SUCCESSFUL){
98 if (status == RTEMS_SUCCESSFUL){
97 if ((spectral_matrices_regs->ctrl & 0x00000001)==1){
99 if ((spectral_matrices_regs->ctrl & 0x00000001)==1){
98 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
100 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
99 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
101 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
100 //printf("f0_a\n");
102 //printf("f0_a\n");
101 nb_average_f0++;
103 nb_average_f0++;
102 }
104 }
103 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){
105 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){
104 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
106 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
105 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
107 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
106 //printf("f0_b\n");
108 //printf("f0_b\n");
107 nb_average_f0++;
109 nb_average_f0++;
108 }
110 }
109 if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){
111 if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){
110 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
112 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
111 //printf("f0 compressed\n");
113 //printf("f0 compressed\n");
112 nb_average_f0 = 0;
114 nb_average_f0 = 0;
113 matrix_reset(averaged_spec_mat_f0);
115 matrix_reset(averaged_spec_mat_f0);
114 }
116 }
115 }
117 }
116 }
118 }
117 }
119 }
118
120
119 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
121 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
120 {
122 {
121 int i;
123 int i;
122 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
124 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
123 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
125 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
124 + spec_mat_f0_b[i]
126 + spec_mat_f0_b[i]
125 + spec_mat_f0_c[i]
127 + spec_mat_f0_c[i]
126 + spec_mat_f0_d[i]
128 + spec_mat_f0_d[i]
127 + spec_mat_f0_e[i]
129 + spec_mat_f0_e[i]
128 + spec_mat_f0_f[i]
130 + spec_mat_f0_f[i]
129 + spec_mat_f0_g[i]
131 + spec_mat_f0_g[i]
130 + spec_mat_f0_h[i];
132 + spec_mat_f0_h[i];
131 }
133 }
132 }
134 }
133
135
134 void matrix_reset(float *averaged_spec_mat)
136 void matrix_reset(float *averaged_spec_mat)
135 {
137 {
136 int i;
138 int i;
137 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
139 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
138 averaged_spec_mat_f0[i] = 0;
140 averaged_spec_mat_f0[i] = 0;
139 }
141 }
140 }
142 }
141
143
142 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
144 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
143 {
145 {
144 int i, j;
146 int i, j;
145 switch (fChannel){
147 switch (fChannel){
146 case 0:
148 case 0:
147 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
149 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
148 j = 17 + i * 8;
150 j = 17 + i * 8;
149 compressed_spec_mat[i] = (averaged_spec_mat[j]
151 compressed_spec_mat[i] = (averaged_spec_mat[j]
150 + averaged_spec_mat[j+1]
152 + averaged_spec_mat[j+1]
151 + averaged_spec_mat[j+2]
153 + averaged_spec_mat[j+2]
152 + averaged_spec_mat[j+3]
154 + averaged_spec_mat[j+3]
153 + averaged_spec_mat[j+4]
155 + averaged_spec_mat[j+4]
154 + averaged_spec_mat[j+5]
156 + averaged_spec_mat[j+5]
155 + averaged_spec_mat[j+6]
157 + averaged_spec_mat[j+6]
156 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
158 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
157 }
159 }
158 break;
160 break;
159 case 1:
161 case 1:
160 // case fChannel = f1 tp be completed later
162 // case fChannel = f1 tp be completed later
161 break;
163 break;
162 case 2:
164 case 2:
163 // case fChannel = f1 tp be completed later
165 // case fChannel = f1 tp be completed later
164 break;
166 break;
165 default:
167 default:
166 break;
168 break;
167 }
169 }
168 }
170 }
169
171
170 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
172 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
171 int i, j;
173 int i, j;
172 unsigned char tmp_u_char;
174 unsigned char tmp_u_char;
173 unsigned char * pt_char;
175 unsigned char * pt_char;
174 float PSDB, PSDE;
176 float PSDB, PSDE;
175 float NVEC_V0, NVEC_V1, NVEC_V2;
177 float NVEC_V0, NVEC_V1, NVEC_V2;
176 float significand;
178 float significand;
177 int exponent;
179 int exponent;
178 float aux, tr_SB_SB, tmp;
180 float aux, tr_SB_SB, tmp;
179 float e_cross_b_re, e_cross_b_im;
181 float e_cross_b_re, e_cross_b_im;
180 float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0;
182 float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0;
181 float nx = 0, ny = 0;
183 float nx = 0, ny = 0;
182 float bz_bz_star = 0;
184 float bz_bz_star = 0;
183 for(i=0; i<nb_bins_compressed_spec_mat; i++){
185 for(i=0; i<nb_bins_compressed_spec_mat; i++){
184 //==============================================
186 //==============================================
185 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
187 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
186 PSDB = compressed_spec_mat[i*30] // S11
188 PSDB = compressed_spec_mat[i*30] // S11
187 + compressed_spec_mat[i*30+10] // S22
189 + compressed_spec_mat[i*30+10] // S22
188 + compressed_spec_mat[i*30+18]; // S33
190 + compressed_spec_mat[i*30+18]; // S33
189 significand = frexp(PSDB, &exponent);
191 significand = frexp(PSDB, &exponent);
190 pt_char = (unsigned char*) &PSDB;
192 pt_char = (unsigned char*) &PSDB;
191 LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float
193 LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float
192 LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float
194 LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float
193 //==============================================
195 //==============================================
194 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
196 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
195 PSDE = compressed_spec_mat[i*30+24] * k44 // S44
197 PSDE = compressed_spec_mat[i*30+24] * k44 // S44
196 + compressed_spec_mat[i*30+28] * k55 // S55
198 + compressed_spec_mat[i*30+28] * k55 // S55
197 + compressed_spec_mat[i*30+26] * k45_re // S45
199 + compressed_spec_mat[i*30+26] * k45_re // S45
198 - compressed_spec_mat[i*30+27] * k45_im; // S45
200 - compressed_spec_mat[i*30+27] * k45_im; // S45
199 pt_char = (unsigned char*) &PSDE;
201 pt_char = (unsigned char*) &PSDE;
200 LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float
202 LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float
201 LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float
203 LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float
202 //==============================================================================
204 //==============================================================================
203 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
205 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
204 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
206 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
205 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
207 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
206 tmp = sqrt(
208 tmp = sqrt(
207 compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12
209 compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12
208 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13
210 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13
209 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23
211 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23
210 );
212 );
211 NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23
213 NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23
212 NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13
214 NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13
213 NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12
215 NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12
214 LFR_BP1[i*9+4] = (char) (NVEC_V0*256);
216 LFR_BP1[i*9+4] = (char) (NVEC_V0*256);
215 LFR_BP1[i*9+3] = (char) (NVEC_V1*256);
217 LFR_BP1[i*9+3] = (char) (NVEC_V1*256);
216 pt_char = (unsigned char*) &NVEC_V2;
218 pt_char = (unsigned char*) &NVEC_V2;
217 LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
219 LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
218 //=======================================================
220 //=======================================================
219 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
221 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
220 aux = 2*tmp / PSDB; // compute the ellipticity
222 aux = 2*tmp / PSDB; // compute the ellipticity
221 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
223 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
222 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
224 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
223 //==============================================================
225 //==============================================================
224 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
226 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
225 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
227 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
226 tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30]
228 tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30]
227 + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10]
229 + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10]
228 + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18]
230 + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18]
229 + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2]
231 + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2]
230 + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3]
232 + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3]
231 + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4]
233 + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4]
232 + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5]
234 + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5]
233 + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12]
235 + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12]
234 + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13];
236 + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13];
235 }
237 }
236 aux = PSDB*PSDB;
238 aux = PSDB*PSDB;
237 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux );
239 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux );
238 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
240 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
239 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char
241 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char
240 //=======================================================================================
242 //=======================================================================================
241 // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
243 // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
242 e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re
244 e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re
243 + compressed_spec_mat[i*30+6]*k14_re
245 + compressed_spec_mat[i*30+6]*k14_re
244 + compressed_spec_mat[i*30+8]*k15_re
246 + compressed_spec_mat[i*30+8]*k15_re
245 + compressed_spec_mat[i*30+14]*k24_re
247 + compressed_spec_mat[i*30+14]*k24_re
246 + compressed_spec_mat[i*30+16]*k25_re;
248 + compressed_spec_mat[i*30+16]*k25_re;
247 e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im
249 e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im
248 + compressed_spec_mat[i*30+7]*k14_im
250 + compressed_spec_mat[i*30+7]*k14_im
249 + compressed_spec_mat[i*30+9]*k15_im
251 + compressed_spec_mat[i*30+9]*k15_im
250 + compressed_spec_mat[i*30+15]*k24_im
252 + compressed_spec_mat[i*30+15]*k24_im
251 + compressed_spec_mat[i*30+17]*k25_im;
253 + compressed_spec_mat[i*30+17]*k25_im;
252 tmp = e_cross_b_re / PSDE; // compute ReaSz
254 tmp = e_cross_b_re / PSDE; // compute ReaSz
253 LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
255 LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
254 tmp = e_cross_b_re * e_cross_b_im;
256 tmp = e_cross_b_re * e_cross_b_im;
255 pt_char = (unsigned char*) &tmp;
257 pt_char = (unsigned char*) &tmp;
256 LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz
258 LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz
257 //======================================================================
259 //======================================================================
258 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
260 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
259 nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1;
261 nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1;
260 ny = NVEC_V2;
262 ny = NVEC_V2;
261 bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11
263 bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11
262 + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22
264 + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22
263 - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12
265 - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12
264 n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re
266 n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re
265 +compressed_spec_mat[i*30+6]*k14_bis_re
267 +compressed_spec_mat[i*30+6]*k14_bis_re
266 +compressed_spec_mat[i*30+16]*k25_bis_re
268 +compressed_spec_mat[i*30+16]*k25_bis_re
267 +compressed_spec_mat[i*30+14]*k24_bis_re)
269 +compressed_spec_mat[i*30+14]*k24_bis_re)
268 + ny * (compressed_spec_mat[i*30+6]*k14_tris_re
270 + ny * (compressed_spec_mat[i*30+6]*k14_tris_re
269 +compressed_spec_mat[i*30+14]*k24_tris_re);
271 +compressed_spec_mat[i*30+14]*k24_tris_re);
270 n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im
272 n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im
271 +compressed_spec_mat[i*30+6]*k14_bis_im
273 +compressed_spec_mat[i*30+6]*k14_bis_im
272 +compressed_spec_mat[i*30+16]*k25_bis_im
274 +compressed_spec_mat[i*30+16]*k25_bis_im
273 +compressed_spec_mat[i*30+14]*k24_bis_im)
275 +compressed_spec_mat[i*30+14]*k24_bis_im)
274 + ny * (compressed_spec_mat[i*30+6]*k14_tris_im
276 + ny * (compressed_spec_mat[i*30+6]*k14_tris_im
275 +compressed_spec_mat[i*30+14]*k24_tris_im);
277 +compressed_spec_mat[i*30+14]*k24_tris_im);
276 tmp = n_cross_e_scal_b_re / bz_bz_star;
278 tmp = n_cross_e_scal_b_re / bz_bz_star;
277 LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
279 LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
278 tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im;
280 tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im;
279 pt_char = (unsigned char*) &tmp;
281 pt_char = (unsigned char*) &tmp;
280 LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV
282 LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV
281 }
283 }
282
284
283 }
285 }
284
286
285 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
287 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
286 // BP2 autocorrelation
288 // BP2 autocorrelation
287 int i, aux = 0;
289 int i, aux = 0;
288 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
290 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
289 // S12
291 // S12
290 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]);
292 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]);
291 compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux;
293 compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux;
292 compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux;
294 compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux;
293 // S13
295 // S13
294 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]);
296 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]);
295 compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux;
297 compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux;
296 compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux;
298 compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux;
297 // S23
299 // S23
298 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]);
300 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]);
299 compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux;
301 compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux;
300 compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux;
302 compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux;
301 // S45
303 // S45
302 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]);
304 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]);
303 compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux;
305 compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux;
304 compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux;
306 compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux;
305 // S14
307 // S14
306 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]);
308 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]);
307 compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux;
309 compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux;
308 compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux;
310 compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux;
309 // S15
311 // S15
310 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]);
312 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]);
311 compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux;
313 compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux;
312 compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux;
314 compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux;
313 // S24
315 // S24
314 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]);
316 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]);
315 compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux;
317 compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux;
316 compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux;
318 compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux;
317 // S25
319 // S25
318 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]);
320 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]);
319 compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux;
321 compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux;
320 compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux;
322 compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux;
321 // S34
323 // S34
322 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]);
324 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]);
323 compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux;
325 compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux;
324 compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux;
326 compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux;
325 // S35
327 // S35
326 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]);
328 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]);
327 compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux;
329 compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux;
328 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
330 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
329 }
331 }
330 }
332 }
331
333
332 rtems_task avf0_task(rtems_task_argument argument){
334 rtems_task avf0_task(rtems_task_argument argument){
333 int i;
335 int i;
334 static int nb_average;
336 static int nb_average;
335 rtems_event_set event_out;
337 rtems_event_set event_out;
336 rtems_status_code status;
338 rtems_status_code status;
337
339
338 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
340 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
339 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
341 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
340 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
342 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
341
343
342 nb_average = 0;
344 nb_average = 0;
343
345
344 PRINTF("In AVFO *** \n")
346 PRINTF("In AVFO *** \n")
345
347
346 while(1){
348 while(1){
347 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
349 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
348 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
350 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
349 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
351 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
350 + spec_mat_f0_b[i]
352 + spec_mat_f0_b[i]
351 + spec_mat_f0_c[i]
353 + spec_mat_f0_c[i]
352 + spec_mat_f0_d[i]
354 + spec_mat_f0_d[i]
353 + spec_mat_f0_e[i]
355 + spec_mat_f0_e[i]
354 + spec_mat_f0_f[i]
356 + spec_mat_f0_f[i]
355 + spec_mat_f0_g[i]
357 + spec_mat_f0_g[i]
356 + spec_mat_f0_h[i];
358 + spec_mat_f0_h[i];
357 }
359 }
358 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
360 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
359 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
361 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
360 if (nb_average == NB_AVERAGE_NORMAL_f0) {
362 if (nb_average == NB_AVERAGE_NORMAL_f0) {
361 nb_average = 0;
363 nb_average = 0;
362 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
364 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
363 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
365 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
364 }
366 }
365 }
367 }
366 }
368 }
367
369
368 rtems_task bpf0_task(rtems_task_argument argument){
370 rtems_task bpf0_task(rtems_task_argument argument){
369 rtems_event_set event_out;
371 rtems_event_set event_out;
370
372
373 PRINTF("In BPFO *** \n")
374
371 while(1){
375 while(1){
372 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
376 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
373 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
377 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
374 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
378 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
375 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
379 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
376 }
380 }
377 }
381 }
378
382
379 //*******
383 //*******
380 // UNUSED
384 // UNUSED
381 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
385 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
382 {/*
386 {/*
383 rtems_status_code status;
387 rtems_status_code status;
384 //static int nb_average_f1 = 0;
388 //static int nb_average_f1 = 0;
385 //static int nb_average_f2 = 0;
389 //static int nb_average_f2 = 0;
386
390
387 rtems_name name;
391 rtems_name name;
388 rtems_id period;
392 rtems_id period;
389 name = rtems_build_name( 'P', 'E', 'R', 'D' );
393 name = rtems_build_name( 'P', 'E', 'R', 'D' );
390 status = rtems_rate_monotonic_create( name, &period );
394 status = rtems_rate_monotonic_create( name, &period );
391 if( status != RTEMS_SUCCESSFUL ) {
395 if( status != RTEMS_SUCCESSFUL ) {
392 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
396 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
393 //exit( 1 );
397 //exit( 1 );
394 }
398 }
395
399
396 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
400 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
397 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
401 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
398 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
402 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
399
403
400 printf("In BPPR BIS ***\n");
404 printf("In BPPR BIS ***\n");
401
405
402 while(1){ // launch the rate monotonic task
406 while(1){ // launch the rate monotonic task
403 if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){
407 if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){
404 printf("TIMEOUT\n");
408 printf("TIMEOUT\n");
405 //break;
409 //break;
406 }
410 }
407 status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0
411 status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0
408 if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status);
412 if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status);
409 }
413 }
410
414
411 status = rtems_rate_monotonic_delete( period );
415 status = rtems_rate_monotonic_delete( period );
412 if ( status != RTEMS_SUCCESSFUL ) {
416 if ( status != RTEMS_SUCCESSFUL ) {
413 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
417 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
414 //exit( 1 );
418 //exit( 1 );
415 }
419 }
416 status = rtems_task_delete( RTEMS_SELF ); // should not return
420 status = rtems_task_delete( RTEMS_SELF ); // should not return
417 printf( "rtems_task_delete returned with status of %d.\n", status );
421 printf( "rtems_task_delete returned with status of %d.\n", status );
418 //exit( 1 );*/
422 //exit( 1 );*/
419 }
423 }
420
424
421
425
422
426
423
427
@@ -1,414 +1,489
1 #include <tc_handler.h>
1 #include <tc_handler.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
4 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
5 "WRONG_LEN_PACKET 1",
5 "WRONG_LEN_PACKET 1",
6 "INCOR_CHECKSUM 2",
6 "INCOR_CHECKSUM 2",
7 "ILL_TYPE 3",
7 "ILL_TYPE 3",
8 "ILL_SUBTYPE 4",
8 "ILL_SUBTYPE 4",
9 "WRONG_APP_DATA 5",
9 "WRONG_APP_DATA 5",
10 "WRONG_CMD_CODE 6",
10 "WRONG_CMD_CODE 6",
11 "CCSDS_TM_VALID 7"
11 "CCSDS_TM_VALID 7"
12 };
12 };
13
13
14 //**********************
14 //**********************
15 // GENERAL USE FUNCTIONS
15 // GENERAL USE FUNCTIONS
16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
17 {
17 {
18 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
18 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
19 }
19 }
20
20
21 void InitLookUpTableForCRC()
21 void initLookUpTableForCRC()
22 {
22 {
23 unsigned int i, tmp;
23 unsigned int i, tmp;
24 for (i=0; i<256; i++)
24 for (i=0; i<256; i++)
25 {
25 {
26 tmp = 0;
26 tmp = 0;
27 if((i & 1) != 0) tmp = tmp ^ 0x1021;
27 if((i & 1) != 0) tmp = tmp ^ 0x1021;
28 if((i & 2) != 0) tmp = tmp ^ 0x2042;
28 if((i & 2) != 0) tmp = tmp ^ 0x2042;
29 if((i & 4) != 0) tmp = tmp ^ 0x4084;
29 if((i & 4) != 0) tmp = tmp ^ 0x4084;
30 if((i & 8) != 0) tmp = tmp ^ 0x8108;
30 if((i & 8) != 0) tmp = tmp ^ 0x8108;
31 if((i & 16) != 0) tmp = tmp ^ 0x1231;
31 if((i & 16) != 0) tmp = tmp ^ 0x1231;
32 if((i & 32) != 0) tmp = tmp ^ 0x2462;
32 if((i & 32) != 0) tmp = tmp ^ 0x2462;
33 if((i & 64) != 0) tmp = tmp ^ 0x48c4;
33 if((i & 64) != 0) tmp = tmp ^ 0x48c4;
34 if((i & 128) != 0) tmp = tmp ^ 0x9188;
34 if((i & 128) != 0) tmp = tmp ^ 0x9188;
35 lookUpTableForCRC[i] = tmp;
35 lookUpTableForCRC[i] = tmp;
36 }
36 }
37 }
37 }
38
38
39 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
39 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
40 {
40 {
41 unsigned int Chk;
41 unsigned int Chk;
42 int j;
42 int j;
43 Chk = 0xffff; // reset the syndrom to all ones
43 Chk = 0xffff; // reset the syndrom to all ones
44 for (j=0; j<sizeOfData; j++) {
44 for (j=0; j<sizeOfData; j++) {
45 Chk = Crc_opt(data[j], Chk);
45 Chk = Crc_opt(data[j], Chk);
46 }
46 }
47 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
47 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
49 }
49 }
50
50
51
51
52 //*********************
52 //*********************
53 // ACCEPTANCE FUNCTIONS
53 // ACCEPTANCE FUNCTIONS
54 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
54 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
55 {
55 {
56 rtems_status_code status;
56 rtems_status_code status;
57 spw_ioctl_pkt_send spw_ioctl_send;
57 spw_ioctl_pkt_send spw_ioctl_send;
58 TMHeader_t TM_header;
58 TMHeader_t TM_header;
59 unsigned int code = 0;
59 unsigned int code = 0;
60 unsigned char computed_CRC[2];
60 unsigned char computed_CRC[2];
61 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
61 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
62
62
63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
64 code = acceptTM( TC, tc_len_recv ) ;
64 code = acceptTM( TC, tc_len_recv ) ;
65 if ( (code == 0) | (code == 1) | (code == 2)
65 if ( (code == 0) | (code == 1) | (code == 2)
66 | (code == 3) | (code == 4) | (code == 5) )
66 | (code == 3) | (code == 4) | (code == 5) )
67 { // generate TM_LFR_TC_EXE_CORRUPTED
67 { // generate TM_LFR_TC_EXE_CORRUPTED
68 // BUILD HEADER
68 // BUILD HEADER
69 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
69 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
70 // BUILD DATA
70 // BUILD DATA
71 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
71 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
72 // PREPARE TM SENDING
72 // PREPARE TM SENDING
73 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
73 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
74 spw_ioctl_send.hdr = (char*) &TM_header;
74 spw_ioctl_send.hdr = (char*) &TM_header;
75 spw_ioctl_send.dlen = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
75 spw_ioctl_send.dlen = 16;
76 spw_ioctl_send.data = data;
76 spw_ioctl_send.data = data;
77 // SEND PACKET
77 // SEND PACKET
78 write_spw(&spw_ioctl_send);
78 write_spw(&spw_ioctl_send);
79 }
79 }
80 else { // send valid TC to the action launcher
80 else { // send valid TC to the action launcher
81 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET);
81 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
82 return -1;
82 return -1;
83 }
83 }
84 return -1;
84 return -1;
85 }
85 }
86
86
87 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
87 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
88 {
88 {
89 unsigned char pid = 0;
89 unsigned char pid = 0;
90 unsigned char category = 0;
90 unsigned char category = 0;
91 unsigned int length = 0;
91 unsigned int length = 0;
92 unsigned char packetType = 0;
92 unsigned char packetType = 0;
93 unsigned char packetSubtype = 0;
93 unsigned char packetSubtype = 0;
94 unsigned char * CCSDSContent;
94 unsigned char * CCSDSContent;
95
95
96 // APID check *** APID on 2 bytes
96 // APID check *** APID on 2 bytes
97 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
97 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
98 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
98 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
99 if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID;
99 if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID;
100 if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID;
100 if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID;
101
101
102 // packet length check
102 // packet length check
103 length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1];
103 length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1];
104 if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
104 if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
105 if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
105 if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
106
106
107 packetType = TMPacket->dataFieldHeader[1];
107 packetType = TMPacket->dataFieldHeader[1];
108 packetSubtype = TMPacket->dataFieldHeader[2];
108 packetSubtype = TMPacket->dataFieldHeader[2];
109 // service type, subtype and packet length check
109 // service type, subtype and packet length check
110 if (packetType == 181){
110 if (packetType == 181){
111 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
111 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
112 case 3:
112 case 3:
113 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
113 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
114 break;
114 break;
115 case 20:
115 case 20:
116 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
116 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
117 break;
117 break;
118 case 21:
118 case 21:
119 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
119 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
120 break;
120 break;
121 case 24:
121 case 24:
122 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
122 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
123 break;
123 break;
124 case 27:
124 case 27:
125 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
125 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
126 break;
126 break;
127 case 28:
127 case 28:
128 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
128 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
129 break;
129 break;
130 case 30:
130 case 30:
131 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
131 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
132 break;
132 break;
133 case 40:
133 case 40:
134 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
134 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
135 break;
135 break;
136 case 50:
136 case 50:
137 if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
137 if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
138 break;
138 break;
139 case 60:
139 case 60:
140 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
140 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
141 break;
141 break;
142 case 61:
142 case 61:
143 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
143 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
144 break;
144 break;
145 default:
145 default:
146 return ILL_SUBTYPE;
146 return ILL_SUBTYPE;
147 break;
147 break;
148 }
148 }
149 }
149 }
150 else if (packetType == 9){
150 else if (packetType == 9){
151 if (packetSubtype!=129) return ILL_SUBTYPE;
151 if (packetSubtype!=129) return ILL_SUBTYPE;
152 if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
152 if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
153 }
153 }
154 else return ILL_TYPE;
154 else return ILL_TYPE;
155
155
156 // source ID check // Source ID not documented in the ICD
156 // source ID check // Source ID not documented in the ICD
157
157
158 // packet error control, CRC check
158 // packet error control, CRC check
159 CCSDSContent = (unsigned char*) TMPacket->packetID;
159 CCSDSContent = (unsigned char*) TMPacket->packetID;
160 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
160 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
161 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM;
161 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM;
162 if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM;
162 if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM;
163
163
164 return CCSDS_TM_VALID;
164 return CCSDS_TM_VALID;
165 }
165 }
166
166
167 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
167 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
168 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
168 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
169 {
169 {
170 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
170 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
171 TMHeader->protocolIdentifier = 0x02;
171 TMHeader->protocolIdentifier = 0x02;
172 TMHeader->reserved = 0x00;
172 TMHeader->reserved = 0x00;
173 TMHeader->userApplication = 0x00;
173 TMHeader->userApplication = 0x00;
174 TMHeader->packetID[0] = 0x0c;
174 TMHeader->packetID[0] = 0x0c;
175 TMHeader->packetSequenceControl[0] = 0xc0;
175 TMHeader->packetSequenceControl[0] = 0xc0;
176 TMHeader->packetSequenceControl[1] = 0x00;
176 TMHeader->packetSequenceControl[1] = 0x00;
177 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
177 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
178 TMHeader->packetLength[1] = (unsigned char) packetLength;
178 TMHeader->packetLength[1] = (unsigned char) packetLength;
179 TMHeader->dataFieldHeader[0] = 0x10;
179 TMHeader->dataFieldHeader[0] = 0x10;
180 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
180 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
181 switch (tm_type){
181 switch (tm_type){
182 case(TM_LFR_TC_EXE_OK):
182 case(TM_LFR_TC_EXE_OK):
183 TMHeader->packetID[1] = 0xc1;
183 TMHeader->packetID[1] = 0xc1;
184 TMHeader->dataFieldHeader[1] = 1; // type
184 TMHeader->dataFieldHeader[1] = 1; // type
185 TMHeader->dataFieldHeader[2] = 7; // subtype
185 TMHeader->dataFieldHeader[2] = 7; // subtype
186 break;
186 break;
187 case(TM_LFR_TC_EXE_ERR):
187 case(TM_LFR_TC_EXE_ERR):
188 TMHeader->packetID[1] = 0xc1;
188 TMHeader->packetID[1] = 0xc1;
189 TMHeader->dataFieldHeader[1] = 1; // type
189 TMHeader->dataFieldHeader[1] = 1; // type
190 TMHeader->dataFieldHeader[2] = 8; // subtype
190 TMHeader->dataFieldHeader[2] = 8; // subtype
191 break;
191 break;
192 case(TM_LFR_HK):
192 case(TM_LFR_HK):
193 TMHeader->packetID[1] = 0xc4;
193 TMHeader->packetID[1] = 0xc4;
194 TMHeader->dataFieldHeader[1] = 3; // type
194 TMHeader->dataFieldHeader[1] = 3; // type
195 TMHeader->dataFieldHeader[2] = 25; // subtype
195 TMHeader->dataFieldHeader[2] = 25; // subtype
196 break;
196 break;
197 case(TM_LFR_SCI):
197 case(TM_LFR_SCI):
198 TMHeader->packetID[1] = 0xcc;
198 TMHeader->packetID[1] = 0xcc;
199 TMHeader->dataFieldHeader[1] = 21; // type
199 TMHeader->dataFieldHeader[1] = 21; // type
200 TMHeader->dataFieldHeader[2] = 3; // subtype
200 TMHeader->dataFieldHeader[2] = 3; // subtype
201 break;
201 break;
202 case(TM_LFR_SCI_SBM):
202 case(TM_LFR_SCI_SBM):
203 TMHeader->packetID[1] = 0xfc;
203 TMHeader->packetID[1] = 0xfc;
204 TMHeader->dataFieldHeader[1] = 21; // type
204 TMHeader->dataFieldHeader[1] = 21; // type
205 TMHeader->dataFieldHeader[2] = 3; // subtype
205 TMHeader->dataFieldHeader[2] = 3; // subtype
206 break;
206 break;
207 case(TM_LFR_PAR_DUMP):
207 case(TM_LFR_PAR_DUMP):
208 TMHeader->packetID[1] = 0xc9;
208 TMHeader->packetID[1] = 0xc9;
209 TMHeader->dataFieldHeader[1] = 181; // type
209 TMHeader->dataFieldHeader[1] = 181; // type
210 TMHeader->dataFieldHeader[2] = 31; // subtype
210 TMHeader->dataFieldHeader[2] = 31; // subtype
211 break;
211 break;
212 default:
212 default:
213 return 0;
213 return 0;
214 }
214 }
215 /*TMHeader->dataFieldHeader[4] = (unsigned char) (coarseTime>>24);
215 TMHeader->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
216 TMHeader->dataFieldHeader[5] = (unsigned char) (coarseTime>>16);
216 TMHeader->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
217 TMHeader->dataFieldHeader[6] = (unsigned char) (coarseTime>>8);
217 TMHeader->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
218 TMHeader->dataFieldHeader[7] = (unsigned char) (coarseTime);
218 TMHeader->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
219 TMHeader->dataFieldHeader[8] = (unsigned char) (fineTime>>8);
219 TMHeader->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
220 TMHeader->dataFieldHeader[9] = (unsigned char) (fineTime);*/
220 TMHeader->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
221 TMHeader->dataFieldHeader[4] = 0xaa;
222 TMHeader->dataFieldHeader[5] = 0xbb;
223 TMHeader->dataFieldHeader[6] = 0xcc;
224 TMHeader->dataFieldHeader[7] = 0xdd;
225 TMHeader->dataFieldHeader[8] = 0xee;
226 TMHeader->dataFieldHeader[9] = 0xff;
227 return 1;
221 return 1;
228 }
222 }
229
223
230 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
224 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
231 {
225 {
232 unsigned int packetLength;
226 unsigned int packetLength;
233 packetLength = TC->packetLength[0] * 256 + TC->packetLength[1];
227 packetLength = TC->packetLength[0] * 256 + TC->packetLength[1];
234 switch (SID){
228 switch (SID){
235 case (SID_NOT_EXE):
229 case (SID_NOT_EXE):
236 break;
230 break;
237 case (SID_NOT_IMP):
231 case (SID_NOT_IMP):
238 data[0] = 0x9c;
232 data[0] = 0x9c;
239 data[1] = 0x42;
233 data[1] = 0x42;
240 data[2] = TC->packetID[0];
234 data[2] = TC->packetID[0];
241 data[3] = TC->packetID[1];
235 data[3] = TC->packetID[1];
242 data[4] = TC->packetSequenceControl[0];
236 data[4] = TC->packetSequenceControl[0];
243 data[5] = TC->packetSequenceControl[1];
237 data[5] = TC->packetSequenceControl[1];
244 data[6] = TC->dataFieldHeader[1]; // type
238 data[6] = TC->dataFieldHeader[1]; // type
245 data[7] = TC->dataFieldHeader[2]; // subtype
239 data[7] = TC->dataFieldHeader[2]; // subtype
246 break;
240 break;
247 case (SID_EXE_ERR):
241 case (SID_EXE_ERR):
248 break;
242 break;
249 case (SID_EXE_CORR):
243 case (SID_EXE_CORR):
250 data[0] = 0x9c;
244 data[0] = 0x9c;
251 data[1] = 0x45;
245 data[1] = 0x45;
252 data[2] = TC->packetID[0];
246 data[2] = TC->packetID[0];
253 data[3] = TC->packetID[1];
247 data[3] = TC->packetID[1];
254 data[4] = TC->packetSequenceControl[0];
248 data[4] = TC->packetSequenceControl[0];
255 data[5] = TC->packetSequenceControl[1];
249 data[5] = TC->packetSequenceControl[1];
256 data[6] = TC->dataFieldHeader[1]; // type
250 data[6] = TC->dataFieldHeader[1]; // type
257 data[7] = TC->dataFieldHeader[2]; // subtype
251 data[7] = TC->dataFieldHeader[2]; // subtype
258 data[8] = currentTC_LEN_RCV[0];
252 data[8] = currentTC_LEN_RCV[0];
259 data[9] = currentTC_LEN_RCV[1];
253 data[9] = currentTC_LEN_RCV[1];
260 data[10] = TC->packetLength[0];
254 data[10] = TC->packetLength[0];
261 data[11] = TC->packetLength[1];
255 data[11] = TC->packetLength[1];
262 data[12] = TC->dataAndCRC[packetLength];
256 data[12] = TC->dataAndCRC[packetLength];
263 data[13] = TC->dataAndCRC[packetLength+1];
257 data[13] = TC->dataAndCRC[packetLength+1];
264 data[14] = computed_CRC[0];
258 data[14] = computed_CRC[0];
265 data[15] = computed_CRC[1];
259 data[15] = computed_CRC[1];
266 break;
260 break;
267 default:
261 default:
268 return 0;
262 return 0;
269 }
263 }
270 return 1;
264 return 1;
271 }
265 }
272
266
273 //***********
267 //***********
274 // RTEMS TASK
268 // RTEMS TASK
275 rtems_task recv_task( rtems_task_argument unused )
269 rtems_task recv_task( rtems_task_argument unused )
276 {
270 {
277 int len = 0;
271 int len = 0;
278 unsigned int i = 0;
272 unsigned int i = 0;
279 unsigned int data_length = 0;
273 unsigned int data_length = 0;
280 ccsdsTelecommandPacket_t currentTC;
274 ccsdsTelecommandPacket_t currentTC;
281 char data[100];
275 char data[100];
282
276
283 for(i=0; i<100; i++) data[i] = 0;
277 for(i=0; i<100; i++) data[i] = 0;
284
278
285 PRINTF("In RECV *** \n")
279 PRINTF("In RECV *** \n")
286
280
287 while(1)
281 while(1)
288 {
282 {
289 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
283 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
290 if (len == -1){ // error during the read call
284 if (len == -1){ // error during the read call
291 PRINTF("In RECV *** last read call returned -1\n")
285 PRINTF("In RECV *** last read call returned -1\n")
292 if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL)
286 if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL)
293 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
287 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
294 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL)
288 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL)
295 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
289 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
296 }
290 }
297 else {
291 else {
298 //PRINTF1("In RECV *** Got Message of length %d\n", len)
292 //PRINTF1("In RECV *** Got Message of length %d\n", len)
299 currentTC_LEN_RCV[0] = 0x00;
293 currentTC_LEN_RCV[0] = 0x00;
300 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
294 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
301 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
295 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
302 // CHECK THE TC AND BUILD THE APPROPRIATE TM
296 // CHECK THE TC AND BUILD THE APPROPRIATE TM
303 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
297 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
304 if (data_length!=-1)
298 if (data_length!=-1)
305 {
299 {
306 }
300 }
307 }
301 }
308 }
302 }
309 }
303 }
310
304
311 rtems_task actn_task( rtems_task_argument unused )
305 rtems_task actn_task( rtems_task_argument unused )
312 {
306 {
307 int result = 0;
313 rtems_status_code status; // RTEMS status code
308 rtems_status_code status; // RTEMS status code
314 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
309 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
315 size_t size; // size of the incoming TC packet
310 size_t size; // size of the incoming TC packet
316 unsigned char subtype = 0; // subtype of the current TC packet
311 unsigned char subtype = 0; // subtype of the current TC packet
317
312
313 PRINTF("In ACTN *** \n")
314
318 while(1)
315 while(1)
319 {
316 {
320 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
317 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
321 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
318 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
322 if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status)
319 if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status)
323 else
320 else
324 {
321 {
325 subtype = TC.dataFieldHeader[2];
322 subtype = TC.dataFieldHeader[2];
326 switch(subtype)
323 switch(subtype)
327 {
324 {
328 case TC_SUBTYPE_RESET:
325 case TC_SUBTYPE_RESET:
329 break;
326 result = action_default( &TC );
330 case TC_SUBTYPE_LOAD_COMM:
331 break;
327 break;
328 //
329 case TC_SUBTYPE_LOAD_COMM:
330 result = action_default( &TC );
331 break;
332 //
332 case TC_SUBTYPE_LOAD_NORM:
333 case TC_SUBTYPE_LOAD_NORM:
333 action_load_norm( &TC );
334 result = action_load_norm( &TC );
335 send_tm_lfr_tc_exe_success( &TC );
334 break;
336 break;
337 //
335 case TC_SUBTYPE_LOAD_BURST:
338 case TC_SUBTYPE_LOAD_BURST:
339 result = action_default( &TC );
336 break;
340 break;
341 //
337 case TC_SUBTYPE_LOAD_SBM1:
342 case TC_SUBTYPE_LOAD_SBM1:
343 result = action_default( &TC );
338 break;
344 break;
345 //
339 case TC_SUBTYPE_LOAD_SBM2:
346 case TC_SUBTYPE_LOAD_SBM2:
347 result = action_default( &TC );
340 break;
348 break;
349 //
341 case TC_SUBTYPE_DUMP:
350 case TC_SUBTYPE_DUMP:
342 action_default( &TC );
351 result = action_default( &TC );
343 break;
352 break;
353 //
344 case TC_SUBTYPE_ENTER:
354 case TC_SUBTYPE_ENTER:
345 action_enter( &TC );
355 result = action_enter( &TC );
356 send_tm_lfr_tc_exe_success( &TC );
346 break;
357 break;
358 //
347 case TC_SUBTYPE_UPDT_INFO:
359 case TC_SUBTYPE_UPDT_INFO:
360 result = action_default( &TC );
348 break;
361 break;
362 //
349 case TC_SUBTYPE_EN_CAL:
363 case TC_SUBTYPE_EN_CAL:
364 result = action_default( &TC );
350 break;
365 break;
366 //
351 case TC_SUBTYPE_DIS_CAL:
367 case TC_SUBTYPE_DIS_CAL:
368 result = action_default( &TC );
352 break;
369 break;
370 //
353 case TC_SUBTYPE_UPDT_TIME:
371 case TC_SUBTYPE_UPDT_TIME:
372 result = action_updt_time( &TC );
373 send_tm_lfr_tc_exe_success( &TC );
354 break;
374 break;
375 //
355 default:
376 default:
356 break;
377 break;
357 }
378 }
358 }
379 }
359 }
380 }
360 }
381 }
361
382
362 int create_message_queue()
383 int create_message_queue()
363 {
384 {
364 rtems_status_code status;
385 rtems_status_code status;
365 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
386 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
366 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
387 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
367 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
388 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
368 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
369
390
370 return 0;
391 return 0;
371 }
392 }
372
393
373 //***********
394 //***********
374 // TC ACTIONS
395 // TC ACTIONS
375 int action_default(ccsdsTelecommandPacket_t *TC)
396 int action_default(ccsdsTelecommandPacket_t *TC)
376 {
397 {
377 char data[100]; // buffer for the generic TM packet
398 char data[100]; // buffer for the generic TM packet
378 TMHeader_t TM_header; // TM header
399 TMHeader_t TM_header; // TM header
379 spw_ioctl_pkt_send spw_ioctl_send; // structure to send the TM packet if any
400 spw_ioctl_pkt_send spw_ioctl_send; // structure to send the TM packet if any
380 // BUILD HEADER
401 // BUILD HEADER
381 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP, 0, 0, &TM_header);
402 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP, 0, 0, &TM_header);
382 // BUILD DATA
403 // BUILD DATA
383 TM_build_data( TC, data, SID_NOT_IMP, NULL);
404 TM_build_data( TC, data, SID_NOT_IMP, NULL);
384 // filling the strture for the spcawire transmission
405 // filling the strture for the spcawire transmission
385 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
406 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
386 spw_ioctl_send.hdr = (char*) &TM_header;
407 spw_ioctl_send.hdr = (char*) &TM_header;
387 spw_ioctl_send.dlen = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN;
408 spw_ioctl_send.dlen = 8;
388 spw_ioctl_send.data = data;
409 spw_ioctl_send.data = data;
389 // SEND DATA
410 // SEND DATA
390 write_spw(&spw_ioctl_send);
411 write_spw(&spw_ioctl_send);
391
412
392 return 0;
413 return 0;
393 }
414 }
394
415
395 int action_enter(ccsdsTelecommandPacket_t *TC)
416 int action_enter(ccsdsTelecommandPacket_t *TC)
396 {
417 {
418 unsigned char lfr_mode = TC->dataAndCRC[1];
419 printf("enter mode %d\n", lfr_mode);
420 switch(lfr_mode)
421 {
422 case(LFR_MODE_STANDBY):
423 LEON_Mask_interrupt( IRQ_WF );
424 LEON_Mask_interrupt( IRQ_SM );
425 break;
426 case(LFR_MODE_NORMAL):
427 LEON_Unmask_interrupt( IRQ_WF );
428 LEON_Unmask_interrupt( IRQ_SM );
429 break;
430 case(LFR_MODE_BURST):
431 break;
432 case(LFR_MODE_SBM1):
433 break;
434 case(LFR_MODE_SBM2):
435 break;
436 }
397 return 0;
437 return 0;
398 }
438 }
399
439
400 int action_load_norm(ccsdsTelecommandPacket_t *TC)
440 int action_load_norm(ccsdsTelecommandPacket_t *TC)
401 {
441 {
402 param_norm.sy_lfr_n_swf_l = TC->dataAndCRC[0] * 256 + TC->dataAndCRC[1];
442 param_norm.sy_lfr_n_swf_l = TC->dataAndCRC[0] * 256 + TC->dataAndCRC[1];
403 param_norm.sy_lfr_n_swf_p = TC->dataAndCRC[2] * 256 + TC->dataAndCRC[3];
443 param_norm.sy_lfr_n_swf_p = TC->dataAndCRC[2] * 256 + TC->dataAndCRC[3];
404 param_norm.sy_lfr_n_asm_p = TC->dataAndCRC[4] * 256 + TC->dataAndCRC[5];
444 param_norm.sy_lfr_n_asm_p = TC->dataAndCRC[4] * 256 + TC->dataAndCRC[5];
405 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
445 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
406 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
446 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
407 printf("sy_lfr_n_ => swf_l %d, swf_p %d, asm_p %d, bsp_p0 %d, bsp_p1 %d\n",
447 /*printf("sy_lfr_n_ => swf_l %d, swf_p %d, asm_p %d, bsp_p0 %d, bsp_p1 %d\n",
408 param_norm.sy_lfr_n_swf_l, param_norm.sy_lfr_n_swf_p,
448 param_norm.sy_lfr_n_swf_l, param_norm.sy_lfr_n_swf_p,
409 param_norm.sy_lfr_n_asm_p, param_norm.sy_lfr_n_bp_p0, param_norm.sy_lfr_n_bp_p1);
449 param_norm.sy_lfr_n_asm_p, param_norm.sy_lfr_n_bp_p0, param_norm.sy_lfr_n_bp_p1);*/
450 return 0;
451 }
452
453 int action_updt_time(ccsdsTelecommandPacket_t *TC)
454 {
455 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
456 + (TC->dataAndCRC[1] << 16)
457 + (TC->dataAndCRC[2] << 8)
458 + TC->dataAndCRC[3];
459 time_management_regs->ctrl = time_management_regs->ctrl | 1;
460 return 0;
461 }
462
463 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
464 {
465 TMHeader_t TM_header;
466 char data[4];
467 spw_ioctl_pkt_send spw_ioctl_send;
468
469 TM_build_header( TM_LFR_TC_EXE_OK, TM_LEN_EXE,
470 time_management_regs->coarse_time, time_management_regs->fine_time, &TM_header);
471
472 data[0] = TC->packetID[0];
473 data[1] = TC->packetID[1];
474 data[2] = TC->packetSequenceControl[0];
475 data[3] = TC->packetSequenceControl[1];
476
477 // filling the structure for the spacewire transmission
478 spw_ioctl_send.hlen = TM_HEADER_LEN + 3; // + 4 is for the protocole extra header
479 spw_ioctl_send.hdr = (char*) &TM_header;
480 spw_ioctl_send.dlen = 3;
481 spw_ioctl_send.data = data;
482
483 // SEND DATA
484 write_spw(&spw_ioctl_send);
485
410 return 0;
486 return 0;
411 }
487 }
412
488
413
489
414
@@ -1,113 +1,115
1 #include <wf_handler.h>
1 #include <wf_handler.h>
2
2
3 rtems_isr waveforms_isr( rtems_vector_number vector )
3 rtems_isr waveforms_isr( rtems_vector_number vector )
4 {
4 {
5 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
5 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
7 }
7 }
8
8
9 rtems_task wfrm_task(rtems_task_argument argument)
9 rtems_task wfrm_task(rtems_task_argument argument)
10 {
10 {
11 unsigned int length;
11 unsigned int length;
12 unsigned int i = 0;
12 unsigned int i = 0;
13 spw_ioctl_pkt_send spw_ioctl_send;
13 spw_ioctl_pkt_send spw_ioctl_send;
14 rtems_event_set event_out;
14 rtems_event_set event_out;
15 gptimer_regs_t *gptimer_regs;
15 gptimer_regs_t *gptimer_regs;
16 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
16 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
17 ExtendedTMHeader_t header;
17 ExtendedTMHeader_t header;
18
18
19 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
19 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
20 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
20 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
21 header.reserved = 0x00;
21 header.reserved = 0x00;
22 header.userApplication = CCSDS_USER_APP;
22 header.userApplication = CCSDS_USER_APP;
23 header.packetID[0] = 0x0c;
23 header.packetID[0] = 0x0c;
24 header.packetID[1] = 0xcc;
24 header.packetID[1] = 0xcc;
25 header.packetSequenceControl[0] = 0x00;
25 header.packetSequenceControl[0] = 0x00;
26 header.packetSequenceControl[1] = 0x00;
26 header.packetSequenceControl[1] = 0x00;
27 header.packetLength[0] = 0x00;
27 header.packetLength[0] = 0x00;
28 header.packetLength[1] = 0x00;
28 header.packetLength[1] = 0x00;
29 header.dataFieldHeader[0] = 0x10;
29 header.dataFieldHeader[0] = 0x10;
30 header.dataFieldHeader[1] = 0x15; // service type
30 header.dataFieldHeader[1] = 0x15; // service type
31 header.dataFieldHeader[2] = 0x03; // service subtype
31 header.dataFieldHeader[2] = 0x03; // service subtype
32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
33 header.dataFieldHeader[4] = 0xaa;
33 header.dataFieldHeader[4] = 0xaa;
34 header.dataFieldHeader[5] = 0xbb;
34 header.dataFieldHeader[5] = 0xbb;
35 header.dataFieldHeader[6] = 0xcc;
35 header.dataFieldHeader[6] = 0xcc;
36 header.dataFieldHeader[7] = 0xdd;
36 header.dataFieldHeader[7] = 0xdd;
37 header.dataFieldHeader[8] = 0xee;
37 header.dataFieldHeader[8] = 0xee;
38 header.dataFieldHeader[9] = 0xff;
38 header.dataFieldHeader[9] = 0xff;
39
39
40 header.auxiliaryHeader[0] = 0x00;
40 header.auxiliaryHeader[0] = 0x00;
41 header.auxiliaryHeader[1] = 0x1f;
41 header.auxiliaryHeader[1] = 0x1f;
42 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
42 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
43 header.auxiliaryHeader[3] = 0x00; // PKT_NR
43 header.auxiliaryHeader[3] = 0x00; // PKT_NR
44 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
44 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
45 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
45 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
46
46
47 // BUILD THE PACKET HEADER
47 // BUILD THE PACKET HEADER
48 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
48 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
49 spw_ioctl_send.hdr = (char*) &header;
49 spw_ioctl_send.hdr = (char*) &header;
50
50
51 PRINTF("In WFRM *** \n")
52
51 while(1){
53 while(1){
52 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
54 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
53 for (i=0; i<7; i++) // send F0
55 for (i=0; i<7; i++) // send F0
54 {
56 {
55 // BUILD THE DATA
57 // BUILD THE DATA
56 if (i==6) {
58 if (i==6) {
57 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
59 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
58 length = TM_LEN_SCI_NORM_SWF_340;
60 length = TM_LEN_SCI_NORM_SWF_340;
59 }
61 }
60 else {
62 else {
61 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
63 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
62 length = TM_LEN_SCI_NORM_SWF_8;
64 length = TM_LEN_SCI_NORM_SWF_8;
63 }
65 }
64 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
66 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
65 // BUILD THE HEADER
67 // BUILD THE HEADER
66 header.packetLength[0] = (unsigned char) (length>>8);
68 header.packetLength[0] = (unsigned char) (length>>8);
67 header.packetLength[1] = (unsigned char) (length);
69 header.packetLength[1] = (unsigned char) (length);
68 header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID
70 header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID
69 // SEND PACKET
71 // SEND PACKET
70 write_spw(&spw_ioctl_send);
72 write_spw(&spw_ioctl_send);
71 }
73 }
72 for (i=0; i<7; i++) // send F1
74 for (i=0; i<7; i++) // send F1
73 {
75 {
74 // BUILD THE DATA
76 // BUILD THE DATA
75 if (i==6) {
77 if (i==6) {
76 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
78 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
77 length = TM_LEN_SCI_NORM_SWF_340;
79 length = TM_LEN_SCI_NORM_SWF_340;
78 }
80 }
79 else {
81 else {
80 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
82 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
81 length = TM_LEN_SCI_NORM_SWF_8;
83 length = TM_LEN_SCI_NORM_SWF_8;
82 }
84 }
83 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
85 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
84 // BUILD THE HEADER
86 // BUILD THE HEADER
85 header.packetLength[0] = (unsigned char) (length>>8);
87 header.packetLength[0] = (unsigned char) (length>>8);
86 header.packetLength[1] = (unsigned char) (length);
88 header.packetLength[1] = (unsigned char) (length);
87 header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID
89 header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID
88 // SEND PACKET
90 // SEND PACKET
89 write_spw(&spw_ioctl_send);
91 write_spw(&spw_ioctl_send);
90 }
92 }
91 for (i=0; i<7; i++) // send F0
93 for (i=0; i<7; i++) // send F0
92 {
94 {
93 // BUILD THE DATA
95 // BUILD THE DATA
94 if (i==6) {
96 if (i==6) {
95 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
97 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
96 length = TM_LEN_SCI_NORM_SWF_340;
98 length = TM_LEN_SCI_NORM_SWF_340;
97 }
99 }
98 else {
100 else {
99 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
101 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
100 length = TM_LEN_SCI_NORM_SWF_8;
102 length = TM_LEN_SCI_NORM_SWF_8;
101 }
103 }
102 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
104 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
103 // BUILD THE HEADER
105 // BUILD THE HEADER
104 header.packetLength[0] = (unsigned char) (length>>8);
106 header.packetLength[0] = (unsigned char) (length>>8);
105 header.packetLength[1] = (unsigned char) (length);
107 header.packetLength[1] = (unsigned char) (length);
106 header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID
108 header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID
107 // SEND PACKET
109 // SEND PACKET
108 write_spw(&spw_ioctl_send);
110 write_spw(&spw_ioctl_send);
109 }
111 }
110 // irq processed, reset the related register of the timer unit
112 // irq processed, reset the related register of the timer unit
111 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
113 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
112 }
114 }
113 }
115 }
General Comments 0
You need to be logged in to leave comments. Login now