@@ -1,69 +1,69 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
|
2 | 2 | <CodeBlocks_project_file> |
|
3 | 3 | <FileVersion major="1" minor="6" /> |
|
4 | 4 | <Project> |
|
5 | 5 | <Option title="FSW-rtems" /> |
|
6 | 6 | <Option pch_mode="2" /> |
|
7 | 7 | <Option compiler="sparcrtemsgcc446" /> |
|
8 | 8 | <Build> |
|
9 | 9 | <Target title="Debug"> |
|
10 | 10 | <Option output="bin/Debug/fsw" prefix_auto="1" extension_auto="1" /> |
|
11 | 11 | <Option object_output="obj/Debug/" /> |
|
12 | 12 | <Option type="1" /> |
|
13 | <Option compiler="sparcrtems446" /> | |
|
13 | <Option compiler="sparcrtemsgcc446" /> | |
|
14 | 14 | <Compiler> |
|
15 | 15 | <Add option="-fexpensive-optimizations" /> |
|
16 | 16 | <Add option="-O3" /> |
|
17 | 17 | <Add option="-g" /> |
|
18 | 18 | <Add directory="../header" /> |
|
19 | 19 | <Add directory="../src" /> |
|
20 | 20 | </Compiler> |
|
21 | 21 | </Target> |
|
22 | 22 | <Target title="Release"> |
|
23 | 23 | <Option output="bin/Release/FSW-rtems" prefix_auto="1" extension_auto="1" /> |
|
24 | 24 | <Option object_output="obj/Release/" /> |
|
25 | 25 | <Option type="1" /> |
|
26 | 26 | <Option compiler="sparcrtemsgcc446" /> |
|
27 | 27 | <Compiler> |
|
28 | 28 | <Add option="-O2" /> |
|
29 | 29 | </Compiler> |
|
30 | 30 | <Linker> |
|
31 | 31 | <Add option="-s" /> |
|
32 | 32 | </Linker> |
|
33 | 33 | </Target> |
|
34 | 34 | </Build> |
|
35 | 35 | <Compiler> |
|
36 | 36 | <Add option="-Wall" /> |
|
37 | 37 | </Compiler> |
|
38 | 38 | <Unit filename="../header/ccsds_types.h" /> |
|
39 | 39 | <Unit filename="../header/fsw_init.h" /> |
|
40 | 40 | <Unit filename="../header/fsw_misc.h" /> |
|
41 | 41 | <Unit filename="../header/fsw_params.h" /> |
|
42 | 42 | <Unit filename="../header/fsw_processing.h" /> |
|
43 | 43 | <Unit filename="../header/grlib_regs.h" /> |
|
44 | 44 | <Unit filename="../header/tc_handler.h" /> |
|
45 | 45 | <Unit filename="../header/wf_handler.h" /> |
|
46 | 46 | <Unit filename="../src/fsw_globals.c"> |
|
47 | 47 | <Option compilerVar="CC" /> |
|
48 | 48 | </Unit> |
|
49 | 49 | <Unit filename="../src/fsw_init.c"> |
|
50 | 50 | <Option compilerVar="CC" /> |
|
51 | 51 | </Unit> |
|
52 | 52 | <Unit filename="../src/fsw_misc.c"> |
|
53 | 53 | <Option compilerVar="CC" /> |
|
54 | 54 | </Unit> |
|
55 | 55 | <Unit filename="../src/fsw_processing.c"> |
|
56 | 56 | <Option compilerVar="CC" /> |
|
57 | 57 | </Unit> |
|
58 | 58 | <Unit filename="../src/tc_handler.c"> |
|
59 | 59 | <Option compilerVar="CC" /> |
|
60 | 60 | </Unit> |
|
61 | 61 | <Unit filename="../src/wf_handler.c"> |
|
62 | 62 | <Option compilerVar="CC" /> |
|
63 | 63 | </Unit> |
|
64 | 64 | <Extensions> |
|
65 | 65 | <code_completion /> |
|
66 | 66 | <debugger /> |
|
67 | 67 | </Extensions> |
|
68 | 68 | </Project> |
|
69 | 69 | </CodeBlocks_project_file> |
@@ -1,192 +1,226 | |||
|
1 | 1 | # depslib dependency file v1.0 |
|
2 | 2 | 1355231335 source:e:\missions\solo\dev_ple\src\fsw-rtems.c |
|
3 | 3 | <rtems.h> |
|
4 | 4 | <bsp.h> |
|
5 | 5 | <rtems/confdefs.h> |
|
6 | 6 | <drvmgr/drvmgr_confdefs.h> |
|
7 | 7 | <rtems.h> |
|
8 | 8 | <errno.h> |
|
9 | 9 | <fcntl.h> |
|
10 | 10 | <stdio.h> |
|
11 | 11 | <stdlib.h> |
|
12 | 12 | <FSW-config.c> |
|
13 | 13 | <grspw.h> |
|
14 | 14 | <apbuart.h> |
|
15 | 15 | <FSW-rtems-processing.h> |
|
16 | 16 | |
|
17 | 17 | 1355231335 -processing.h> |
|
18 | 18 | |
|
19 | 19 | 1350983928 source:e:\missions\solo\dev_ple\src\grspw.c |
|
20 | 20 | <..\header\grspw.h> |
|
21 | 21 | <stdio.h> |
|
22 | 22 | |
|
23 | 23 | 1354190601 |
|
24 | 24 | |
|
25 | 25 | 1350983928 e:\missions\solo\dev_ple\header\grspw.h |
|
26 | 26 | |
|
27 | 27 | 1351173364 source:e:\missions\solo\dev_ple\src\fsw-config.c |
|
28 | 28 | <drvmgr/ambapp_bus.h> |
|
29 | 29 | |
|
30 | 30 | 1354190602 bapp_bus.h> |
|
31 | 31 | |
|
32 | 32 | 1354190602 e:\missions\solo\dev_ple\src\fsw-config.c |
|
33 | 33 | <drvmgr/ambapp_bus.h> |
|
34 | 34 | |
|
35 | 35 | 1354190602 source:e:\missions\solo\dev_ple\src\fsw-rtems-processing.c |
|
36 | 36 | <FSW-rtems-processing.h> |
|
37 | 37 | <math.h> |
|
38 | 38 | <stdio.h> |
|
39 | 39 | <leon.h> |
|
40 | 40 | |
|
41 | 41 | 1354190601 e:\missions\solo\dev_ple\header\fsw-rtems-processing.h |
|
42 | 42 | <rtems.h> |
|
43 | 43 | |
|
44 | 44 | 1359451040 source:/opt/DEV_PLE/src/FSW-rtems-processing.c |
|
45 | 45 | <FSW-rtems-processing.h> |
|
46 | 46 | <math.h> |
|
47 | 47 | <stdio.h> |
|
48 | 48 | <leon.h> |
|
49 | 49 | |
|
50 | 50 | 1359458568 /opt/DEV_PLE/header/FSW-rtems-processing.h |
|
51 | 51 | <rtems.h> |
|
52 | 52 | <grlibregs.h> |
|
53 | 53 | <FSW-params.h> |
|
54 | 54 | |
|
55 | 55 | 1359458854 source:/opt/DEV_PLE/src/FSW-rtems.c |
|
56 | 56 | <rtems.h> |
|
57 | 57 | <bsp.h> |
|
58 | 58 | <rtems/confdefs.h> |
|
59 | 59 | <drvmgr/drvmgr_confdefs.h> |
|
60 | 60 | <FSW-rtems.h> |
|
61 | 61 | <FSW-config.c> |
|
62 | 62 | |
|
63 | 63 | 1359365823 /opt/DEV_PLE/src/FSW-config.c |
|
64 | 64 | <drvmgr/ambapp_bus.h> |
|
65 | 65 | |
|
66 | 66 | 1359458568 source:/opt/DEV_PLE/src/TC_handler.c |
|
67 | 67 | <TC_handler.h> |
|
68 | 68 | <FSW-params.h> |
|
69 | 69 | |
|
70 | 70 | 1359377846 /opt/DEV_PLE/header/TC_handler.h |
|
71 | 71 | <stdio.h> |
|
72 | 72 | <ccsds_types.h> |
|
73 | 73 | |
|
74 |
1359 |
|
|
74 | 1359640245 /opt/DEV_PLE/header/ccsds_types.h | |
|
75 | 75 | |
|
76 | 76 | 1359365823 source:/opt/DEV_PLE/src/FSW-config.c |
|
77 | 77 | <drvmgr/ambapp_bus.h> |
|
78 | 78 | |
|
79 | 79 | 1359452642 /opt/DEV_PLE/header/FSW-config.h |
|
80 | 80 | |
|
81 | 81 | 1359440704 /opt/DEV_PLE/header/grlibregs.h |
|
82 | 82 | |
|
83 | 83 | 1359382989 source:/opt/DEV_PLE/src/WF_handler.c |
|
84 | 84 | |
|
85 | 85 | 1359459475 source:/opt/DEV_PLE/src/FSW-misc.c |
|
86 | 86 | <FSW-misc.h> |
|
87 | 87 | <FSW-params.h> |
|
88 | 88 | |
|
89 | 89 | 1359459330 /opt/DEV_PLE/header/FSW-misc.h |
|
90 | 90 | <rtems.h> |
|
91 | 91 | <stdio.h> |
|
92 | 92 | <FSW-rtems.h> |
|
93 | 93 | <FSW-params.h> |
|
94 | 94 | <grlibregs.h> |
|
95 | 95 | <grspw.h> |
|
96 | 96 | <ccsds_types.h> |
|
97 | 97 | |
|
98 | 98 | 1359459364 /opt/DEV_PLE/header/FSW-rtems.h |
|
99 | 99 | <errno.h> |
|
100 | 100 | <fcntl.h> |
|
101 | 101 | <stdio.h> |
|
102 | 102 | <stdlib.h> |
|
103 | 103 | <grspw.h> |
|
104 | 104 | <apbuart.h> |
|
105 | 105 | <FSW-params.h> |
|
106 | 106 | <FSW-misc.h> |
|
107 | 107 | <FSW-rtems-processing.h> |
|
108 | 108 | <TC_handler.h> |
|
109 | 109 | <WF_handler.h> |
|
110 | 110 | <grlibregs.h> |
|
111 | 111 | |
|
112 | 112 | 1359458453 /opt/DEV_PLE/header/FSW-params.h |
|
113 | 113 | |
|
114 | 114 | 1359459642 /opt/DEV_PLE/header/WF_handler.h |
|
115 | 115 | <rtems.h> |
|
116 | 116 | <FSW-params.h> |
|
117 | 117 | <grspw.h> |
|
118 | 118 | <grlibregs.h> |
|
119 | 119 | <ccsds_types.h> |
|
120 | 120 | <stdio.h> |
|
121 | 121 | <FSW-rtems.h> |
|
122 | 122 | |
|
123 | 123 | 1359464354 source:/opt/DEV_PLE/src/fsw_main.c |
|
124 | 124 | <rtems.h> |
|
125 | 125 | <bsp.h> |
|
126 | 126 | <rtems/confdefs.h> |
|
127 | 127 | <drvmgr/drvmgr_confdefs.h> |
|
128 | 128 | <fsw_main.h> |
|
129 | 129 | <fsw_config.c> |
|
130 | 130 | |
|
131 | 131 | 1359464346 /opt/DEV_PLE/header/fsw_main.h |
|
132 | 132 | <errno.h> |
|
133 | 133 | <fcntl.h> |
|
134 | 134 | <stdio.h> |
|
135 | 135 | <stdlib.h> |
|
136 | 136 | <grspw.h> |
|
137 | 137 | <apbuart.h> |
|
138 | 138 | <fsw_params.h> |
|
139 | 139 | <fsw_misc.h> |
|
140 | 140 | <fsw_processing.h> |
|
141 | 141 | <tc_handler.h> |
|
142 | 142 | <wf_handler.h> |
|
143 | 143 | <grlib_regs.h> |
|
144 | 144 | |
|
145 |
1359 |
|
|
145 | 1359616894 /opt/DEV_PLE/header/fsw_params.h | |
|
146 | 146 | |
|
147 |
1359 |
|
|
147 | 1359614518 /opt/DEV_PLE/header/fsw_misc.h | |
|
148 | 148 | <rtems.h> |
|
149 | 149 | <stdio.h> |
|
150 |
<fsw_ |
|
|
150 | <fsw_init.h> | |
|
151 | 151 | <fsw_params.h> |
|
152 | 152 | <grlib_regs.h> |
|
153 | 153 | <grspw.h> |
|
154 | 154 | <ccsds_types.h> |
|
155 | 155 | |
|
156 | 156 | 1359440704 /opt/DEV_PLE/header/grlib_regs.h |
|
157 | 157 | |
|
158 |
13594 |
|
|
158 | 1359614517 /opt/DEV_PLE/header/fsw_processing.h | |
|
159 | 159 | <rtems.h> |
|
160 | 160 | <grlib_regs.h> |
|
161 | 161 | <fsw_params.h> |
|
162 | 162 | |
|
163 |
1359 |
|
|
163 | 1359643450 /opt/DEV_PLE/header/tc_handler.h | |
|
164 | <rtems.h> | |
|
164 | 165 | <stdio.h> |
|
166 | <unistd.h> | |
|
167 | <sys/ioctl.h> | |
|
165 | 168 | <ccsds_types.h> |
|
169 | <grspw.h> | |
|
170 | <fsw_init.h> | |
|
166 | 171 | |
|
167 |
1359 |
|
|
172 | 1359614518 /opt/DEV_PLE/header/wf_handler.h | |
|
168 | 173 | <rtems.h> |
|
169 | 174 | <fsw_params.h> |
|
170 | 175 | <grspw.h> |
|
171 | 176 | <grlib_regs.h> |
|
172 | 177 | <ccsds_types.h> |
|
173 | 178 | <stdio.h> |
|
174 |
<fsw_ |
|
|
179 | <fsw_init.h> | |
|
175 | 180 | |
|
176 | 181 | 1359365823 /opt/DEV_PLE/src/fsw_config.c |
|
177 | 182 | <drvmgr/ambapp_bus.h> |
|
178 | 183 | |
|
179 |
1359 |
|
|
184 | 1359614518 source:/opt/DEV_PLE/src/fsw_misc.c | |
|
180 | 185 | <fsw_misc.h> |
|
181 | 186 | <fsw_params.h> |
|
182 | 187 | |
|
183 |
1359 |
|
|
188 | 1359643720 source:/opt/DEV_PLE/src/tc_handler.c | |
|
184 | 189 | <tc_handler.h> |
|
185 | 190 | <fsw_params.h> |
|
186 | 191 | |
|
187 |
1359 |
|
|
192 | 1359614518 source:/opt/DEV_PLE/src/wf_handler.c | |
|
188 | 193 | <wf_handler.h> |
|
189 | 194 | |
|
190 |
1359 |
|
|
195 | 1359615705 source:/opt/DEV_PLE/src/fsw_globals.c | |
|
191 | 196 | <fsw_processing.h> |
|
197 | <rtems.h> | |
|
192 | 198 | |
|
199 | 1359622160 source:/opt/DEV_PLE/src/fsw_init.c | |
|
200 | <rtems.h> | |
|
201 | <bsp.h> | |
|
202 | <rtems/confdefs.h> | |
|
203 | <drvmgr/drvmgr_confdefs.h> | |
|
204 | <fsw_init.h> | |
|
205 | <fsw_config.c> | |
|
206 | ||
|
207 | 1359615705 /opt/DEV_PLE/header/fsw_init.h | |
|
208 | <errno.h> | |
|
209 | <fcntl.h> | |
|
210 | <stdio.h> | |
|
211 | <stdlib.h> | |
|
212 | <grspw.h> | |
|
213 | <apbuart.h> | |
|
214 | <fsw_params.h> | |
|
215 | <fsw_misc.h> | |
|
216 | <fsw_processing.h> | |
|
217 | <tc_handler.h> | |
|
218 | <wf_handler.h> | |
|
219 | <grlib_regs.h> | |
|
220 | ||
|
221 | 1359614518 source:/opt/DEV_PLE/src/fsw_processing.c | |
|
222 | <fsw_processing.h> | |
|
223 | <math.h> | |
|
224 | <stdio.h> | |
|
225 | <leon.h> | |
|
226 |
@@ -1,43 +1,53 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
|
2 | 2 | <CodeBlocks_layout_file> |
|
3 | 3 | <ActiveTarget name="Debug" /> |
|
4 | 4 | <File name="../header/ccsds_types.h" open="0" top="0" tabpos="5"> |
|
5 | 5 | <Cursor position="1172" topLine="24" /> |
|
6 | 6 | </File> |
|
7 | 7 | <File name="../header/fsw_init.h" open="1" top="0" tabpos="3"> |
|
8 | 8 | <Cursor position="410" topLine="16" /> |
|
9 | 9 | </File> |
|
10 | 10 | <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0"> |
|
11 | 11 | <Cursor position="114" topLine="0" /> |
|
12 | 12 | </File> |
|
13 | 13 | <File name="../header/fsw_params.h" open="0" top="0" tabpos="0"> |
|
14 | 14 | <Cursor position="1320" topLine="8" /> |
|
15 | 15 | </File> |
|
16 | 16 | <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0"> |
|
17 | 17 | <Cursor position="510" topLine="0" /> |
|
18 | 18 | </File> |
|
19 | 19 | <File name="../header/tc_handler.h" open="0" top="0" tabpos="4"> |
|
20 | 20 | <Cursor position="634" topLine="0" /> |
|
21 | 21 | </File> |
|
22 | 22 | <File name="../header/wf_handler.h" open="0" top="0" tabpos="0"> |
|
23 | 23 | <Cursor position="212" topLine="0" /> |
|
24 | 24 | </File> |
|
25 | 25 | <File name="../src/fsw_globals.c" open="1" top="0" tabpos="4"> |
|
26 | 26 | <Cursor position="46" topLine="0" /> |
|
27 | 27 | </File> |
|
28 | <<<<<<< local | |
|
29 | <File name="../src/fsw_init.c" open="1" top="1" tabpos="0"> | |
|
30 | <Cursor position="1703" topLine="36" /> | |
|
31 | ======= | |
|
28 | 32 | <File name="../src/fsw_init.c" open="1" top="1" tabpos="2"> |
|
29 | 33 | <Cursor position="3361" topLine="60" /> |
|
34 | >>>>>>> other | |
|
30 | 35 | </File> |
|
31 | 36 | <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0"> |
|
32 | 37 | <Cursor position="20" topLine="0" /> |
|
33 | 38 | </File> |
|
34 | 39 | <File name="../src/fsw_processing.c" open="0" top="0" tabpos="2"> |
|
35 | 40 | <Cursor position="1175" topLine="46" /> |
|
36 | 41 | </File> |
|
42 | <<<<<<< local | |
|
43 | <File name="../src/tc_handler.c" open="0" top="0" tabpos="3"> | |
|
44 | <Cursor position="2672" topLine="26" /> | |
|
45 | ======= | |
|
37 | 46 | <File name="../src/tc_handler.c" open="1" top="0" tabpos="1"> |
|
38 | 47 | <Cursor position="11070" topLine="270" /> |
|
48 | >>>>>>> other | |
|
39 | 49 | </File> |
|
40 | 50 | <File name="../src/wf_handler.c" open="0" top="0" tabpos="0"> |
|
41 | 51 | <Cursor position="3936" topLine="62" /> |
|
42 | 52 | </File> |
|
43 | 53 | </CodeBlocks_layout_file> |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -1,118 +1,141 | |||
|
1 | 1 | #ifndef CCSDS_H_INCLUDED |
|
2 | 2 | #define CCSDS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4 |
|
5 | 5 | #define CCSDS_TM_PKT_MAX_SIZE 4412 |
|
6 | 6 | #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4 |
|
7 | #define CCSDS_TC_PKT_MAX_SIZE 248 | |
|
7 | #define CCSDS_TC_PKT_MAX_SIZE 50 // size of the TC_LFR_UPDATE_INFO packet | |
|
8 | 8 | #define CCSDS_TC_TM_PACKET_OFFSET 7 |
|
9 | 9 | #define CCSDS_PROCESS_ID 76 |
|
10 | 10 | #define CCSDS_PACKET_CATEGORY 12 |
|
11 | 11 | #define CCSDS_DESTINATION_ID 0x21 |
|
12 | 12 | #define CCSDS_PROTOCOLE_ID 0x02 |
|
13 | 13 | #define CCSDS_USER_APP 0x00 |
|
14 | 14 | |
|
15 | 15 | #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24 |
|
16 | 16 | #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32 |
|
17 | 17 | |
|
18 | 18 | #define ILLEGAL_APID 0 |
|
19 | 19 | #define WRONG_LEN_PACKET 1 |
|
20 | 20 | #define INCOR_CHECKSUM 2 |
|
21 | 21 | #define ILL_TYPE 3 |
|
22 | 22 | #define ILL_SUBTYPE 4 |
|
23 | 23 | #define WRONG_APP_DATA 5 |
|
24 | 24 | #define WRONG_CMD_CODE 6 |
|
25 | 25 | #define CCSDS_TM_VALID 7 |
|
26 | 26 | // |
|
27 | 27 | #define TC_NOT_EXE 40000 |
|
28 | 28 | #define WRONG_SRC_ID 40001 |
|
29 | 29 | #define FUNCT_NOT_IMPL 40002 |
|
30 | 30 | #define FAIL_DETECTED 40003 |
|
31 | 31 | #define NOT_ALLOWED 40004 |
|
32 | 32 | #define CORRUPTED 40005 |
|
33 | // | |
|
34 | #define SID_TC_RESET 3 | |
|
35 | #define SID_TC_LOAD_COMM 20 | |
|
36 |
#define |
|
|
37 |
#define |
|
|
38 |
#define |
|
|
39 |
#define |
|
|
40 | #define SID_TC_DUMP 30 | |
|
41 | #define SID_TC_ENTER 40 | |
|
42 | #define SID_TC_UPDT_INFO 50 | |
|
43 | #define SID_TC_EN_CAL 60 | |
|
44 |
#define |
|
|
45 | #define SID_TC_UPDT_TIME 129 | |
|
33 | ||
|
34 | // // TC SUBTYPES | |
|
35 | #define TC_SUBTYPE_RESET 3 | |
|
36 | #define TC_SUBTYPE_LOAD_COMM 20 | |
|
37 | #define TC_SUBTYPE_LOAD_NORM 21 | |
|
38 | #define TC_SUBTYPE_LOAD_BURST 24 | |
|
39 | #define TC_SUBTYPE_LOAD_SBM1 27 | |
|
40 | #define TC_SUBTYPE_LOAD_SBM2 28 | |
|
41 | #define TC_SUBTYPE_DUMP 30 | |
|
42 | #define TC_SUBTYPE_ENTER 40 | |
|
43 | #define TC_SUBTYPE_UPDT_INFO 50 | |
|
44 | #define TC_SUBTYPE_EN_CAL 60 | |
|
45 | #define TC_SUBTYPE_DIS_CAL 61 | |
|
46 | #define TC_SUBTYPE_UPDT_TIME 129 | |
|
46 | 47 | |
|
47 | 48 | #define SID_DEFAULT 0 |
|
48 | 49 | #define SID_EXE_INC 5 |
|
49 | 50 | #define SID_NOT_EXE 40000 |
|
50 | 51 | #define SID_NOT_IMP 40002 |
|
51 | 52 | #define SID_EXE_ERR 40003 |
|
52 | 53 | #define SID_EXE_CORR 40005 |
|
53 | 54 | |
|
54 | 55 | #define SID_NORM_SWF_F0 3 |
|
55 | 56 | #define SID_NORM_SWF_F1 4 |
|
56 | 57 | #define SID_NORM_SWF_F2 5 |
|
57 | 58 | #define SID_NORM_CWF_F3 1 |
|
59 | #define SID_BURST_CWF_F2 2 | |
|
60 | #define SID_SBM1_CWF_F1 24 | |
|
61 | #define SID_SBM2_CWF_F2 25 | |
|
62 | #define SID_NORM_ASM_F0 11 | |
|
63 | #define SID_NORM_ASM_F1 12 | |
|
64 | #define SID_NORM_ASM_F2 13 | |
|
65 | #define SID_NORM_BP1_F0 14 | |
|
66 | #define SID_NORM_BP1_F1 15 | |
|
67 | #define SID_NORM_BP1_F2 16 | |
|
68 | #define SID_NORM_BP2_F0 19 | |
|
69 | #define SID_NORM_BP2_F1 20 | |
|
70 | #define SID_NORM_BP2_F2 21 | |
|
71 | #define SID_BURST_BP1_F0 17 | |
|
72 | #define SID_BURST_BP2_F0 22 | |
|
73 | #define SID_BURST_BP1_F1 18 | |
|
74 | #define SID_BURST_BP2_F1 23 | |
|
75 | #define SID_SBM1_BP1_F0 28 | |
|
76 | #define SID_SBM1_BP2_F0 31 | |
|
77 | #define SID_SBM2_BP1_F0 29 | |
|
78 | #define SID_SBM2_BP2_F0 32 | |
|
79 | #define SID_SBM1_BP1_F1 30 | |
|
80 | #define SID_SBM1_BP2_F1 33 | |
|
58 | 81 | |
|
59 | 82 | #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET |
|
60 | 83 | #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET |
|
61 | 84 | #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET |
|
62 | 85 | #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET |
|
63 | 86 | #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET |
|
64 | 87 | #define TM_HEADER_LEN 16 |
|
65 | 88 | #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1 |
|
66 | 89 | #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1 |
|
67 | 90 | |
|
68 | 91 | enum TM_TYPE{ |
|
69 | 92 | TM_LFR_TC_EXE_OK, |
|
70 | 93 | TM_LFR_TC_EXE_ERR, |
|
71 | 94 | TM_LFR_HK, |
|
72 | 95 | TM_LFR_SCI, |
|
73 | 96 | TM_LFR_SCI_SBM, |
|
74 | 97 | TM_LFR_PAR_DUMP |
|
75 | 98 | }; |
|
76 | 99 | |
|
77 | 100 | struct TMHeader_str |
|
78 | 101 | { |
|
79 | 102 | volatile unsigned char targetLogicalAddress; |
|
80 | 103 | volatile unsigned char protocolIdentifier; |
|
81 | 104 | volatile unsigned char reserved; |
|
82 | 105 | volatile unsigned char userApplication; |
|
83 | 106 | volatile unsigned char packetID[2]; |
|
84 | 107 | volatile unsigned char packetSequenceControl[2]; |
|
85 | 108 | volatile unsigned char packetLength[2]; |
|
86 | 109 | volatile unsigned char dataFieldHeader[10]; |
|
87 | 110 | }; |
|
88 | 111 | typedef struct TMHeader_str TMHeader_t; |
|
89 | 112 | |
|
90 | 113 | struct ExtendedTMHeader_str |
|
91 | 114 | { |
|
92 | 115 | volatile unsigned char targetLogicalAddress; |
|
93 | 116 | volatile unsigned char protocolIdentifier; |
|
94 | 117 | volatile unsigned char reserved; |
|
95 | 118 | volatile unsigned char userApplication; |
|
96 | 119 | volatile unsigned char packetID[2]; |
|
97 | 120 | volatile unsigned char packetSequenceControl[2]; |
|
98 | 121 | volatile unsigned char packetLength[2]; |
|
99 | 122 | volatile unsigned char dataFieldHeader[10]; |
|
100 | 123 | volatile unsigned char auxiliaryHeader[6]; |
|
101 | 124 | }; |
|
102 | 125 | typedef struct ExtendedTMHeader_str ExtendedTMHeader_t; |
|
103 | 126 | |
|
104 | 127 | struct ccsdsTelecommandPacket_str |
|
105 | 128 | { |
|
106 | 129 | //unsigned char targetLogicalAddress; // removed by the grspw module |
|
107 | 130 | volatile unsigned char protocolIdentifier; |
|
108 | 131 | volatile unsigned char reserved; |
|
109 | 132 | volatile unsigned char userApplication; |
|
110 | 133 | volatile unsigned char packetID[2]; |
|
111 | 134 | volatile unsigned char packetSequenceControl[2]; |
|
112 | 135 | volatile unsigned char packetLength[2]; |
|
113 | 136 | volatile unsigned char dataFieldHeader[4]; |
|
114 | 137 | volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10]; |
|
115 | 138 | }; |
|
116 | 139 | typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t; |
|
117 | 140 | |
|
118 | 141 | #endif // CCSDS_H_INCLUDED |
@@ -1,41 +1,45 | |||
|
1 | 1 | #ifndef FSW_RTEMS_H_INCLUDED |
|
2 | 2 | #define FSW_RTEMS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <errno.h> |
|
5 | 5 | #include <fcntl.h> |
|
6 | 6 | #include <stdio.h> |
|
7 | 7 | #include <stdlib.h> |
|
8 | 8 | |
|
9 | 9 | #include <grspw.h> |
|
10 | 10 | #include <apbuart.h> |
|
11 | 11 | |
|
12 | 12 | #include <fsw_params.h> |
|
13 | 13 | #include <fsw_misc.h> |
|
14 | 14 | #include <fsw_processing.h> |
|
15 | 15 | #include <tc_handler.h> |
|
16 | 16 | #include <wf_handler.h> |
|
17 | 17 | #include <grlib_regs.h> |
|
18 | 18 | |
|
19 | 19 | extern int sched_yield(); |
|
20 | 20 | extern int errno; |
|
21 | extern rtems_name misc_names[ ]; | |
|
21 | extern rtems_id Task_id[ ]; /* array of task ids */ | |
|
22 | extern rtems_name Task_name[ ]; /* array of task names */ | |
|
23 | extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */ | |
|
24 | extern int fdSPW; // grspw file descriptor | |
|
25 | extern int fdUART; // uart file descriptor | |
|
22 | 26 | |
|
23 | 27 | // RTEMS TASKS |
|
24 | 28 | rtems_task Init( rtems_task_argument argument); /* forward declaration needed */ |
|
25 |
rtems_task |
|
|
26 |
rtems_task |
|
|
27 |
rtems_task |
|
|
28 |
rtems_task |
|
|
29 | rtems_task recv_task(rtems_task_argument argument); | |
|
30 | rtems_task spiq_task(rtems_task_argument argument); | |
|
31 | rtems_task stat_task(rtems_task_argument argument); | |
|
32 | rtems_task wfrm_task(rtems_task_argument argument); | |
|
29 | 33 | int create_all_tasks(); |
|
30 | 34 | int start_all_tasks(); |
|
31 | 35 | int create_message_queue(); |
|
32 | 36 | |
|
33 | 37 | // OTHER functions |
|
34 | 38 | int configure_spw_link(); |
|
35 | 39 | int send_console_outputs_on_serial_port(); |
|
36 | 40 | extern int rtems_cpu_usage_report(); |
|
37 | 41 | extern int rtems_cpu_usage_reset(); |
|
38 | 42 | void print_statistics(spw_stats *); |
|
39 | 43 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send); |
|
40 | 44 | |
|
41 | 45 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -1,19 +1,19 | |||
|
1 | 1 | #ifndef FSW_MISC_H_INCLUDED |
|
2 | 2 | #define FSW_MISC_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | |
|
7 | 7 | #include <fsw_init.h> |
|
8 | 8 | #include <fsw_params.h> |
|
9 | 9 | #include <grlib_regs.h> |
|
10 | 10 | #include <grspw.h> |
|
11 | 11 | #include <ccsds_types.h> |
|
12 | 12 | |
|
13 | 13 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
14 | 14 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
15 | 15 | void print_statistics(spw_stats *stats); |
|
16 | 16 | int send_console_outputs_on_serial_port(); |
|
17 |
rtems_task |
|
|
17 | rtems_task stat_task(rtems_task_argument argument); | |
|
18 | 18 | |
|
19 | 19 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,51 +1,60 | |||
|
1 | 1 | #ifndef FSW_RTEMS_CONFIG_H_INCLUDED |
|
2 | 2 | #define FSW_RTEMS_CONFIG_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
5 | 5 | #define UART_DEVICE_NAME "/dev/console" |
|
6 | 6 | |
|
7 | //***************************** | |
|
8 | // APB REGISTERS BASE ADDRESSES | |
|
7 | 9 | #define REGS_ADDR_APBUART 0x80000100 |
|
8 | 10 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
9 | 11 | #define REGS_ADDR_GRSPW 0x80000500 |
|
10 | 12 | #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700 |
|
11 | 13 | |
|
12 | 14 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
13 | 15 | |
|
14 | 16 | #define IRQ_SM 9 |
|
15 | 17 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
16 | 18 | #define IRQ_WF 10 |
|
17 | 19 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels |
|
18 | 20 | |
|
19 | 21 | #define CLKDIV_SM_SIMULATOR 9999 |
|
20 | 22 | #define CLKDIV_WF_SIMULATOR 9999999 |
|
21 | 23 | #define TIMER_SM_SIMULATOR 1 |
|
22 | 24 | #define TIMER_WF_SIMULATOR 2 |
|
23 | 25 | |
|
26 | //****** | |
|
27 | // RTEMS | |
|
24 | 28 | #define TASKID_RECV 1 |
|
29 | #define TASKID_ACTN 1 | |
|
25 | 30 | #define TASKID_SPIQ 3 |
|
26 | 31 | #define TASKID_SMIQ 4 |
|
27 | 32 | #define TASKID_STAT 5 |
|
28 | 33 | #define TASKID_AVF0 6 |
|
29 | 34 | #define TASKID_BPF0 7 |
|
30 | 35 | #define TASKID_WFRM 8 |
|
31 | 36 | |
|
37 | #define ACTION_MSG_QUEUE_COUNT 10 | |
|
38 | ||
|
39 | //******* | |
|
40 | // MACROS | |
|
32 | 41 | #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions |
|
33 | 42 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
34 | 43 | #define PRINTF(x) printf(x); |
|
35 | 44 | #define PRINTF1(x,y) printf(x,y); |
|
36 | 45 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
37 | 46 | #else |
|
38 | 47 | #define PRINTF(x) ; |
|
39 | 48 | #define PRINTF1(x,y) ; |
|
40 | 49 | #define PRINTF2(x,y,z) ; |
|
41 | 50 | #endif |
|
42 | 51 | |
|
43 | 52 | #define NB_SAMPLES_PER_SNAPSHOT 2048 |
|
44 | 53 | #define NB_BYTES_SWF_BLK 2 * 6 |
|
45 | 54 | |
|
46 | 55 | extern volatile int wf_snap_f0[ ]; // 24576 bytes |
|
47 | 56 | extern volatile int wf_snap_f1[ ]; // 24576 bytes |
|
48 | 57 | extern volatile int wf_snap_f2[ ]; // 24576 bytes |
|
49 | 58 | extern volatile int wf_cont_f3[ ]; // 24576 bytes |
|
50 | 59 | |
|
51 | 60 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -1,44 +1,44 | |||
|
1 | 1 | #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED |
|
2 | 2 | #define FSW_RTEMS_PROCESSING_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #define NB_BINS_spec_mat 128 |
|
5 | 5 | #define NB_VALUES_PER_spec_mat 25 |
|
6 | 6 | #define TOTAL_SIZE_SPEC_MAT NB_BINS_spec_mat * NB_VALUES_PER_spec_mat |
|
7 | 7 | #define NB_BINS_COMPRESSED_MATRIX_f0 11 |
|
8 | 8 | #define SIZE_COMPRESSED_spec_mat_f1 13 |
|
9 | 9 | #define SIZE_COMPRESSED_spec_mat_f2 12 |
|
10 | 10 | #define TOTAL_SIZE_COMPRESSED_MATRIX_f0 NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_spec_mat |
|
11 | 11 | #define NB_AVERAGE_NORMAL_f0 96*4 |
|
12 | 12 | #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8 |
|
13 | 13 | |
|
14 | 14 | #include <rtems.h> |
|
15 | 15 | #include <grlib_regs.h> |
|
16 | 16 | #include <fsw_params.h> |
|
17 | 17 | |
|
18 | 18 | struct BP1_str{ |
|
19 | 19 | volatile unsigned char PE[2]; |
|
20 | 20 | volatile unsigned char PB[2]; |
|
21 | 21 | volatile unsigned char V0; |
|
22 | 22 | volatile unsigned char V1; |
|
23 | 23 | volatile unsigned char V2_ELLIP_DOP; |
|
24 | 24 | volatile unsigned char SZ; |
|
25 | 25 | volatile unsigned char VPHI; |
|
26 | 26 | }; |
|
27 | 27 | typedef struct BP1_str BP1_t; |
|
28 | 28 | |
|
29 | 29 | // ISR |
|
30 | 30 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
31 | 31 | // RTEMS TASKS |
|
32 | 32 | rtems_task spw_bppr_task(rtems_task_argument argument); |
|
33 |
rtems_task |
|
|
34 |
rtems_task |
|
|
35 |
rtems_task |
|
|
33 | rtems_task avf0_task(rtems_task_argument argument); | |
|
34 | rtems_task bpf0_task(rtems_task_argument argument); | |
|
35 | rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator | |
|
36 | 36 | // |
|
37 | 37 | rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument); |
|
38 | 38 | void matrix_average(volatile int *spec_mat, float *averaged_spec_mat); |
|
39 | 39 | void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat); |
|
40 | 40 | void matrix_reset(float *averaged_spec_mat); |
|
41 | 41 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1); |
|
42 | 42 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat); |
|
43 | 43 | |
|
44 | 44 | #endif // FSW_RTEMS_PROCESSING_H_INCLUDED |
@@ -1,40 +1,48 | |||
|
1 | 1 | #ifndef TC_HANDLER_H_INCLUDED |
|
2 | 2 | #define TC_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | #include <unistd.h> // for the read call |
|
7 | 7 | #include <sys/ioctl.h> // for the ioctl call |
|
8 | 8 | #include <ccsds_types.h> |
|
9 | 9 | #include <grspw.h> |
|
10 | #include <fsw_init.h> | |
|
10 | 11 | |
|
11 | 12 | extern int fdSPW; |
|
13 | extern rtems_name misc_name[ ]; | |
|
14 | extern rtems_name misc_id[ ]; | |
|
12 | 15 | extern rtems_id Task_id[ ]; /* array of task ids */ |
|
13 | 16 | |
|
14 | 17 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field |
|
15 | 18 | unsigned char currentTC_COMPUTED_CRC[2]; |
|
16 | 19 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; |
|
17 | 20 | unsigned int currentTM_length; |
|
18 | 21 | unsigned char currentTC_processedFlag; |
|
19 | 22 | |
|
20 | 23 | //********************** |
|
21 | 24 | // GENERAL USE FUNCTIONS |
|
22 | 25 | unsigned int lookUpTableForCRC[256]; |
|
23 | 26 | void InitLookUpTableForCRC(); |
|
24 | 27 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); |
|
25 | 28 | |
|
26 | 29 | //********************* |
|
27 | 30 | // ACCEPTANCE FUNCTIONS |
|
28 |
unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int |
|
|
31 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv); | |
|
29 | 32 | |
|
30 | 33 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength, |
|
31 | 34 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader); |
|
32 | 35 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC); |
|
33 |
|
|
|
34 | TMHeader_t *TM_Header, unsigned int *hlen, char *data); | |
|
36 | int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV); | |
|
35 | 37 | |
|
36 | 38 | //*********** |
|
37 | 39 | // RTEMS TASK |
|
38 |
rtems_task |
|
|
40 | rtems_task recv_task( rtems_task_argument unused ); | |
|
41 | rtems_task actn_task( rtems_task_argument unused ); | |
|
42 | int create_message_queue(); | |
|
43 | ||
|
44 | //*********** | |
|
45 | // TC ACTIONS | |
|
46 | int default_action(ccsdsTelecommandPacket_t *TC); | |
|
39 | 47 | |
|
40 | 48 | #endif // TC_HANDLER_H_INCLUDED |
@@ -1,20 +1,20 | |||
|
1 | 1 | #ifndef WF_HANDLER_H_INCLUDED |
|
2 | 2 | #define WF_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <fsw_params.h> |
|
6 | 6 | #include <grspw.h> |
|
7 | 7 | #include <grlib_regs.h> |
|
8 | 8 | #include <ccsds_types.h> |
|
9 | 9 | #include <stdio.h> |
|
10 | 10 | #include <fsw_init.h> |
|
11 | 11 | |
|
12 | 12 | //#include <sys/ioctl.h> |
|
13 | 13 | |
|
14 | 14 | extern rtems_id Task_id[]; /* array of task ids */ |
|
15 | 15 | extern int fdSPW; |
|
16 | 16 | |
|
17 | 17 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
18 |
rtems_task |
|
|
18 | rtems_task wfrm_task(rtems_task_argument argument); | |
|
19 | 19 | |
|
20 | 20 | #endif // WF_HANDLER_H_INCLUDED |
@@ -1,29 +1,34 | |||
|
1 | 1 | #include <fsw_processing.h> |
|
2 | 2 | #include <rtems.h> |
|
3 | 3 | |
|
4 | 4 | // RTEMS GLOBAL VARIABLES |
|
5 |
rtems_name misc_name |
|
|
5 | rtems_name misc_name[5]; | |
|
6 | rtems_name misc_id[5]; | |
|
7 | rtems_id Task_id[10]; /* array of task ids */ | |
|
8 | rtems_name Task_name[10]; /* array of task names */ | |
|
9 | int fdSPW; | |
|
10 | int fdUART; | |
|
6 | 11 | |
|
7 | 12 | // WAVEFORMS GLOBAL VARIABLES |
|
8 | 13 | volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes |
|
9 | 14 | volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes |
|
10 | 15 | volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes |
|
11 | 16 | volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes |
|
12 | 17 | |
|
13 | 18 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
14 | 19 | volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ]; |
|
15 | 20 | volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ]; |
|
16 | 21 | volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ]; |
|
17 | 22 | volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ]; |
|
18 | 23 | volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ]; |
|
19 | 24 | volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ]; |
|
20 | 25 | volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ]; |
|
21 | 26 | volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ]; |
|
22 | 27 | // |
|
23 | 28 | float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ]; |
|
24 | 29 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; |
|
25 | 30 | |
|
26 | 31 | // BASIC PARAMETERS GLOBAL VAIRABLES |
|
27 | 32 | unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ]; |
|
28 | 33 | |
|
29 | 34 | BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ]; |
@@ -1,257 +1,255 | |||
|
1 | 1 | //************************* |
|
2 | 2 | // GPL reminder to be added |
|
3 | 3 | //************************* |
|
4 | 4 | |
|
5 | 5 | #include <rtems.h> |
|
6 | 6 | |
|
7 | 7 | /* configuration information */ |
|
8 | 8 | |
|
9 | 9 | #define CONFIGURE_INIT |
|
10 | 10 | |
|
11 | 11 | #include <bsp.h> /* for device driver prototypes */ |
|
12 | 12 | |
|
13 | 13 | /* configuration information */ |
|
14 | 14 | |
|
15 | 15 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
16 | 16 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
17 | 17 | |
|
18 | 18 | #define CONFIGURE_MAXIMUM_TASKS 10 |
|
19 | 19 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
20 | 20 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
21 | 21 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
22 | 22 | #define CONFIGURE_INIT_TASK_PRIORITY 100 |
|
23 | 23 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
24 | 24 | #define CONFIGURE_MAXIMUM_PERIODS 1 |
|
25 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 | |
|
25 | 26 | |
|
26 | 27 | #include <rtems/confdefs.h> |
|
27 | 28 | |
|
28 | 29 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
29 | 30 | #ifdef RTEMS_DRVMGR_STARTUP |
|
30 | 31 | #ifdef LEON3 |
|
31 | 32 | /* Add Timer and UART Driver */ |
|
32 | 33 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
33 | 34 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
34 | 35 | #endif |
|
35 | 36 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
36 | 37 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
37 | 38 | #endif |
|
38 | 39 | #endif |
|
39 | 40 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
40 | 41 | #include <drvmgr/drvmgr_confdefs.h> |
|
41 | 42 | #endif |
|
42 | 43 | |
|
43 | 44 | #include <fsw_init.h> |
|
44 | 45 | #include <fsw_config.c> |
|
45 | 46 | |
|
46 | int fdSPW; | |
|
47 | int fdUART; | |
|
48 | ||
|
49 | 47 | char *link_status(int status); |
|
50 | 48 | |
|
51 | 49 | char *lstates[6] = {"Error-reset", |
|
52 | 50 | "Error-wait", |
|
53 | 51 | "Ready", |
|
54 | 52 | "Started", |
|
55 | 53 | "Connecting", |
|
56 | 54 | "Run" |
|
57 | 55 | }; |
|
58 | 56 | |
|
59 | rtems_id Task_id[10]; /* array of task ids */ | |
|
60 | rtems_name Task_name[10]; /* array of task names */ | |
|
61 | ||
|
62 | 57 | rtems_task Init( rtems_task_argument ignored ) |
|
63 | 58 | { |
|
64 | 59 | rtems_status_code status; |
|
65 | 60 | |
|
66 | 61 | //send_console_outputs_on_serial_port(); |
|
67 | 62 | |
|
68 | 63 | InitLookUpTableForCRC(); // in tc_handler.h |
|
69 | 64 | |
|
70 | 65 | create_message_queue(); |
|
71 | 66 | create_all_tasks(); |
|
72 | 67 | start_all_tasks(); |
|
73 | 68 | |
|
74 | 69 | configure_spw_link(); |
|
75 | 70 | // configure timer for spectral matrices simulation |
|
76 | 71 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
77 | 72 | IRQ_SPARC_SM, spectral_matrices_isr ); |
|
78 | 73 | // configure timer for waveforms simulation |
|
79 | 74 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, |
|
80 | 75 | IRQ_SPARC_WF, waveforms_isr ); |
|
81 | 76 | |
|
82 | 77 | LEON_Unmask_interrupt( IRQ_SM ); |
|
83 | 78 | LEON_Unmask_interrupt( IRQ_WF ); |
|
84 | 79 | |
|
85 | 80 | status = rtems_task_delete(RTEMS_SELF); |
|
86 | 81 | } |
|
87 | 82 | |
|
88 |
rtems_task |
|
|
83 | rtems_task spiq_task(rtems_task_argument unused) | |
|
89 | 84 | { |
|
90 | 85 | rtems_event_set event_out; |
|
91 | 86 | struct grspw_regs_str *grspw_regs; |
|
92 | 87 | grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW; |
|
93 | 88 | |
|
94 | 89 | while(1){ |
|
95 | 90 | PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n") |
|
96 | 91 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
97 | 92 | |
|
98 | 93 | if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task |
|
99 | 94 | PRINTF("In SPIQ *** Error suspending RECV Task\n") |
|
100 | 95 | |
|
101 | 96 | configure_spw_link(); |
|
102 | 97 | |
|
103 | 98 | if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task |
|
104 | 99 | PRINTF("In SPIQ *** Error resume RECV Task\n") |
|
105 | 100 | } |
|
106 | 101 | } |
|
107 | 102 | |
|
108 | int create_message_queue() | |
|
109 | { | |
|
110 | misc_names[0] = rtems_build_name( 'D', 'O', 'I', 'T' ); | |
|
111 | return 0; | |
|
112 | } | |
|
113 | ||
|
114 | 103 | int create_all_tasks() |
|
115 | 104 | { |
|
116 | 105 | rtems_status_code status; |
|
117 | 106 | |
|
118 | 107 | Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
108 | Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
|
119 | 109 | Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
120 | 110 | Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
121 | 111 | Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
122 | 112 | Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
123 | 113 | Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' ); |
|
124 | 114 | Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
125 | 115 | |
|
126 | 116 | // RECV |
|
127 | 117 | status = rtems_task_create( |
|
128 | 118 | Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
129 | 119 | RTEMS_DEFAULT_MODES, |
|
130 | 120 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1] |
|
131 | 121 | ); |
|
122 | // ACTN | |
|
123 | status = rtems_task_create( | |
|
124 | Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2, | |
|
125 | RTEMS_DEFAULT_MODES, | |
|
126 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2] | |
|
127 | ); | |
|
132 | 128 | // SPIQ |
|
133 | 129 | status = rtems_task_create( |
|
134 | 130 | Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
135 | 131 | RTEMS_DEFAULT_MODES, |
|
136 | 132 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3] |
|
137 | 133 | ); |
|
138 | 134 | // SMIQ |
|
139 | 135 | status = rtems_task_create( |
|
140 | 136 | Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
141 | 137 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
142 | 138 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4] |
|
143 | 139 | ); |
|
144 | 140 | // STAT |
|
145 | 141 | status = rtems_task_create( |
|
146 | 142 | Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
147 | 143 | RTEMS_DEFAULT_MODES, |
|
148 | 144 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5] |
|
149 | 145 | ); |
|
150 | 146 | // AVF0 |
|
151 | 147 | status = rtems_task_create( |
|
152 | 148 | Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
153 | 149 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
154 | 150 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6] |
|
155 | 151 | ); |
|
156 | 152 | // BPF0 |
|
157 | 153 | status = rtems_task_create( |
|
158 | 154 | Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
159 | 155 | RTEMS_DEFAULT_MODES, |
|
160 | 156 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7] |
|
161 | 157 | ); |
|
162 | 158 | // WFRM |
|
163 | 159 | status = rtems_task_create( |
|
164 | 160 | Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
165 | 161 | RTEMS_DEFAULT_MODES, |
|
166 | 162 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8] |
|
167 | 163 | ); |
|
168 | 164 | |
|
169 | 165 | return 0; |
|
170 | 166 | } |
|
171 | 167 | |
|
172 | 168 | int start_all_tasks() |
|
173 | 169 | { |
|
174 | 170 | rtems_status_code status; |
|
175 | 171 | |
|
176 |
status = rtems_task_start( Task_id[3], |
|
|
172 | status = rtems_task_start( Task_id[3], spiq_task, 1 ); | |
|
177 | 173 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n") |
|
178 | 174 | |
|
179 |
status = rtems_task_start( Task_id[1], |
|
|
175 | status = rtems_task_start( Task_id[1], recv_task, 1 ); | |
|
180 | 176 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n") |
|
181 | 177 | |
|
182 |
|
|
|
183 | status = rtems_task_start( Task_id[4], spw_smiq_task, 1 ); | |
|
178 | status = rtems_task_start( Task_id[2], actn_task, 1 ); | |
|
179 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n") | |
|
180 | ||
|
181 | status = rtems_task_start( Task_id[4], smiq_task, 1 ); | |
|
184 | 182 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n") |
|
185 | 183 | |
|
186 |
status = rtems_task_start( Task_id[5], |
|
|
184 | status = rtems_task_start( Task_id[5], stat_task, 1 ); | |
|
187 | 185 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n") |
|
188 | 186 | |
|
189 |
status = rtems_task_start( Task_id[6], |
|
|
187 | status = rtems_task_start( Task_id[6], avf0_task, 1 ); | |
|
190 | 188 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n") |
|
191 | 189 | |
|
192 |
status = rtems_task_start( Task_id[7], |
|
|
190 | status = rtems_task_start( Task_id[7], bpf0_task, 1 ); | |
|
193 | 191 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n") |
|
194 | 192 | |
|
195 |
status = rtems_task_start( Task_id[8], |
|
|
193 | status = rtems_task_start( Task_id[8], wfrm_task, 1 ); | |
|
196 | 194 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n") |
|
197 | 195 | |
|
198 | 196 | return 0; |
|
199 | 197 | } |
|
200 | 198 | |
|
201 | 199 | int configure_spw_link() |
|
202 | 200 | { |
|
203 | 201 | rtems_status_code status; |
|
204 | 202 | |
|
205 | 203 | close(fdSPW); // close the device if it is already open |
|
206 | 204 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware |
|
207 | 205 | if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") |
|
208 | 206 | while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){ |
|
209 | 207 | PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n") |
|
210 | 208 | close(fdSPW); // close the device |
|
211 | 209 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware |
|
212 | 210 | if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") |
|
213 | 211 | rtems_task_wake_after(100); |
|
214 | 212 | } |
|
215 | 213 | |
|
216 | 214 | PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n") |
|
217 | 215 | |
|
218 | 216 | // sets a few parameters of the link |
|
219 | 217 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit |
|
220 | 218 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n") |
|
221 | 219 | // |
|
222 | 220 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
223 | 221 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
224 | 222 | // |
|
225 | 223 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a |
|
226 | 224 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
227 | 225 | // |
|
228 | 226 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts |
|
229 | 227 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
230 | 228 | // |
|
231 | 229 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
232 | 230 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
233 | 231 | |
|
234 | 232 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit |
|
235 | 233 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
236 | 234 | // |
|
237 | 235 | //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key |
|
238 | 236 | //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
239 | 237 | // |
|
240 | 238 | PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n") |
|
241 | 239 | |
|
242 | 240 | return RTEMS_SUCCESSFUL; |
|
243 | 241 | } |
|
244 | 242 | |
|
245 | 243 | char *link_status(int status){ |
|
246 | 244 | return lstates[status]; |
|
247 | 245 | } |
|
248 | 246 | |
|
249 | 247 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send) |
|
250 | 248 | { |
|
251 | 249 | rtems_status_code status; |
|
252 | 250 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
253 | 251 | if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n"); |
|
254 | 252 | return status; |
|
255 | 253 | } |
|
256 | 254 | |
|
257 | 255 |
@@ -1,73 +1,73 | |||
|
1 | 1 | #include <fsw_misc.h> |
|
2 | 2 | #include <fsw_params.h> |
|
3 | 3 | |
|
4 | 4 | extern rtems_id Task_id[]; /* array of task ids */ |
|
5 | 5 | extern int fdSPW; |
|
6 | 6 | |
|
7 | 7 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
8 | 8 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
9 | 9 | { // configure the timer for the waveforms simulation |
|
10 | 10 | rtems_status_code status; |
|
11 | 11 | rtems_isr_entry old_isr_handler; |
|
12 | 12 | |
|
13 | 13 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
14 | 14 | //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n") |
|
15 | 15 | |
|
16 | 16 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
17 | 17 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
18 | 18 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
19 | 19 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
20 | 20 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
21 | 21 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
22 | 22 | |
|
23 | 23 | return 1; |
|
24 | 24 | } |
|
25 | 25 | |
|
26 | 26 | void print_statistics(spw_stats *stats) |
|
27 | 27 | { |
|
28 | 28 | //printf(" ******** STATISTICS ******** \n"); |
|
29 | 29 | printf("Transmit link errors: %i\n", stats->tx_link_err); |
|
30 | 30 | printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err); |
|
31 | 31 | printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err); |
|
32 | 32 | printf("Receiver EEP errors: %i\n", stats->rx_eep_err); |
|
33 | 33 | printf("Receiver truncation errors: %i\n", stats->rx_truncated); |
|
34 | 34 | printf("Parity errors: %i\n", stats->parity_err); |
|
35 | 35 | printf("Escape errors: %i\n", stats->escape_err); |
|
36 | 36 | printf("Credit errors: %i\n", stats->credit_err); |
|
37 | 37 | printf("Disconnect errors: %i\n", stats->disconnect_err); |
|
38 | 38 | printf("Write synchronization errors: %i\n", stats->write_sync_err); |
|
39 | 39 | printf("Early EOP/EEP: %i\n", stats->early_ep); |
|
40 | 40 | printf("Invalid Node Address: %i\n", stats->invalid_address); |
|
41 | 41 | printf("Packets transmitted: %i\n", stats->packets_sent); |
|
42 | 42 | printf("Packets received: %i\n", stats->packets_received); |
|
43 | 43 | } |
|
44 | 44 | |
|
45 | 45 | int send_console_outputs_on_serial_port() // Send the console outputs on the serial port |
|
46 | 46 | { |
|
47 | 47 | struct apbuart_regs_str *apbuart_regs; |
|
48 | 48 | |
|
49 | 49 | apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
50 | 50 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; |
|
51 | 51 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
52 | 52 | |
|
53 | 53 | return 0; |
|
54 | 54 | } |
|
55 | 55 | |
|
56 |
rtems_task |
|
|
56 | rtems_task stat_task(rtems_task_argument argument) | |
|
57 | 57 | { |
|
58 | 58 | int i; |
|
59 | 59 | i = 0; |
|
60 | 60 | PRINTF("In STAT *** \n") |
|
61 | 61 | while(1){ |
|
62 | 62 | rtems_task_wake_after(1000); |
|
63 | 63 | PRINTF1("%d\n", i) |
|
64 | 64 | if (i == 2) { |
|
65 | 65 | rtems_cpu_usage_report(); |
|
66 | 66 | rtems_cpu_usage_reset(); |
|
67 | 67 | i = 0; |
|
68 | 68 | } |
|
69 | 69 | else i++; |
|
70 | 70 | } |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 |
@@ -1,423 +1,423 | |||
|
1 | 1 | #include <fsw_processing.h> |
|
2 | 2 | #include <math.h> |
|
3 | 3 | #include <stdio.h> |
|
4 | 4 | #include <leon.h> |
|
5 | 5 | |
|
6 | 6 | float k14_re = 1; |
|
7 | 7 | float k14_im = 1; |
|
8 | 8 | float k14_bis_re = 1; |
|
9 | 9 | float k14_bis_im = 1; |
|
10 | 10 | float k14_tris_re = 1; |
|
11 | 11 | float k14_tris_im = 1; |
|
12 | 12 | float k15_re = 1; |
|
13 | 13 | float k15_im = 1; |
|
14 | 14 | float k15_bis_re = 1; |
|
15 | 15 | float k15_bis_im = 1; |
|
16 | 16 | float k24_re = 1; |
|
17 | 17 | float k24_im = 1; |
|
18 | 18 | float k24_bis_re = 1; |
|
19 | 19 | float k24_bis_im = 1; |
|
20 | 20 | float k24_tris_re = 1; |
|
21 | 21 | float k24_tris_im = 1; |
|
22 | 22 | float k25_re = 1; |
|
23 | 23 | float k25_im = 1; |
|
24 | 24 | float k25_bis_re = 1; |
|
25 | 25 | float k25_bis_im = 1; |
|
26 | 26 | float k34_re = 1; |
|
27 | 27 | float k34_im = 1; |
|
28 | 28 | float k44 = 1; |
|
29 | 29 | float k55 = 1; |
|
30 | 30 | float k45_re = 1; |
|
31 | 31 | float k45_im = 1; |
|
32 | 32 | float alpha_M = M_PI/4; |
|
33 | 33 | |
|
34 | 34 | extern volatile int spec_mat_f0_a[ ]; |
|
35 | 35 | extern volatile int spec_mat_f0_b[ ]; |
|
36 | 36 | extern volatile int spec_mat_f0_c[ ]; |
|
37 | 37 | extern volatile int spec_mat_f0_d[ ]; |
|
38 | 38 | extern volatile int spec_mat_f0_e[ ]; |
|
39 | 39 | extern volatile int spec_mat_f0_f[ ]; |
|
40 | 40 | extern volatile int spec_mat_f0_g[ ]; |
|
41 | 41 | extern volatile int spec_mat_f0_h[ ]; |
|
42 | 42 | extern float averaged_spec_mat_f0[ ]; |
|
43 | 43 | extern float compressed_spec_mat_f0[ ]; |
|
44 | 44 | extern unsigned char LFR_BP1_F0[ ]; |
|
45 | 45 | |
|
46 | 46 | extern BP1_t data_BP1[ ]; |
|
47 | 47 | |
|
48 | 48 | extern rtems_id Task_id[ ]; /* array of task ids */ |
|
49 | 49 | |
|
50 | 50 | spectral_matrices_regs_t *spectral_matrices_regs; |
|
51 | 51 | |
|
52 | 52 | // Interrupt Service Routine for spectral matrices processing |
|
53 | 53 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
54 | 54 | { |
|
55 | 55 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
56 | 56 | printf("In spectral_matrices_isr *** Error sending event to AVF0\n"); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 |
rtems_task |
|
|
59 | rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ | |
|
60 | 60 | { |
|
61 | 61 | rtems_event_set event_out; |
|
62 | 62 | gptimer_regs_t *gptimer_regs; |
|
63 | 63 | gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
64 | 64 | unsigned char nb_interrupt_f0 = 0; |
|
65 | 65 | |
|
66 | 66 | while(1){ |
|
67 | 67 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
68 | 68 | nb_interrupt_f0 = nb_interrupt_f0 + 1; |
|
69 | 69 | if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){ |
|
70 | 70 | if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
71 |
printf("In s |
|
|
71 | printf("In smiq_task *** Error sending event to AVF0\n"); | |
|
72 | 72 | nb_interrupt_f0 = 0; |
|
73 | 73 | } |
|
74 | 74 | gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010; |
|
75 | 75 | } |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | rtems_task spw_bppr_task(rtems_task_argument argument) |
|
79 | 79 | { |
|
80 | 80 | rtems_status_code status; |
|
81 | 81 | rtems_event_set event_out; |
|
82 | 82 | static int nb_average_f0 = 0; |
|
83 | 83 | //static int nb_average_f1 = 0; |
|
84 | 84 | //static int nb_average_f2 = 0; |
|
85 | 85 | |
|
86 | 86 | while(1) |
|
87 | 87 | |
|
88 | 88 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; |
|
89 | 89 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; |
|
90 | 90 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; |
|
91 | 91 | |
|
92 | 92 | printf("In BPPR ***\n"); |
|
93 | 93 | |
|
94 | 94 | while(1){ // wait for an event to begin with the processing |
|
95 | 95 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); |
|
96 | 96 | if (status == RTEMS_SUCCESSFUL){ |
|
97 | 97 | if ((spectral_matrices_regs->ctrl & 0x00000001)==1){ |
|
98 | 98 | matrix_average(spec_mat_f0_a, averaged_spec_mat_f0); |
|
99 | 99 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; |
|
100 | 100 | //printf("f0_a\n"); |
|
101 | 101 | nb_average_f0++; |
|
102 | 102 | } |
|
103 | 103 | if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){ |
|
104 | 104 | matrix_average(spec_mat_f0_b, compressed_spec_mat_f0); |
|
105 | 105 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd; |
|
106 | 106 | //printf("f0_b\n"); |
|
107 | 107 | nb_average_f0++; |
|
108 | 108 | } |
|
109 | 109 | if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){ |
|
110 | 110 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); |
|
111 | 111 | //printf("f0 compressed\n"); |
|
112 | 112 | nb_average_f0 = 0; |
|
113 | 113 | matrix_reset(averaged_spec_mat_f0); |
|
114 | 114 | } |
|
115 | 115 | } |
|
116 | 116 | } |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | void matrix_average(volatile int *spec_mat, float *averaged_spec_mat) |
|
120 | 120 | { |
|
121 | 121 | int i; |
|
122 | 122 | for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){ |
|
123 | 123 | averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i] |
|
124 | 124 | + spec_mat_f0_b[i] |
|
125 | 125 | + spec_mat_f0_c[i] |
|
126 | 126 | + spec_mat_f0_d[i] |
|
127 | 127 | + spec_mat_f0_e[i] |
|
128 | 128 | + spec_mat_f0_f[i] |
|
129 | 129 | + spec_mat_f0_g[i] |
|
130 | 130 | + spec_mat_f0_h[i]; |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | void matrix_reset(float *averaged_spec_mat) |
|
135 | 135 | { |
|
136 | 136 | int i; |
|
137 | 137 | for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){ |
|
138 | 138 | averaged_spec_mat_f0[i] = 0; |
|
139 | 139 | } |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) |
|
143 | 143 | { |
|
144 | 144 | int i, j; |
|
145 | 145 | switch (fChannel){ |
|
146 | 146 | case 0: |
|
147 | 147 | for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){ |
|
148 | 148 | j = 17 + i * 8; |
|
149 | 149 | compressed_spec_mat[i] = (averaged_spec_mat[j] |
|
150 | 150 | + averaged_spec_mat[j+1] |
|
151 | 151 | + averaged_spec_mat[j+2] |
|
152 | 152 | + averaged_spec_mat[j+3] |
|
153 | 153 | + averaged_spec_mat[j+4] |
|
154 | 154 | + averaged_spec_mat[j+5] |
|
155 | 155 | + averaged_spec_mat[j+6] |
|
156 | 156 | + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0); |
|
157 | 157 | } |
|
158 | 158 | break; |
|
159 | 159 | case 1: |
|
160 | 160 | // case fChannel = f1 tp be completed later |
|
161 | 161 | break; |
|
162 | 162 | case 2: |
|
163 | 163 | // case fChannel = f1 tp be completed later |
|
164 | 164 | break; |
|
165 | 165 | default: |
|
166 | 166 | break; |
|
167 | 167 | } |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ |
|
171 | 171 | int i, j; |
|
172 | 172 | unsigned char tmp_u_char; |
|
173 | 173 | unsigned char * pt_char; |
|
174 | 174 | float PSDB, PSDE; |
|
175 | 175 | float NVEC_V0, NVEC_V1, NVEC_V2; |
|
176 | 176 | float significand; |
|
177 | 177 | int exponent; |
|
178 | 178 | float aux, tr_SB_SB, tmp; |
|
179 | 179 | float e_cross_b_re, e_cross_b_im; |
|
180 | 180 | float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0; |
|
181 | 181 | float nx = 0, ny = 0; |
|
182 | 182 | float bz_bz_star = 0; |
|
183 | 183 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ |
|
184 | 184 | //============================================== |
|
185 | 185 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits |
|
186 | 186 | PSDB = compressed_spec_mat[i*30] // S11 |
|
187 | 187 | + compressed_spec_mat[i*30+10] // S22 |
|
188 | 188 | + compressed_spec_mat[i*30+18]; // S33 |
|
189 | 189 | significand = frexp(PSDB, &exponent); |
|
190 | 190 | pt_char = (unsigned char*) &PSDB; |
|
191 | 191 | LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float |
|
192 | 192 | LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float |
|
193 | 193 | //============================================== |
|
194 | 194 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits |
|
195 | 195 | PSDE = compressed_spec_mat[i*30+24] * k44 // S44 |
|
196 | 196 | + compressed_spec_mat[i*30+28] * k55 // S55 |
|
197 | 197 | + compressed_spec_mat[i*30+26] * k45_re // S45 |
|
198 | 198 | - compressed_spec_mat[i*30+27] * k45_im; // S45 |
|
199 | 199 | pt_char = (unsigned char*) &PSDE; |
|
200 | 200 | LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float |
|
201 | 201 | LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float |
|
202 | 202 | //============================================================================== |
|
203 | 203 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits |
|
204 | 204 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits |
|
205 | 205 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits |
|
206 | 206 | tmp = sqrt( |
|
207 | 207 | compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12 |
|
208 | 208 | +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13 |
|
209 | 209 | +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23 |
|
210 | 210 | ); |
|
211 | 211 | NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23 |
|
212 | 212 | NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13 |
|
213 | 213 | NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12 |
|
214 | 214 | LFR_BP1[i*9+4] = (char) (NVEC_V0*256); |
|
215 | 215 | LFR_BP1[i*9+3] = (char) (NVEC_V1*256); |
|
216 | 216 | pt_char = (unsigned char*) &NVEC_V2; |
|
217 | 217 | LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 |
|
218 | 218 | //======================================================= |
|
219 | 219 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits |
|
220 | 220 | aux = 2*tmp / PSDB; // compute the ellipticity |
|
221 | 221 | tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity |
|
222 | 222 | LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char |
|
223 | 223 | //============================================================== |
|
224 | 224 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits |
|
225 | 225 | for(j = 0; j<NB_VALUES_PER_spec_mat;j++){ |
|
226 | 226 | tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30] |
|
227 | 227 | + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10] |
|
228 | 228 | + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18] |
|
229 | 229 | + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2] |
|
230 | 230 | + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] |
|
231 | 231 | + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4] |
|
232 | 232 | + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] |
|
233 | 233 | + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12] |
|
234 | 234 | + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13]; |
|
235 | 235 | } |
|
236 | 236 | aux = PSDB*PSDB; |
|
237 | 237 | tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); |
|
238 | 238 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); |
|
239 | 239 | LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char |
|
240 | 240 | //======================================================================================= |
|
241 | 241 | // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) |
|
242 | 242 | e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re |
|
243 | 243 | + compressed_spec_mat[i*30+6]*k14_re |
|
244 | 244 | + compressed_spec_mat[i*30+8]*k15_re |
|
245 | 245 | + compressed_spec_mat[i*30+14]*k24_re |
|
246 | 246 | + compressed_spec_mat[i*30+16]*k25_re; |
|
247 | 247 | e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im |
|
248 | 248 | + compressed_spec_mat[i*30+7]*k14_im |
|
249 | 249 | + compressed_spec_mat[i*30+9]*k15_im |
|
250 | 250 | + compressed_spec_mat[i*30+15]*k24_im |
|
251 | 251 | + compressed_spec_mat[i*30+17]*k25_im; |
|
252 | 252 | tmp = e_cross_b_re / PSDE; // compute ReaSz |
|
253 | 253 | LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive? |
|
254 | 254 | tmp = e_cross_b_re * e_cross_b_im; |
|
255 | 255 | pt_char = (unsigned char*) &tmp; |
|
256 | 256 | LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz |
|
257 | 257 | //====================================================================== |
|
258 | 258 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) |
|
259 | 259 | nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1; |
|
260 | 260 | ny = NVEC_V2; |
|
261 | 261 | bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11 |
|
262 | 262 | + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22 |
|
263 | 263 | - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12 |
|
264 | 264 | n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re |
|
265 | 265 | +compressed_spec_mat[i*30+6]*k14_bis_re |
|
266 | 266 | +compressed_spec_mat[i*30+16]*k25_bis_re |
|
267 | 267 | +compressed_spec_mat[i*30+14]*k24_bis_re) |
|
268 | 268 | + ny * (compressed_spec_mat[i*30+6]*k14_tris_re |
|
269 | 269 | +compressed_spec_mat[i*30+14]*k24_tris_re); |
|
270 | 270 | n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im |
|
271 | 271 | +compressed_spec_mat[i*30+6]*k14_bis_im |
|
272 | 272 | +compressed_spec_mat[i*30+16]*k25_bis_im |
|
273 | 273 | +compressed_spec_mat[i*30+14]*k24_bis_im) |
|
274 | 274 | + ny * (compressed_spec_mat[i*30+6]*k14_tris_im |
|
275 | 275 | +compressed_spec_mat[i*30+14]*k24_tris_im); |
|
276 | 276 | tmp = n_cross_e_scal_b_re / bz_bz_star; |
|
277 | 277 | LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive? |
|
278 | 278 | tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im; |
|
279 | 279 | pt_char = (unsigned char*) &tmp; |
|
280 | 280 | LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV |
|
281 | 281 | } |
|
282 | 282 | |
|
283 | 283 | } |
|
284 | 284 | |
|
285 | 285 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ |
|
286 | 286 | // BP2 autocorrelation |
|
287 | 287 | int i, aux = 0; |
|
288 | 288 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ |
|
289 | 289 | // S12 |
|
290 | 290 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]); |
|
291 | 291 | compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux; |
|
292 | 292 | compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux; |
|
293 | 293 | // S13 |
|
294 | 294 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]); |
|
295 | 295 | compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux; |
|
296 | 296 | compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux; |
|
297 | 297 | // S23 |
|
298 | 298 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]); |
|
299 | 299 | compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux; |
|
300 | 300 | compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux; |
|
301 | 301 | // S45 |
|
302 | 302 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]); |
|
303 | 303 | compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux; |
|
304 | 304 | compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux; |
|
305 | 305 | // S14 |
|
306 | 306 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]); |
|
307 | 307 | compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux; |
|
308 | 308 | compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux; |
|
309 | 309 | // S15 |
|
310 | 310 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]); |
|
311 | 311 | compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux; |
|
312 | 312 | compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux; |
|
313 | 313 | // S24 |
|
314 | 314 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]); |
|
315 | 315 | compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux; |
|
316 | 316 | compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux; |
|
317 | 317 | // S25 |
|
318 | 318 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]); |
|
319 | 319 | compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux; |
|
320 | 320 | compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux; |
|
321 | 321 | // S34 |
|
322 | 322 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]); |
|
323 | 323 | compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux; |
|
324 | 324 | compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux; |
|
325 | 325 | // S35 |
|
326 | 326 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]); |
|
327 | 327 | compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux; |
|
328 | 328 | compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux; |
|
329 | 329 | } |
|
330 | 330 | } |
|
331 | 331 | |
|
332 |
rtems_task |
|
|
332 | rtems_task avf0_task(rtems_task_argument argument){ | |
|
333 | 333 | int i; |
|
334 | 334 | static int nb_average; |
|
335 | 335 | rtems_event_set event_out; |
|
336 | 336 | rtems_status_code status; |
|
337 | 337 | |
|
338 | 338 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; |
|
339 | 339 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; |
|
340 | 340 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; |
|
341 | 341 | |
|
342 | 342 | nb_average = 0; |
|
343 | 343 | |
|
344 | 344 | PRINTF("In AVFO *** \n") |
|
345 | 345 | |
|
346 | 346 | while(1){ |
|
347 | 347 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
348 | 348 | for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){ |
|
349 | 349 | averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i] |
|
350 | 350 | + spec_mat_f0_b[i] |
|
351 | 351 | + spec_mat_f0_c[i] |
|
352 | 352 | + spec_mat_f0_d[i] |
|
353 | 353 | + spec_mat_f0_e[i] |
|
354 | 354 | + spec_mat_f0_f[i] |
|
355 | 355 | + spec_mat_f0_g[i] |
|
356 | 356 | + spec_mat_f0_h[i]; |
|
357 | 357 | } |
|
358 | 358 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register |
|
359 | 359 | nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0; |
|
360 | 360 | if (nb_average == NB_AVERAGE_NORMAL_f0) { |
|
361 | 361 | nb_average = 0; |
|
362 | 362 | status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 |
|
363 | 363 | if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); |
|
364 | 364 | } |
|
365 | 365 | } |
|
366 | 366 | } |
|
367 | 367 | |
|
368 |
rtems_task |
|
|
368 | rtems_task bpf0_task(rtems_task_argument argument){ | |
|
369 | 369 | rtems_event_set event_out; |
|
370 | 370 | |
|
371 | 371 | while(1){ |
|
372 | 372 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
373 | 373 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); |
|
374 | 374 | BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0); |
|
375 | 375 | //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n") |
|
376 | 376 | } |
|
377 | 377 | } |
|
378 | 378 | |
|
379 | 379 | //******* |
|
380 | 380 | // UNUSED |
|
381 | 381 | rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument) |
|
382 | 382 | {/* |
|
383 | 383 | rtems_status_code status; |
|
384 | 384 | //static int nb_average_f1 = 0; |
|
385 | 385 | //static int nb_average_f2 = 0; |
|
386 | 386 | |
|
387 | 387 | rtems_name name; |
|
388 | 388 | rtems_id period; |
|
389 | 389 | name = rtems_build_name( 'P', 'E', 'R', 'D' ); |
|
390 | 390 | status = rtems_rate_monotonic_create( name, &period ); |
|
391 | 391 | if( status != RTEMS_SUCCESSFUL ) { |
|
392 | 392 | printf( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
393 | 393 | //exit( 1 ); |
|
394 | 394 | } |
|
395 | 395 | |
|
396 | 396 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; |
|
397 | 397 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; |
|
398 | 398 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; |
|
399 | 399 | |
|
400 | 400 | printf("In BPPR BIS ***\n"); |
|
401 | 401 | |
|
402 | 402 | while(1){ // launch the rate monotonic task |
|
403 | 403 | if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){ |
|
404 | 404 | printf("TIMEOUT\n"); |
|
405 | 405 | //break; |
|
406 | 406 | } |
|
407 | 407 | status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0 |
|
408 | 408 | if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status); |
|
409 | 409 | } |
|
410 | 410 | |
|
411 | 411 | status = rtems_rate_monotonic_delete( period ); |
|
412 | 412 | if ( status != RTEMS_SUCCESSFUL ) { |
|
413 | 413 | printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status ); |
|
414 | 414 | //exit( 1 ); |
|
415 | 415 | } |
|
416 | 416 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
417 | 417 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
418 | 418 | //exit( 1 );*/ |
|
419 | 419 | } |
|
420 | 420 | |
|
421 | 421 | |
|
422 | 422 | |
|
423 | 423 |
@@ -1,331 +1,396 | |||
|
1 | 1 | #include <tc_handler.h> |
|
2 | 2 | #include <fsw_params.h> |
|
3 | 3 | |
|
4 | 4 | char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0", |
|
5 | 5 | "WRONG_LEN_PACKET 1", |
|
6 | 6 | "INCOR_CHECKSUM 2", |
|
7 | 7 | "ILL_TYPE 3", |
|
8 | 8 | "ILL_SUBTYPE 4", |
|
9 | 9 | "WRONG_APP_DATA 5", |
|
10 | 10 | "WRONG_CMD_CODE 6", |
|
11 | 11 | "CCSDS_TM_VALID 7" |
|
12 | 12 | }; |
|
13 | 13 | |
|
14 | 14 | //********************** |
|
15 | 15 | // GENERAL USE FUNCTIONS |
|
16 | 16 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) |
|
17 | 17 | { |
|
18 | 18 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | void InitLookUpTableForCRC() |
|
22 | 22 | { |
|
23 | 23 | unsigned int i, tmp; |
|
24 | 24 | for (i=0; i<256; i++) |
|
25 | 25 | { |
|
26 | 26 | tmp = 0; |
|
27 | 27 | if((i & 1) != 0) tmp = tmp ^ 0x1021; |
|
28 | 28 | if((i & 2) != 0) tmp = tmp ^ 0x2042; |
|
29 | 29 | if((i & 4) != 0) tmp = tmp ^ 0x4084; |
|
30 | 30 | if((i & 8) != 0) tmp = tmp ^ 0x8108; |
|
31 | 31 | if((i & 16) != 0) tmp = tmp ^ 0x1231; |
|
32 | 32 | if((i & 32) != 0) tmp = tmp ^ 0x2462; |
|
33 | 33 | if((i & 64) != 0) tmp = tmp ^ 0x48c4; |
|
34 | 34 | if((i & 128) != 0) tmp = tmp ^ 0x9188; |
|
35 | 35 | lookUpTableForCRC[i] = tmp; |
|
36 | 36 | } |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) |
|
40 | 40 | { |
|
41 | 41 | unsigned int Chk; |
|
42 | 42 | int j; |
|
43 | 43 | Chk = 0xffff; // reset the syndrom to all ones |
|
44 | 44 | for (j=0; j<sizeOfData; j++) { |
|
45 | 45 | Chk = Crc_opt(data[j], Chk); |
|
46 | 46 | } |
|
47 | 47 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); |
|
48 | 48 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | |
|
52 | 52 | //********************* |
|
53 | 53 | // ACCEPTANCE FUNCTIONS |
|
54 |
|
|
|
55 | TMHeader_t *TM_Header, unsigned int *hlen, char *data) | |
|
54 | int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv) | |
|
56 | 55 | { |
|
56 | rtems_status_code status; | |
|
57 | spw_ioctl_pkt_send spw_ioctl_send; | |
|
58 | TMHeader_t TM_header; | |
|
57 | 59 | unsigned int code = 0; |
|
58 | unsigned int data_length = 0; | |
|
59 | 60 | unsigned char computed_CRC[2]; |
|
60 | unsigned char subtype = 0; | |
|
61 | char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ]; | |
|
61 | 62 | |
|
62 | subtype = TC->dataFieldHeader[2]; | |
|
63 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, TC_LEN_RCV + 5 ); | |
|
64 | code = acceptTM( TC, TC_LEN_RCV ) ; | |
|
65 | //PRINTF1("in TC_checker *** %s\n", errorCCSDSMsg[code]); | |
|
63 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 ); | |
|
64 | code = acceptTM( TC, tc_len_recv ) ; | |
|
66 | 65 | if ( (code == 0) | (code == 1) | (code == 2) |
|
67 | 66 | | (code == 3) | (code == 4) | (code == 5) ) |
|
68 | 67 | { // generate TM_LFR_TC_EXE_CORRUPTED |
|
69 | 68 | // BUILD HEADER |
|
70 |
TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, |
|
|
69 | TM_build_header( TM_LFR_TC_EXE_ERR, SID_EXE_CORR, TM_LEN_EXE_CORR, 0, 0, &TM_header); | |
|
71 | 70 | // BUILD DATA |
|
72 | 71 | TM_build_data( TC, data, SID_EXE_CORR, computed_CRC); |
|
73 | data_length = TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |
|
74 | } | |
|
75 | if (subtype == SID_TC_UPDT_TIME){ | |
|
76 | // BUILD HEADER | |
|
77 | TM_build_header( TM_LFR_TC_EXE_OK, SID_DEFAULT, TM_LEN_EXE, 0, 0, TM_Header); | |
|
78 |
// |
|
|
79 | TM_build_data( TC, data, SID_DEFAULT, computed_CRC); | |
|
80 | data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |
|
72 | // PREPARE TM SENDING | |
|
73 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra 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; | |
|
76 | spw_ioctl_send.data = data; | |
|
77 | // SEND PACKET | |
|
78 | write_spw(&spw_ioctl_send); | |
|
81 | 79 | } |
|
82 | 80 | else { // TM_LFR_TC_EXE_NOT_IMPLEMENTED |
|
83 | // BUILD HEADER | |
|
84 | TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, TM_Header); | |
|
85 | // BUILD DATA | |
|
86 | TM_build_data( TC, data, SID_NOT_IMP, computed_CRC); | |
|
87 | data_length = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |
|
81 | status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET); | |
|
82 | return -1; | |
|
88 | 83 | } |
|
89 | ||
|
90 | return data_length; | |
|
84 | return -1; | |
|
91 | 85 | } |
|
92 | 86 | |
|
93 | 87 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV) |
|
94 | 88 | { |
|
95 | 89 | unsigned char pid = 0; |
|
96 | 90 | unsigned char category = 0; |
|
97 | 91 | unsigned int length = 0; |
|
98 | 92 | unsigned char packetType = 0; |
|
99 | 93 | unsigned char packetSubtype = 0; |
|
100 | 94 | unsigned char * CCSDSContent; |
|
101 | 95 | |
|
102 | 96 | // APID check *** APID on 2 bytes |
|
103 | 97 | pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx |
|
104 | 98 | category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 |
|
105 | 99 | if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID; |
|
106 | 100 | if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID; |
|
107 | 101 | |
|
108 | 102 | // packet length check |
|
109 | 103 | length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1]; |
|
110 | 104 | if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD |
|
111 | 105 | if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size |
|
112 | 106 | |
|
113 | 107 | packetType = TMPacket->dataFieldHeader[1]; |
|
114 | 108 | packetSubtype = TMPacket->dataFieldHeader[2]; |
|
115 | 109 | // service type, subtype and packet length check |
|
116 | 110 | if (packetType == 181){ |
|
117 | 111 | switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61 |
|
118 | 112 | case 3: |
|
119 | 113 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
120 | 114 | break; |
|
121 | 115 | case 20: |
|
122 | 116 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
123 | 117 | break; |
|
124 | 118 | case 21: |
|
125 | 119 | if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
126 | 120 | break; |
|
127 | 121 | case 24: |
|
128 | 122 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
129 | 123 | break; |
|
130 | 124 | case 27: |
|
131 | 125 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
132 | 126 | break; |
|
133 | 127 | case 28: |
|
134 | 128 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
135 | 129 | break; |
|
136 | 130 | case 30: |
|
137 | 131 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
138 | 132 | break; |
|
139 | 133 | case 40: |
|
140 | 134 | if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
141 | 135 | break; |
|
142 | 136 | case 50: |
|
143 | 137 | if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
144 | 138 | break; |
|
145 | 139 | case 60: |
|
146 | 140 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
147 | 141 | break; |
|
148 | 142 | case 61: |
|
149 | 143 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
150 | 144 | break; |
|
151 | 145 | default: |
|
152 | 146 | return ILL_SUBTYPE; |
|
153 | 147 | break; |
|
154 | 148 | } |
|
155 | 149 | } |
|
156 | 150 | else if (packetType == 9){ |
|
157 | 151 | if (packetSubtype!=129) return ILL_SUBTYPE; |
|
158 | 152 | if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
159 | 153 | } |
|
160 | 154 | else return ILL_TYPE; |
|
161 | 155 | |
|
162 | 156 | // source ID check // Source ID not documented in the ICD |
|
163 | 157 | |
|
164 | 158 | // packet error control, CRC check |
|
165 | 159 | CCSDSContent = (unsigned char*) TMPacket->packetID; |
|
166 | 160 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC |
|
167 | 161 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM; |
|
168 | 162 | if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM; |
|
169 | 163 | |
|
170 | 164 | return CCSDS_TM_VALID; |
|
171 | 165 | } |
|
172 | 166 | |
|
173 | 167 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int SID, unsigned int packetLength, |
|
174 | 168 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader) |
|
175 | 169 | { |
|
176 | 170 | TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
177 | 171 | TMHeader->protocolIdentifier = 0x02; |
|
178 | 172 | TMHeader->reserved = 0x00; |
|
179 | 173 | TMHeader->userApplication = 0x00; |
|
180 | 174 | TMHeader->packetID[0] = 0x0c; |
|
181 | 175 | TMHeader->packetSequenceControl[0] = 0xc0; |
|
182 | 176 | TMHeader->packetSequenceControl[1] = 0x00; |
|
183 | 177 | TMHeader->packetLength[0] = (unsigned char) (packetLength>>8); |
|
184 | 178 | TMHeader->packetLength[1] = (unsigned char) packetLength; |
|
185 | 179 | TMHeader->dataFieldHeader[0] = 0x10; |
|
186 | 180 | TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID; |
|
187 | 181 | switch (tm_type){ |
|
188 | 182 | case(TM_LFR_TC_EXE_OK): |
|
189 | 183 | TMHeader->packetID[1] = 0xc1; |
|
190 | 184 | TMHeader->dataFieldHeader[1] = 1; // type |
|
191 | 185 | TMHeader->dataFieldHeader[2] = 7; // subtype |
|
192 | 186 | break; |
|
193 | 187 | case(TM_LFR_TC_EXE_ERR): |
|
194 | 188 | TMHeader->packetID[1] = 0xc1; |
|
195 | 189 | TMHeader->dataFieldHeader[1] = 1; // type |
|
196 | 190 | TMHeader->dataFieldHeader[2] = 8; // subtype |
|
197 | 191 | break; |
|
198 | 192 | case(TM_LFR_HK): |
|
199 | 193 | TMHeader->packetID[1] = 0xc4; |
|
200 | 194 | TMHeader->dataFieldHeader[1] = 3; // type |
|
201 | 195 | TMHeader->dataFieldHeader[2] = 25; // subtype |
|
202 | 196 | break; |
|
203 | 197 | case(TM_LFR_SCI): |
|
204 | 198 | TMHeader->packetID[1] = 0xcc; |
|
205 | 199 | TMHeader->dataFieldHeader[1] = 21; // type |
|
206 | 200 | TMHeader->dataFieldHeader[2] = 3; // subtype |
|
207 | 201 | break; |
|
208 | 202 | case(TM_LFR_SCI_SBM): |
|
209 | 203 | TMHeader->packetID[1] = 0xfc; |
|
210 | 204 | TMHeader->dataFieldHeader[1] = 21; // type |
|
211 | 205 | TMHeader->dataFieldHeader[2] = 3; // subtype |
|
212 | 206 | break; |
|
213 | 207 | case(TM_LFR_PAR_DUMP): |
|
214 | 208 | TMHeader->packetID[1] = 0xc9; |
|
215 | 209 | TMHeader->dataFieldHeader[1] = 181; // type |
|
216 | 210 | TMHeader->dataFieldHeader[2] = 31; // subtype |
|
217 | 211 | break; |
|
218 | 212 | default: |
|
219 | 213 | return 0; |
|
220 | 214 | } |
|
221 | 215 | /*TMHeader->dataFieldHeader[4] = (unsigned char) (coarseTime>>24); |
|
222 | 216 | TMHeader->dataFieldHeader[5] = (unsigned char) (coarseTime>>16); |
|
223 | 217 | TMHeader->dataFieldHeader[6] = (unsigned char) (coarseTime>>8); |
|
224 | 218 | TMHeader->dataFieldHeader[7] = (unsigned char) (coarseTime); |
|
225 | 219 | TMHeader->dataFieldHeader[8] = (unsigned char) (fineTime>>8); |
|
226 | 220 | TMHeader->dataFieldHeader[9] = (unsigned char) (fineTime);*/ |
|
227 | 221 | TMHeader->dataFieldHeader[4] = 0xaa; |
|
228 | 222 | TMHeader->dataFieldHeader[5] = 0xbb; |
|
229 | 223 | TMHeader->dataFieldHeader[6] = 0xcc; |
|
230 | 224 | TMHeader->dataFieldHeader[7] = 0xdd; |
|
231 | 225 | TMHeader->dataFieldHeader[8] = 0xee; |
|
232 | 226 | TMHeader->dataFieldHeader[9] = 0xff; |
|
233 | 227 | return 1; |
|
234 | 228 | } |
|
235 | 229 | |
|
236 | 230 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC) |
|
237 | 231 | { |
|
238 | 232 | unsigned int packetLength; |
|
239 | 233 | packetLength = TC->packetLength[0] * 256 + TC->packetLength[1]; |
|
240 | 234 | switch (SID){ |
|
241 | 235 | case (SID_NOT_EXE): |
|
242 | 236 | break; |
|
243 | 237 | case (SID_NOT_IMP): |
|
244 | 238 | data[0] = 0x9c; |
|
245 | 239 | data[1] = 0x42; |
|
246 | 240 | data[2] = TC->packetID[0]; |
|
247 | 241 | data[3] = TC->packetID[1]; |
|
248 | 242 | data[4] = TC->packetSequenceControl[0]; |
|
249 | 243 | data[5] = TC->packetSequenceControl[1]; |
|
250 | 244 | data[6] = TC->dataFieldHeader[1]; // type |
|
251 | 245 | data[7] = TC->dataFieldHeader[2]; // subtype |
|
252 | 246 | break; |
|
253 | 247 | case (SID_EXE_ERR): |
|
254 | 248 | break; |
|
255 | 249 | case (SID_EXE_CORR): |
|
256 | 250 | data[0] = 0x9c; |
|
257 | 251 | data[1] = 0x45; |
|
258 | 252 | data[2] = TC->packetID[0]; |
|
259 | 253 | data[3] = TC->packetID[1]; |
|
260 | 254 | data[4] = TC->packetSequenceControl[0]; |
|
261 | 255 | data[5] = TC->packetSequenceControl[1]; |
|
262 | 256 | data[6] = TC->dataFieldHeader[1]; // type |
|
263 | 257 | data[7] = TC->dataFieldHeader[2]; // subtype |
|
264 | 258 | data[8] = currentTC_LEN_RCV[0]; |
|
265 | 259 | data[9] = currentTC_LEN_RCV[1]; |
|
266 | 260 | data[10] = TC->packetLength[0]; |
|
267 | 261 | data[11] = TC->packetLength[1]; |
|
268 | 262 | data[12] = TC->dataAndCRC[packetLength]; |
|
269 | 263 | data[13] = TC->dataAndCRC[packetLength+1]; |
|
270 | 264 | data[14] = computed_CRC[0]; |
|
271 | 265 | data[15] = computed_CRC[1]; |
|
272 | 266 | break; |
|
273 | 267 | default: |
|
274 | 268 | return 0; |
|
275 | 269 | } |
|
276 | 270 | return 1; |
|
277 | 271 | } |
|
278 | 272 | |
|
279 | unsigned char actionLauncher(unsigned int sid) | |
|
280 | { | |
|
281 | return 0; | |
|
282 | } | |
|
283 | ||
|
284 | 273 | //*********** |
|
285 | 274 | // RTEMS TASK |
|
286 |
rtems_task |
|
|
275 | rtems_task recv_task( rtems_task_argument unused ) | |
|
287 | 276 | { |
|
288 | rtems_status_code status; | |
|
289 | 277 | int len = 0; |
|
290 | 278 | unsigned int i = 0; |
|
291 | 279 | unsigned int data_length = 0; |
|
292 | 280 | ccsdsTelecommandPacket_t currentTC; |
|
293 | spw_ioctl_pkt_send spw_ioctl_send; | |
|
294 | TMHeader_t TM_header; | |
|
295 | 281 | char data[100]; |
|
296 | 282 | |
|
297 | 283 | for(i=0; i<100; i++) data[i] = 0; |
|
298 | 284 | |
|
299 | 285 | PRINTF("In RECV *** \n") |
|
300 | 286 | |
|
301 |
while(1) |
|
|
287 | while(1) | |
|
288 | { | |
|
302 | 289 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking |
|
303 | 290 | if (len == -1){ // error during the read call |
|
304 | 291 | PRINTF("In RECV *** last read call returned -1\n") |
|
305 | 292 | if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) |
|
306 | 293 | PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n") |
|
307 | 294 | if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) |
|
308 | 295 | PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n") |
|
309 | 296 | } |
|
310 | 297 | else { |
|
311 | 298 | //PRINTF1("In RECV *** Got Message of length %d\n", len) |
|
312 | 299 | currentTC_LEN_RCV[0] = 0x00; |
|
313 | 300 | currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field |
|
314 | 301 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes |
|
315 | 302 | // CHECK THE TC AND BUILD THE APPROPRIATE TM |
|
316 |
data_length = TC_checker(¤tTC, currentTC_LEN_RCV_AsUnsignedInt |
|
|
317 | &TM_header, &spw_ioctl_send.hlen, data); | |
|
318 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | |
|
319 | spw_ioctl_send.hdr = (char*) &TM_header; | |
|
320 | spw_ioctl_send.dlen = data_length; | |
|
321 | spw_ioctl_send.data = data; | |
|
322 | //printf("hlen %d, dlen %d\n", spw_ioctl_send.hlen, spw_ioctl_send.dlen); | |
|
323 | // SEND PACKET | |
|
324 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send ); | |
|
325 | if (status!=RTEMS_SUCCESSFUL) printf("In TC_checker *** Error SPACEWIRE_IOCTRL_SEND\n"); | |
|
326 | //PRINTF1("In TC_checker *** packet of size %d sent\n", spw_ioctl_send.sent) | |
|
303 | data_length = TC_checker(¤tTC, currentTC_LEN_RCV_AsUnsignedInt); | |
|
304 | if (data_length!=-1) | |
|
305 | { | |
|
306 | } | |
|
327 | 307 | } |
|
328 | 308 | } |
|
329 | 309 | } |
|
330 | 310 | |
|
311 | rtems_task actn_task( rtems_task_argument unused ) | |
|
312 | { | |
|
313 | rtems_status_code status; // RTEMS status code | |
|
314 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | |
|
315 | size_t size; // size of the incoming TC packet | |
|
316 | unsigned char subtype = 0; // subtype of the current TC packet | |
|
331 | 317 | |
|
318 | while(1) | |
|
319 | { | |
|
320 | status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size, | |
|
321 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
|
322 | if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status) | |
|
323 | else | |
|
324 | { | |
|
325 | subtype = TC.dataFieldHeader[2]; | |
|
326 | switch(subtype) | |
|
327 | { | |
|
328 | case TC_SUBTYPE_RESET: | |
|
329 | break; | |
|
330 | case TC_SUBTYPE_LOAD_COMM: | |
|
331 | break; | |
|
332 | case TC_SUBTYPE_LOAD_NORM: | |
|
333 | break; | |
|
334 | case TC_SUBTYPE_LOAD_BURST: | |
|
335 | break; | |
|
336 | case TC_SUBTYPE_LOAD_SBM1: | |
|
337 | break; | |
|
338 | case TC_SUBTYPE_LOAD_SBM2: | |
|
339 | break; | |
|
340 | case TC_SUBTYPE_DUMP: | |
|
341 | default_action( &TC ); | |
|
342 | break; | |
|
343 | case TC_SUBTYPE_ENTER: | |
|
344 | break; | |
|
345 | case TC_SUBTYPE_UPDT_INFO: | |
|
346 | break; | |
|
347 | case TC_SUBTYPE_EN_CAL: | |
|
348 | break; | |
|
349 | case TC_SUBTYPE_DIS_CAL: | |
|
350 | break; | |
|
351 | case TC_SUBTYPE_UPDT_TIME: | |
|
352 | break; | |
|
353 | default: | |
|
354 | break; | |
|
355 | } | |
|
356 | } | |
|
357 | } | |
|
358 | } | |
|
359 | ||
|
360 | int create_message_queue() | |
|
361 | { | |
|
362 | rtems_status_code status; | |
|
363 | misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' ); | |
|
364 | status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, | |
|
365 | RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] ); | |
|
366 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n") | |
|
367 | ||
|
368 | return 0; | |
|
369 | } | |
|
370 | ||
|
371 | //*********** | |
|
372 | // TC ACTIONS | |
|
373 | int default_action(ccsdsTelecommandPacket_t *TC) | |
|
374 | { | |
|
375 | char data[100]; // buffer for the generic TM packet | |
|
376 | TMHeader_t TM_header; // TM header | |
|
377 | spw_ioctl_pkt_send spw_ioctl_send; // structure to send the TM packet if any | |
|
378 | // BUILD HEADER | |
|
379 | TM_build_header( TM_LFR_TC_EXE_ERR, SID_NOT_IMP, TM_LEN_NOT_IMP, 0, 0, &TM_header); | |
|
380 | // BUILD DATA | |
|
381 | TM_build_data( TC, data, SID_NOT_IMP, NULL); | |
|
382 | // filling the strture for the spcawire transmission | |
|
383 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header | |
|
384 | spw_ioctl_send.hdr = (char*) &TM_header; | |
|
385 | spw_ioctl_send.dlen = TM_LEN_NOT_IMP + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN; | |
|
386 | spw_ioctl_send.data = data; | |
|
387 | // SEND DATA | |
|
388 | write_spw(&spw_ioctl_send); | |
|
389 | ||
|
390 | return 0; | |
|
391 | } | |
|
392 | ||
|
393 | ||
|
394 | ||
|
395 | ||
|
396 |
@@ -1,113 +1,113 | |||
|
1 | 1 | #include <wf_handler.h> |
|
2 | 2 | |
|
3 | 3 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
4 | 4 | { |
|
5 | 5 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
6 | 6 | printf("In spectral_matrices_isr *** Error sending event to WFRM\n"); |
|
7 | 7 | } |
|
8 | 8 | |
|
9 |
rtems_task |
|
|
9 | rtems_task wfrm_task(rtems_task_argument argument) | |
|
10 | 10 | { |
|
11 | 11 | unsigned int length; |
|
12 | 12 | unsigned int i = 0; |
|
13 | 13 | spw_ioctl_pkt_send spw_ioctl_send; |
|
14 | 14 | rtems_event_set event_out; |
|
15 | 15 | gptimer_regs_t *gptimer_regs; |
|
16 | 16 | gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
17 | 17 | ExtendedTMHeader_t header; |
|
18 | 18 | |
|
19 | 19 | header.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
20 | 20 | header.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
21 | 21 | header.reserved = 0x00; |
|
22 | 22 | header.userApplication = CCSDS_USER_APP; |
|
23 | 23 | header.packetID[0] = 0x0c; |
|
24 | 24 | header.packetID[1] = 0xcc; |
|
25 | 25 | header.packetSequenceControl[0] = 0x00; |
|
26 | 26 | header.packetSequenceControl[1] = 0x00; |
|
27 | 27 | header.packetLength[0] = 0x00; |
|
28 | 28 | header.packetLength[1] = 0x00; |
|
29 | 29 | header.dataFieldHeader[0] = 0x10; |
|
30 | 30 | header.dataFieldHeader[1] = 0x15; // service type |
|
31 | 31 | header.dataFieldHeader[2] = 0x03; // service subtype |
|
32 | 32 | header.dataFieldHeader[3] = CCSDS_DESTINATION_ID; |
|
33 | 33 | header.dataFieldHeader[4] = 0xaa; |
|
34 | 34 | header.dataFieldHeader[5] = 0xbb; |
|
35 | 35 | header.dataFieldHeader[6] = 0xcc; |
|
36 | 36 | header.dataFieldHeader[7] = 0xdd; |
|
37 | 37 | header.dataFieldHeader[8] = 0xee; |
|
38 | 38 | header.dataFieldHeader[9] = 0xff; |
|
39 | 39 | |
|
40 | 40 | header.auxiliaryHeader[0] = 0x00; |
|
41 | 41 | header.auxiliaryHeader[1] = 0x1f; |
|
42 | 42 | header.auxiliaryHeader[2] = 0x07; // PKT_CNT |
|
43 | 43 | header.auxiliaryHeader[3] = 0x00; // PKT_NR |
|
44 | 44 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB |
|
45 | 45 | header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB |
|
46 | 46 | |
|
47 | 47 | // BUILD THE PACKET HEADER |
|
48 | 48 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header |
|
49 | 49 | spw_ioctl_send.hdr = (char*) &header; |
|
50 | 50 | |
|
51 | 51 | while(1){ |
|
52 | 52 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
53 | 53 | for (i=0; i<7; i++) // send F0 |
|
54 | 54 | { |
|
55 | 55 | // BUILD THE DATA |
|
56 | 56 | if (i==6) { |
|
57 | 57 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; |
|
58 | 58 | length = TM_LEN_SCI_NORM_SWF_340; |
|
59 | 59 | } |
|
60 | 60 | else { |
|
61 | 61 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; |
|
62 | 62 | length = TM_LEN_SCI_NORM_SWF_8; |
|
63 | 63 | } |
|
64 | 64 | spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK]; |
|
65 | 65 | // BUILD THE HEADER |
|
66 | 66 | header.packetLength[0] = (unsigned char) (length>>8); |
|
67 | 67 | header.packetLength[1] = (unsigned char) (length); |
|
68 | 68 | header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID |
|
69 | 69 | // SEND PACKET |
|
70 | 70 | write_spw(&spw_ioctl_send); |
|
71 | 71 | } |
|
72 | 72 | for (i=0; i<7; i++) // send F1 |
|
73 | 73 | { |
|
74 | 74 | // BUILD THE DATA |
|
75 | 75 | if (i==6) { |
|
76 | 76 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; |
|
77 | 77 | length = TM_LEN_SCI_NORM_SWF_340; |
|
78 | 78 | } |
|
79 | 79 | else { |
|
80 | 80 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; |
|
81 | 81 | length = TM_LEN_SCI_NORM_SWF_8; |
|
82 | 82 | } |
|
83 | 83 | spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK]; |
|
84 | 84 | // BUILD THE HEADER |
|
85 | 85 | header.packetLength[0] = (unsigned char) (length>>8); |
|
86 | 86 | header.packetLength[1] = (unsigned char) (length); |
|
87 | 87 | header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID |
|
88 | 88 | // SEND PACKET |
|
89 | 89 | write_spw(&spw_ioctl_send); |
|
90 | 90 | } |
|
91 | 91 | for (i=0; i<7; i++) // send F0 |
|
92 | 92 | { |
|
93 | 93 | // BUILD THE DATA |
|
94 | 94 | if (i==6) { |
|
95 | 95 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; |
|
96 | 96 | length = TM_LEN_SCI_NORM_SWF_340; |
|
97 | 97 | } |
|
98 | 98 | else { |
|
99 | 99 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; |
|
100 | 100 | length = TM_LEN_SCI_NORM_SWF_8; |
|
101 | 101 | } |
|
102 | 102 | spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK]; |
|
103 | 103 | // BUILD THE HEADER |
|
104 | 104 | header.packetLength[0] = (unsigned char) (length>>8); |
|
105 | 105 | header.packetLength[1] = (unsigned char) (length); |
|
106 | 106 | header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID |
|
107 | 107 | // SEND PACKET |
|
108 | 108 | write_spw(&spw_ioctl_send); |
|
109 | 109 | } |
|
110 | 110 | // irq processed, reset the related register of the timer unit |
|
111 | 111 | gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010; |
|
112 | 112 | } |
|
113 | 113 | } |
General Comments 0
You need to be logged in to leave comments.
Login now