##// END OF EJS Templates
Sync...
paul -
r116:4710a866a7d2 VHDLib206
parent child
Show More
@@ -1,339 +1,339
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-03T15:58:50. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-07T06:54:09. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">1</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 118 </valuemap>
119 119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 126 </valuemap>
127 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 131 </valuemap>
132 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 153 <value type="int">0</value>
154 154 <value type="int">1</value>
155 155 <value type="int">2</value>
156 156 <value type="int">3</value>
157 157 <value type="int">4</value>
158 158 <value type="int">5</value>
159 159 <value type="int">6</value>
160 160 <value type="int">7</value>
161 161 <value type="int">8</value>
162 162 <value type="int">9</value>
163 163 <value type="int">10</value>
164 164 <value type="int">11</value>
165 165 <value type="int">12</value>
166 166 <value type="int">13</value>
167 167 <value type="int">14</value>
168 168 </valuelist>
169 169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 180 <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
181 181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
182 182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 187 </valuemap>
188 188 </data>
189 189 <data>
190 190 <variable>ProjectExplorer.Project.Target.1</variable>
191 191 <valuemap type="QVariantMap">
192 192 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
193 193 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
194 194 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
195 195 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
196 196 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
197 197 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
198 198 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
199 199 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
200 200 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
201 201 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
202 202 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
203 203 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
204 204 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
205 205 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
206 206 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
207 207 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
208 208 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
209 209 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
210 210 </valuemap>
211 211 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
212 212 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
213 213 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
214 214 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
215 215 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
216 216 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
217 217 <value type="QString">-w</value>
218 218 <value type="QString">-r</value>
219 219 </valuelist>
220 220 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
221 221 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
222 222 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
223 223 </valuemap>
224 224 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
225 225 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
226 226 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
227 227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
228 228 </valuemap>
229 229 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
230 230 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
231 231 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
232 232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
233 233 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
234 234 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
235 235 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
236 236 <value type="QString">-w</value>
237 237 <value type="QString">-r</value>
238 238 </valuelist>
239 239 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
240 240 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
241 241 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
242 242 </valuemap>
243 243 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
244 244 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
245 245 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
246 246 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
247 247 </valuemap>
248 248 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
249 249 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
250 250 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
251 251 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
252 252 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
253 253 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
254 254 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
255 255 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
256 256 </valuemap>
257 257 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
258 258 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
259 259 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
260 260 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
261 261 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
262 262 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
263 263 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
264 264 </valuemap>
265 265 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
266 266 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
267 267 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
268 268 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
269 269 </valuemap>
270 270 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
271 271 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
272 272 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
273 273 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
274 274 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
275 275 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
276 276 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
277 277 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
278 278 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
279 279 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
280 280 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
281 281 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
282 282 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
283 283 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
284 284 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
285 285 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
286 286 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
287 287 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
288 288 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
289 289 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
290 290 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
291 291 <value type="int">0</value>
292 292 <value type="int">1</value>
293 293 <value type="int">2</value>
294 294 <value type="int">3</value>
295 295 <value type="int">4</value>
296 296 <value type="int">5</value>
297 297 <value type="int">6</value>
298 298 <value type="int">7</value>
299 299 <value type="int">8</value>
300 300 <value type="int">9</value>
301 301 <value type="int">10</value>
302 302 <value type="int">11</value>
303 303 <value type="int">12</value>
304 304 <value type="int">13</value>
305 305 <value type="int">14</value>
306 306 </valuelist>
307 307 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
308 308 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
309 309 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
310 310 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
311 311 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
312 312 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
313 313 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
314 314 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
315 315 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
316 316 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
317 317 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
318 318 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
319 319 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
320 320 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
321 321 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
322 322 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
323 323 </valuemap>
324 324 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
325 325 </valuemap>
326 326 </data>
327 327 <data>
328 328 <variable>ProjectExplorer.Project.TargetCount</variable>
329 329 <value type="int">2</value>
330 330 </data>
331 331 <data>
332 332 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
333 333 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
334 334 </data>
335 335 <data>
336 336 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
337 337 <value type="int">15</value>
338 338 </data>
339 339 </qtcreator>
@@ -1,655 +1,660
1 1 #ifndef CCSDS_TYPES_H_INCLUDED
2 2 #define CCSDS_TYPES_H_INCLUDED
3 3
4 4 #include "fsw_params_processing.h"
5 5
6 6 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
7 #define CCSDS_TC_TM_PACKET_OFFSET 7
7 8 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
8 9 #define CCSDS_TM_PKT_MAX_SIZE 4412
9 10 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
10 11 #define CCSDS_TC_PKT_MAX_SIZE 256
11 12 #define CCSDS_TC_PKT_MIN_SIZE 16
12 #define CCSDS_TC_TM_PACKET_OFFSET 7
13 13 #define CCSDS_PROCESS_ID 76
14 14 #define CCSDS_PACKET_CATEGORY 12
15 15 #define CCSDS_NODE_ADDRESS 0xfe
16 16 #define CCSDS_USER_APP 0x00
17 17
18 18 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
19 19 #define DEFAULT_RESERVED 0x00
20 20 #define DEFAULT_HKBIA 0x1e // 0001 1110
21 21
22 22 // PACKET ID
23 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
24 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
25 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
23 #define APID_TM_TC_EXE 0x0cc1 // PID 76 CAT 1
24 #define APID_TM_HK 0x0cc4 // PID 76 CAT 4
25 #define APID_TM_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
26 #define APID_TM_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
27 #define APID_TM_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
28 28 #define TM_PACKET_PID_DEFAULT 76
29 29 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
30 30 #define TM_PACKET_CAT_TC_EXE 1
31 31 #define TM_PACKET_CAT_HK 4
32 32 #define TM_PACKET_CAT_PARAMETER_DUMP 9
33 33 #define TM_PACKET_CAT_SCIENCE 12
34 34 #define TC_PACKET_CAT 12
35 35
36 36 // PACKET SEQUENCE CONTROL
37 37 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
38 38 #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000]
39 39 #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000]
40 40 #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000]
41 41 #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000]
42 42
43 43 // DESTINATION ID
44 44 #define TM_DESTINATION_ID_GROUND 0
45 45 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
46 46 #define TM_DESTINATION_ID_TC_SEQUENCES 111
47 47 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
48 48 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
49 49 #define TM_DESTINATION_ID_DIRECT_CMD 120
50 50 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
51 51 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
52 52 #define TM_DESTINATION_ID_OBCP 15
53 53 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
54 54 #define TM_DESTINATION_ID_AOCS 11
55 55
56 56 #define CCSDS_DESTINATION_ID 0x01
57 57 #define CCSDS_PROTOCOLE_ID 0x02
58 58 #define CCSDS_RESERVED 0x00
59 59 #define CCSDS_USER_APP 0x00
60 60
61 61 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
62 62 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
63 63 #define SIZE_HK_PARAMETERS 112
64 64
65 65 // TC TYPES
66 66 #define TC_TYPE_GEN 181
67 67 #define TC_TYPE_TIME 9
68 68
69 69 // TC SUBTYPES
70 70 #define TC_SUBTYPE_RESET 1
71 71 #define TC_SUBTYPE_LOAD_COMM 11
72 72 #define TC_SUBTYPE_LOAD_NORM 13
73 73 #define TC_SUBTYPE_LOAD_BURST 19
74 74 #define TC_SUBTYPE_LOAD_SBM1 25
75 75 #define TC_SUBTYPE_LOAD_SBM2 27
76 76 #define TC_SUBTYPE_DUMP 31
77 77 #define TC_SUBTYPE_ENTER 41
78 78 #define TC_SUBTYPE_UPDT_INFO 51
79 79 #define TC_SUBTYPE_EN_CAL 61
80 80 #define TC_SUBTYPE_DIS_CAL 63
81 81 #define TC_SUBTYPE_UPDT_TIME 129
82 82
83 83 // TC LEN
84 84 #define TC_LEN_RESET 12
85 85 #define TC_LEN_LOAD_COMM 14
86 86 #define TC_LEN_LOAD_NORM 22
87 87 #define TC_LEN_LOAD_BURST 14
88 88 #define TC_LEN_LOAD_SBM1 14
89 89 #define TC_LEN_LOAD_SBM2 14
90 90 #define TC_LEN_DUMP 12
91 91 #define TC_LEN_ENTER 20
92 92 #define TC_LEN_UPDT_INFO 46
93 93 #define TC_LEN_EN_CAL 12
94 94 #define TC_LEN_DIS_CAL 12
95 95 #define TC_LEN_UPDT_TIME 18
96 96
97 97 // TM TYPES
98 98 #define TM_TYPE_TC_EXE 1
99 99 #define TM_TYPE_HK 3
100 100 #define TM_TYPE_PARAMETER_DUMP 3
101 101 #define TM_TYPE_LFR_SCIENCE 21
102 102
103 103 // TM SUBTYPES
104 104 #define TM_SUBTYPE_EXE_OK 7
105 105 #define TM_SUBTYPE_EXE_NOK 8
106 106 #define TM_SUBTYPE_HK 25
107 107 #define TM_SUBTYPE_PARAMETER_DUMP 25
108 108 #define TM_SUBTYPE_SCIENCE 3
109 109 #define TM_SUBTYPE_LFR_SCIENCE 3
110 110
111 111 // FAILURE CODES
112 112 #define ILLEGAL_APID 0
113 113 #define WRONG_LEN_PKT 1
114 114 #define INCOR_CHECKSUM 2
115 115 #define ILL_TYPE 3
116 116 #define ILL_SUBTYPE 4
117 117 #define WRONG_APP_DATA 5 // 0x00 0x05
118 118 #define TC_NOT_EXE 42000 // 0xa4 0x10
119 119 #define WRONG_SRC_ID 42001 // 0xa4 0x11
120 120 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
121 121 #define FAIL_DETECTED 42003 // 0xa4 0x13
122 122 #define NOT_ALLOWED 42004 // 0xa4 0x14
123 123 #define CORRUPTED 42005 // 0xa4 0x15
124 124 #define CCSDS_TM_VALID 7
125 125
126 126 // TC SID
127 127 #define SID_TC_GROUND 0
128 128 #define SID_TC_MISSION_TIMELINE 110
129 129 #define SID_TC_TC_SEQUENCES 111
130 130 #define SID_TC_RECOVERY_ACTION_CMD 112
131 131 #define SID_TC_BACKUP_MISSION_TIMELINE 113
132 132 #define SID_TC_DIRECT_CMD 120
133 133 #define SID_TC_SPARE_GRD_SRC1 121
134 134 #define SID_TC_SPARE_GRD_SRC2 122
135 135 #define SID_TC_OBCP 15
136 136 #define SID_TC_SYSTEM_CONTROL 14
137 137 #define SID_TC_AOCS 11
138 138 #define SID_TC_RPW_INTERNAL 254
139 139
140 140 enum apid_destid{
141 141 GROUND,
142 142 MISSION_TIMELINE,
143 143 TC_SEQUENCES,
144 144 RECOVERY_ACTION_CMD,
145 145 BACKUP_MISSION_TIMELINE,
146 146 DIRECT_CMD,
147 147 SPARE_GRD_SRC1,
148 148 SPARE_GRD_SRC2,
149 149 OBCP,
150 150 SYSTEM_CONTROL,
151 151 AOCS,
152 152 RPW_INTERNAL
153 153 };
154 154 // SEQUENCE COUNTERS
155 155 #define SEQ_CNT_MAX 16383
156 156 #define SEQ_CNT_NB_DEST_ID 12
157 157
158 158 // TM SID
159 159 #define SID_HK 1
160 160 #define SID_PARAMETER_DUMP 10
161 161
162 162 #define SID_NORM_SWF_F0 3
163 163 #define SID_NORM_SWF_F1 4
164 164 #define SID_NORM_SWF_F2 5
165 165 #define SID_NORM_CWF_F3 1
166 166 #define SID_BURST_CWF_F2 2
167 167 #define SID_SBM1_CWF_F1 24
168 168 #define SID_SBM2_CWF_F2 25
169 169 #define SID_NORM_ASM_F0 11
170 170 #define SID_NORM_ASM_F1 12
171 171 #define SID_NORM_ASM_F2 13
172 172 #define SID_NORM_BP1_F0 14
173 173 #define SID_NORM_BP1_F1 15
174 174 #define SID_NORM_BP1_F2 16
175 175 #define SID_NORM_BP2_F0 19
176 176 #define SID_NORM_BP2_F1 20
177 177 #define SID_NORM_BP2_F2 21
178 178 #define SID_BURST_BP1_F0 17
179 179 #define SID_BURST_BP2_F0 22
180 180 #define SID_BURST_BP1_F1 18
181 181 #define SID_BURST_BP2_F1 23
182 182 #define SID_SBM1_BP1_F0 28
183 183 #define SID_SBM1_BP2_F0 31
184 184 #define SID_SBM2_BP1_F0 29
185 185 #define SID_SBM2_BP2_F0 32
186 186 #define SID_SBM2_BP1_F1 30
187 187 #define SID_SBM2_BP2_F1 33
188 188 #define SID_NORM_CWF_LONG_F3 34
189 189
190 190 // LENGTH (BYTES)
191 191 #define LENGTH_TM_LFR_TC_EXE_MAX 32
192 192 #define LENGTH_TM_LFR_HK 126
193 193
194 194 // HEADER_LENGTH
195 195 #define TM_HEADER_LEN 16
196 196 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
197 197 // PACKET_LENGTH
198 198 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
199 199 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
200 200 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
201 201 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
202 202 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
203 203 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
204 204 #define PACKET_LENGTH_HK (124 - CCSDS_TC_TM_PACKET_OFFSET)
205 205 #define PACKET_LENGTH_PARAMETER_DUMP (36 - CCSDS_TC_TM_PACKET_OFFSET)
206 206 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0 (2228 - CCSDS_TC_TM_PACKET_OFFSET) // 44 * 25 * 2 + 28 - 7
207 207 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1 (2628 - CCSDS_TC_TM_PACKET_OFFSET) // 52 * 25 * 2 + 28 - 7
208 208 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2 (2428 - CCSDS_TC_TM_PACKET_OFFSET) // 48 * 25 * 2 + 28 - 7
209 209 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 (126 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 9 + 27 - 7
210 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 25 - 7
211 #define PACKET_LENGTH_TM_LFR_SCIENCE_BURST_BP2_F1 (806 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 30 + 26 - 7
210 212 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26 - 7
214
215 #define PACKET_LENGTH_DELTA 11 // 7 + 4
211 216
212 217 #define SPARE1_PUSVERSION_SPARE2 0x10
213 218
214 219 // R1
215 220 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1
216 221 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1
217 222 #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1
218 223 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1
219 224 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1
220 225 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1
221 226 // R2
222 227 #define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1
223 228 #define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1
224 229 #define TM_LEN_SCI_CWF_336 4051 // 336 * 12 + 10 + 10 - 1
225 230 #define TM_LEN_SCI_CWF_672 4051 // 672 * 6 + 10 + 10 - 1
226 231 //
227 232 #define DEFAULT_PKTCNT 0x07
228 233 #define BLK_NR_304 0x0130
229 234 #define BLK_NR_224 0x00e0
230 235 #define BLK_NR_CWF 0x0150 // 336
231 236 #define BLK_NR_CWF_SHORT_F3 0x02a0 // 672
232 237
233 238 enum TM_TYPE{
234 239 TM_LFR_TC_EXE_OK,
235 240 TM_LFR_TC_EXE_ERR,
236 241 TM_LFR_HK,
237 242 TM_LFR_SCI,
238 243 TM_LFR_SCI_SBM,
239 244 TM_LFR_PAR_DUMP
240 245 };
241 246
242 247 typedef struct {
243 248 unsigned char targetLogicalAddress;
244 249 unsigned char protocolIdentifier;
245 250 unsigned char reserved;
246 251 unsigned char userApplication;
247 252 // PACKET HEADER
248 253 unsigned char packetID[2];
249 254 unsigned char packetSequenceControl[2];
250 255 unsigned char packetLength[2];
251 256 // DATA FIELD HEADER
252 257 unsigned char spare1_pusVersion_spare2;
253 258 unsigned char serviceType;
254 259 unsigned char serviceSubType;
255 260 unsigned char destinationID;
256 261 unsigned char time[6];
257 262 //
258 263 unsigned char telecommand_pkt_id[2];
259 264 unsigned char pkt_seq_control[2];
260 265 } Packet_TM_LFR_TC_EXE_SUCCESS_t;
261 266
262 267 typedef struct {
263 268 unsigned char targetLogicalAddress;
264 269 unsigned char protocolIdentifier;
265 270 unsigned char reserved;
266 271 unsigned char userApplication;
267 272 // PACKET HEADER
268 273 unsigned char packetID[2];
269 274 unsigned char packetSequenceControl[2];
270 275 unsigned char packetLength[2];
271 276 // DATA FIELD HEADER
272 277 unsigned char spare1_pusVersion_spare2;
273 278 unsigned char serviceType;
274 279 unsigned char serviceSubType;
275 280 unsigned char destinationID;
276 281 unsigned char time[6];
277 282 //
278 283 unsigned char tc_failure_code[2];
279 284 unsigned char telecommand_pkt_id[2];
280 285 unsigned char pkt_seq_control[2];
281 286 unsigned char tc_service;
282 287 unsigned char tc_subtype;
283 288 unsigned char byte_position;
284 289 unsigned char rcv_value;
285 290 } Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
286 291
287 292 typedef struct {
288 293 unsigned char targetLogicalAddress;
289 294 unsigned char protocolIdentifier;
290 295 unsigned char reserved;
291 296 unsigned char userApplication;
292 297 // PACKET HEADER
293 298 unsigned char packetID[2];
294 299 unsigned char packetSequenceControl[2];
295 300 unsigned char packetLength[2];
296 301 // DATA FIELD HEADER
297 302 unsigned char spare1_pusVersion_spare2;
298 303 unsigned char serviceType;
299 304 unsigned char serviceSubType;
300 305 unsigned char destinationID;
301 306 unsigned char time[6];
302 307 //
303 308 unsigned char tc_failure_code[2];
304 309 unsigned char telecommand_pkt_id[2];
305 310 unsigned char pkt_seq_control[2];
306 311 unsigned char tc_service;
307 312 unsigned char tc_subtype;
308 313 unsigned char lfr_status_word[2];
309 314 } Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
310 315
311 316 typedef struct {
312 317 unsigned char targetLogicalAddress;
313 318 unsigned char protocolIdentifier;
314 319 unsigned char reserved;
315 320 unsigned char userApplication;
316 321 // PACKET HEADER
317 322 unsigned char packetID[2];
318 323 unsigned char packetSequenceControl[2];
319 324 unsigned char packetLength[2];
320 325 // DATA FIELD HEADER
321 326 unsigned char spare1_pusVersion_spare2;
322 327 unsigned char serviceType;
323 328 unsigned char serviceSubType;
324 329 unsigned char destinationID;
325 330 unsigned char time[6];
326 331 //
327 332 unsigned char tc_failure_code[2];
328 333 unsigned char telecommand_pkt_id[2];
329 334 unsigned char pkt_seq_control[2];
330 335 unsigned char tc_service;
331 336 unsigned char tc_subtype;
332 337 } Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
333 338
334 339 typedef struct {
335 340 unsigned char targetLogicalAddress;
336 341 unsigned char protocolIdentifier;
337 342 unsigned char reserved;
338 343 unsigned char userApplication;
339 344 // PACKET HEADER
340 345 unsigned char packetID[2];
341 346 unsigned char packetSequenceControl[2];
342 347 unsigned char packetLength[2];
343 348 // DATA FIELD HEADER
344 349 unsigned char spare1_pusVersion_spare2;
345 350 unsigned char serviceType;
346 351 unsigned char serviceSubType;
347 352 unsigned char destinationID;
348 353 unsigned char time[6];
349 354 //
350 355 unsigned char tc_failure_code[2];
351 356 unsigned char telecommand_pkt_id[2];
352 357 unsigned char pkt_seq_control[2];
353 358 unsigned char tc_service;
354 359 unsigned char tc_subtype;
355 360 } Packet_TM_LFR_TC_EXE_ERROR_t;
356 361
357 362 typedef struct {
358 363 unsigned char targetLogicalAddress;
359 364 unsigned char protocolIdentifier;
360 365 unsigned char reserved;
361 366 unsigned char userApplication;
362 367 // PACKET HEADER
363 368 unsigned char packetID[2];
364 369 unsigned char packetSequenceControl[2];
365 370 unsigned char packetLength[2];
366 371 // DATA FIELD HEADER
367 372 unsigned char spare1_pusVersion_spare2;
368 373 unsigned char serviceType;
369 374 unsigned char serviceSubType;
370 375 unsigned char destinationID;
371 376 unsigned char time[6];
372 377 //
373 378 unsigned char tc_failure_code[2];
374 379 unsigned char telecommand_pkt_id[2];
375 380 unsigned char pkt_seq_control[2];
376 381 unsigned char tc_service;
377 382 unsigned char tc_subtype;
378 383 unsigned char pkt_len_rcv_value[2];
379 384 unsigned char pkt_datafieldsize_cnt[2];
380 385 unsigned char rcv_crc[2];
381 386 unsigned char computed_crc[2];
382 387 } Packet_TM_LFR_TC_EXE_CORRUPTED_t;
383 388
384 389 typedef struct {
385 390 unsigned char targetLogicalAddress;
386 391 unsigned char protocolIdentifier;
387 392 unsigned char reserved;
388 393 unsigned char userApplication;
389 394 unsigned char packetID[2];
390 395 unsigned char packetSequenceControl[2];
391 396 unsigned char packetLength[2];
392 397 // DATA FIELD HEADER
393 398 unsigned char spare1_pusVersion_spare2;
394 399 unsigned char serviceType;
395 400 unsigned char serviceSubType;
396 401 unsigned char destinationID;
397 402 unsigned char time[6];
398 403 // AUXILIARY HEADER
399 404 unsigned char sid;
400 405 unsigned char hkBIA;
401 406 unsigned char pktCnt;
402 407 unsigned char pktNr;
403 408 unsigned char acquisitionTime[6];
404 409 unsigned char blkNr[2];
405 410 } Header_TM_LFR_SCIENCE_SWF_t;
406 411
407 412 typedef struct {
408 413 unsigned char targetLogicalAddress;
409 414 unsigned char protocolIdentifier;
410 415 unsigned char reserved;
411 416 unsigned char userApplication;
412 417 unsigned char packetID[2];
413 418 unsigned char packetSequenceControl[2];
414 419 unsigned char packetLength[2];
415 420 // DATA FIELD HEADER
416 421 unsigned char spare1_pusVersion_spare2;
417 422 unsigned char serviceType;
418 423 unsigned char serviceSubType;
419 424 unsigned char destinationID;
420 425 unsigned char time[6];
421 426 // AUXILIARY DATA HEADER
422 427 unsigned char sid;
423 428 unsigned char hkBIA;
424 429 unsigned char acquisitionTime[6];
425 430 unsigned char blkNr[2];
426 431 } Header_TM_LFR_SCIENCE_CWF_t;
427 432
428 433 typedef struct {
429 434 unsigned char targetLogicalAddress;
430 435 unsigned char protocolIdentifier;
431 436 unsigned char reserved;
432 437 unsigned char userApplication;
433 438 unsigned char packetID[2];
434 439 unsigned char packetSequenceControl[2];
435 440 unsigned char packetLength[2];
436 441 // DATA FIELD HEADER
437 442 unsigned char spare1_pusVersion_spare2;
438 443 unsigned char serviceType;
439 444 unsigned char serviceSubType;
440 445 unsigned char destinationID;
441 446 unsigned char time[6];
442 447 // AUXILIARY HEADER
443 448 unsigned char sid;
444 449 unsigned char biaStatusInfo;
445 450 unsigned char pa_lfr_pkt_cnt_asm;
446 451 unsigned char pa_lfr_pkt_nr_asm;
447 452 unsigned char acquisitionTime[6];
448 453 unsigned char pa_lfr_asm_blk_nr[2];
449 454 } Header_TM_LFR_SCIENCE_ASM_t;
450 455
451 456 typedef struct {
452 457 unsigned char targetLogicalAddress;
453 458 unsigned char protocolIdentifier;
454 459 unsigned char reserved;
455 460 unsigned char userApplication;
456 461 unsigned char packetID[2];
457 462 unsigned char packetSequenceControl[2];
458 463 unsigned char packetLength[2];
459 464 // DATA FIELD HEADER
460 465 unsigned char spare1_pusVersion_spare2;
461 466 unsigned char serviceType;
462 467 unsigned char serviceSubType;
463 468 unsigned char destinationID;
464 469 unsigned char time[6];
465 470 // AUXILIARY HEADER
466 471 unsigned char sid;
467 472 unsigned char biaStatusInfo;
468 473 unsigned char acquisitionTime[6];
469 unsigned char spare_source_data;
474 unsigned char source_data_spare[2];
470 475 unsigned char pa_lfr_bp_blk_nr[2];
471 } Header_TM_LFR_SCIENCE_BP_NORM_t;
476 } Header_TM_LFR_SCIENCE_BP_with_spare_t;
472 477
473 478 typedef struct {
474 479 unsigned char targetLogicalAddress;
475 480 unsigned char protocolIdentifier;
476 481 unsigned char reserved;
477 482 unsigned char userApplication;
478 483 unsigned char packetID[2];
479 484 unsigned char packetSequenceControl[2];
480 485 unsigned char packetLength[2];
481 486 // DATA FIELD HEADER
482 487 unsigned char spare1_pusVersion_spare2;
483 488 unsigned char serviceType;
484 489 unsigned char serviceSubType;
485 490 unsigned char destinationID;
486 491 unsigned char time[6];
487 492 // AUXILIARY HEADER
488 493 unsigned char sid;
489 494 unsigned char biaStatusInfo;
490 495 unsigned char acquisitionTime[6];
491 496 unsigned char pa_lfr_bp_blk_nr[2];
492 } Header_TM_LFR_SCIENCE_BP_SBM_t;
497 } Header_TM_LFR_SCIENCE_BP_t;
493 498
494 499 typedef struct {
495 500 //targetLogicalAddress is removed by the grspw module
496 501 unsigned char protocolIdentifier;
497 502 unsigned char reserved;
498 503 unsigned char userApplication;
499 504 unsigned char packetID[2];
500 505 unsigned char packetSequenceControl[2];
501 506 unsigned char packetLength[2];
502 507 // DATA FIELD HEADER
503 508 unsigned char headerFlag_pusVersion_Ack;
504 509 unsigned char serviceType;
505 510 unsigned char serviceSubType;
506 511 unsigned char sourceID;
507 512 unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
508 513 } ccsdsTelecommandPacket_t;
509 514
510 515 typedef struct {
511 516 unsigned char targetLogicalAddress;
512 517 unsigned char protocolIdentifier;
513 518 unsigned char reserved;
514 519 unsigned char userApplication;
515 520 unsigned char packetID[2];
516 521 unsigned char packetSequenceControl[2];
517 522 unsigned char packetLength[2];
518 523 unsigned char spare1_pusVersion_spare2;
519 524 unsigned char serviceType;
520 525 unsigned char serviceSubType;
521 526 unsigned char destinationID;
522 527 unsigned char time[6];
523 528 unsigned char sid;
524 529
525 530 //**************
526 531 // HK PARAMETERS
527 532 unsigned char lfr_status_word[2];
528 533 unsigned char lfr_sw_version[4];
529 534 unsigned char lfr_fpga_version[3];
530 535 // ressource statistics
531 536 unsigned char hk_lfr_cpu_load;
532 537 unsigned char hk_lfr_load_max;
533 538 unsigned char hk_lfr_load_aver;
534 539 // tc statistics
535 540 unsigned char hk_lfr_update_info_tc_cnt[2];
536 541 unsigned char hk_lfr_update_time_tc_cnt[2];
537 542 unsigned char hk_lfr_exe_tc_cnt[2];
538 543 unsigned char hk_lfr_rej_tc_cnt[2];
539 544 unsigned char hk_lfr_last_exe_tc_id[2];
540 545 unsigned char hk_lfr_last_exe_tc_type[2];
541 546 unsigned char hk_lfr_last_exe_tc_subtype[2];
542 547 unsigned char hk_lfr_last_exe_tc_time[6];
543 548 unsigned char hk_lfr_last_rej_tc_id[2];
544 549 unsigned char hk_lfr_last_rej_tc_type[2];
545 550 unsigned char hk_lfr_last_rej_tc_subtype[2];
546 551 unsigned char hk_lfr_last_rej_tc_time[6];
547 552 // anomaly statistics
548 553 unsigned char hk_lfr_le_cnt[2];
549 554 unsigned char hk_lfr_me_cnt[2];
550 555 unsigned char hk_lfr_he_cnt[2];
551 556 unsigned char hk_lfr_last_er_rid[2];
552 557 unsigned char hk_lfr_last_er_code;
553 558 unsigned char hk_lfr_last_er_time[6];
554 559 // vhdl_blk_status
555 560 unsigned char hk_lfr_vhdl_aa_sm;
556 561 unsigned char hk_lfr_vhdl_fft_sr;
557 562 unsigned char hk_lfr_vhdl_cic_hk;
558 563 unsigned char hk_lfr_vhdl_iir_cal;
559 564 // spacewire_if_statistics
560 565 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
561 566 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
562 567 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
563 568 unsigned char hk_lfr_dpu_spw_last_timc;
564 569 // ahb error statistics
565 570 unsigned int hk_lfr_last_fail_addr;
566 571 // temperatures
567 572 unsigned char hk_lfr_temp_scm[2];
568 573 unsigned char hk_lfr_temp_pcb[2];
569 574 unsigned char hk_lfr_temp_fpga[2];
570 575 // spacecraft potential
571 576 unsigned char hk_lfr_sc_v_f3[2];
572 577 unsigned char hk_lfr_sc_e1_f3[2];
573 578 unsigned char hk_lfr_sc_e2_f3[2];
574 579 // error counters
575 580 unsigned char hk_lfr_dpu_spw_parity;
576 581 unsigned char hk_lfr_dpu_spw_disconnect;
577 582 unsigned char hk_lfr_dpu_spw_escape;
578 583 unsigned char hk_lfr_dpu_spw_credit;
579 584 unsigned char hk_lfr_dpu_spw_write_sync;
580 585 unsigned char hk_lfr_dpu_spw_rx_ahb;
581 586 unsigned char hk_lfr_dpu_spw_tx_ahb;
582 587 unsigned char hk_lfr_dpu_spw_early_eop;
583 588 unsigned char hk_lfr_dpu_spw_invalid_addr;
584 589 unsigned char hk_lfr_dpu_spw_eep;
585 590 unsigned char hk_lfr_dpu_spw_rx_too_big;
586 591 // timecode
587 592 unsigned char hk_lfr_timecode_erroneous;
588 593 unsigned char hk_lfr_timecode_missing;
589 594 unsigned char hk_lfr_timecode_invalid;
590 595 // time
591 596 unsigned char hk_lfr_time_timecode_it;
592 597 unsigned char hk_lfr_time_not_synchro;
593 598 unsigned char hk_lfr_time_timecode_ctr;
594 599 // hk_lfr_buffer_dpu_
595 600 unsigned char hk_lfr_buffer_dpu_tc_fifo;
596 601 unsigned char hk_lfr_buffer_dpu_tm_fifo;
597 602 // hk_lfr_ahb_
598 603 unsigned char hk_lfr_ahb_correctable;
599 604 unsigned char hk_lfr_ahb_uncorrectable;
600 605 // spare
601 606 unsigned char parameters_spare;
602 607 } Packet_TM_LFR_HK_t;
603 608
604 609 typedef struct {
605 610 unsigned char targetLogicalAddress;
606 611 unsigned char protocolIdentifier;
607 612 unsigned char reserved;
608 613 unsigned char userApplication;
609 614 unsigned char packetID[2];
610 615 unsigned char packetSequenceControl[2];
611 616 unsigned char packetLength[2];
612 617 // DATA FIELD HEADER
613 618 unsigned char spare1_pusVersion_spare2;
614 619 unsigned char serviceType;
615 620 unsigned char serviceSubType;
616 621 unsigned char destinationID;
617 622 unsigned char time[6];
618 623 unsigned char sid;
619 624
620 625 //******************
621 626 // COMMON PARAMETERS
622 627 unsigned char unused0;
623 628 unsigned char bw_sp0_sp1_r0_r1;
624 629
625 630 //******************
626 631 // NORMAL PARAMETERS
627 632 unsigned char sy_lfr_n_swf_l[2];
628 633 unsigned char sy_lfr_n_swf_p[2];
629 634 unsigned char sy_lfr_n_asm_p[2];
630 635 unsigned char sy_lfr_n_bp_p0;
631 636 unsigned char sy_lfr_n_bp_p1;
632 637 unsigned char sy_lfr_n_cwf_long_f3;
633 638 unsigned char lfr_normal_parameters_spare;
634 639
635 640 //*****************
636 641 // BURST PARAMETERS
637 642 unsigned char sy_lfr_b_bp_p0;
638 643 unsigned char sy_lfr_b_bp_p1;
639 644
640 645 //****************
641 646 // SBM1 PARAMETERS
642 647 unsigned char sy_lfr_s1_bp_p0;
643 648 unsigned char sy_lfr_s1_bp_p1;
644 649
645 650 //****************
646 651 // SBM2 PARAMETERS
647 652 unsigned char sy_lfr_s2_bp_p0;
648 653 unsigned char sy_lfr_s2_bp_p1;
649 654
650 655 // SPARE
651 656 unsigned char source_data_spare;
652 657 } Packet_TM_LFR_PARAMETER_DUMP_t;
653 658
654 659
655 660 #endif // CCSDS_TYPES_H_INCLUDED
@@ -1,257 +1,229
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "fsw_params_nb_bytes.h"
7 7 #include "tm_byte_positions.h"
8 8 #include "ccsds_types.h"
9 9
10 10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 11 #define UART_DEVICE_NAME "/dev/console"
12 12
13 13 typedef struct ring_node
14 14 {
15 15 struct ring_node *previous;
16 16 int buffer_address;
17 17 struct ring_node *next;
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 typedef struct ring_node_sm
22 {
23 struct ring_node_sm *previous;
24 int buffer_address;
25 struct ring_node_sm *next;
26 unsigned int status;
27 unsigned int coarseTime;
28 unsigned int fineTime;
29 } ring_node_sm;
30
31 typedef struct ring_node_bp
32 {
33 struct ring_node_bp *previous;
34 struct ring_node_bp *next;
35 unsigned int status;
36 unsigned int coarseTime;
37 unsigned int fineTime;
38 Header_TM_LFR_SCIENCE_BP_SBM_t header;
39 unsigned char data[ 9 * 22 ];
40 } ring_node_bp;
41
42 typedef struct
43 {
44 unsigned int status;
45 unsigned int coarseTime;
46 unsigned int fineTime;
47 Header_TM_LFR_SCIENCE_BP_NORM_t header;
48 unsigned char data[ 9 * 22 ];
49 } ring_node_norm_bp;
50
51 21 //************************
52 22 // flight software version
53 23 // this parameters is handled by the Qt project options
54 24
55 25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
56 26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
57 27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
58 28 #define TIME_OFFSET 2
59 29 #define TIME_OFFSET_IN_BYTES 8
60 30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
61 31 #define NB_BYTES_SWF_BLK (2 * 6)
62 32 #define NB_WORDS_SWF_BLK 3
63 33 #define NB_BYTES_CWF3_LIGHT_BLK 6
64 34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
65 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
66 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
67 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
68 38
69 39 //**********
70 40 // LFR MODES
71 41 #define LFR_MODE_STANDBY 0
72 42 #define LFR_MODE_NORMAL 1
73 43 #define LFR_MODE_BURST 2
74 44 #define LFR_MODE_SBM1 3
75 45 #define LFR_MODE_SBM2 4
76 46
77 47 #define TDS_MODE_LFM 5
78 48 #define TDS_MODE_STANDBY 0
79 49 #define TDS_MODE_NORMAL 1
80 50 #define TDS_MODE_BURST 2
81 51 #define TDS_MODE_SBM1 3
82 52 #define TDS_MODE_SBM2 4
83 53
84 54 #define THR_MODE_STANDBY 0
85 55 #define THR_MODE_NORMAL 1
86 56 #define THR_MODE_BURST 2
87 57
88 58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
89 59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
90 60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
91 61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
92 62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
93 63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
94 #define RTEMS_EVENT_MODE_NORMAL_SWF_F0 RTEMS_EVENT_6
95 #define RTEMS_EVENT_MODE_NORMAL_SWF_F1 RTEMS_EVENT_7
96 #define RTEMS_EVENT_MODE_NORMAL_SWF_F2 RTEMS_EVENT_8
64 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
65 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
66 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
67 #define RTEMS_EVENT_SBM1_BP1_F0 RTEMS_EVENT_9
68 #define RTEMS_EVENT_SBM1_BP2_F0 RTEMS_EVENT_10
97 69
98 70 //****************************
99 71 // LFR DEFAULT MODE PARAMETERS
100 72 // COMMON
101 73 #define DEFAULT_SY_LFR_COMMON0 0x00
102 74 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
103 75 // NORM
104 76 #define SY_LFR_N_SWF_L 2048 // nb sample
105 77 #define SY_LFR_N_SWF_P 300 // sec
106 78 #define SY_LFR_N_ASM_P 3600 // sec
107 79 #define SY_LFR_N_BP_P0 4 // sec
108 80 #define SY_LFR_N_BP_P1 20 // sec
109 81 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
110 82 #define MIN_DELTA_SNAPSHOT 16 // sec
111 83 // BURST
112 84 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
113 85 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
114 86 // SBM1
115 87 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
116 88 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
117 89 // SBM2
118 90 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
119 91 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
120 92 // ADDITIONAL PARAMETERS
121 93 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
122 94 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
123 95 // STATUS WORD
124 96 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
125 97 #define DEFAULT_STATUS_WORD_BYTE1 0x00
126 98 //
127 99 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
128 100 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
129 101 //****************************
130 102
131 103 //*****************************
132 104 // APB REGISTERS BASE ADDRESSES
133 105 #define REGS_ADDR_APBUART 0x80000100
134 106 #define REGS_ADDR_GPTIMER 0x80000300
135 107 #define REGS_ADDR_GRSPW 0x80000500
136 108 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
137 109 #define REGS_ADDR_GRGPIO 0x80000b00
138 110
139 111 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
140 112 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
141 113
142 114 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
143 115 #define APBUART_CTRL_REG_MASK_TE 0x00000002
144 116 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
145 117
146 118 //**********
147 119 // IRQ LINES
148 120 #define IRQ_SM_SIMULATOR 9
149 121 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
150 122 #define IRQ_WAVEFORM_PICKER 14
151 123 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
152 124 #define IRQ_SPECTRAL_MATRIX 6
153 125 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
154 126
155 127 //*****
156 128 // TIME
157 129 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
158 130 #define TIMER_SM_SIMULATOR 1
159 131 #define HK_PERIOD 100 // 100 * 10ms => 1s
160 132 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
161 133 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
162 134
163 135 //**********
164 136 // LPP CODES
165 137 #define LFR_SUCCESSFUL 0
166 138 #define LFR_DEFAULT 1
167 139 #define LFR_EXE_ERROR 2
168 140
169 141 //******
170 142 // RTEMS
171 143 #define TASKID_RECV 1
172 144 #define TASKID_ACTN 2
173 145 #define TASKID_SPIQ 3
174 146 #define TASKID_SMIQ 4
175 147 #define TASKID_STAT 5
176 148 #define TASKID_AVF0 6
177 149 #define TASKID_SWBD 7
178 150 #define TASKID_WFRM 8
179 151 #define TASKID_DUMB 9
180 152 #define TASKID_HOUS 10
181 153 #define TASKID_MATR 11
182 154 #define TASKID_CWF3 12
183 155 #define TASKID_CWF2 13
184 156 #define TASKID_CWF1 14
185 157 #define TASKID_SEND 15
186 158 #define TASKID_WTDG 16
187 159
188 160 #define TASK_PRIORITY_SPIQ 5
189 161 #define TASK_PRIORITY_SMIQ 10
190 162 #define TASK_PRIORITY_WTDG 20
191 163 #define TASK_PRIORITY_HOUS 30
192 164 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
193 165 #define TASK_PRIORITY_CWF2 35 //
194 166 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
195 167 #define TASK_PRIORITY_WFRM 40
196 168 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
197 169 #define TASK_PRIORITY_SEND 45
198 170 #define TASK_PRIORITY_RECV 50
199 171 #define TASK_PRIORITY_ACTN 50
200 172 #define TASK_PRIORITY_AVF0 60
201 173 #define TASK_PRIORITY_BPF0 60
202 174 #define TASK_PRIORITY_MATR 100
203 175 #define TASK_PRIORITY_STAT 200
204 176 #define TASK_PRIORITY_DUMB 200
205 177
206 178 #define ACTION_MSG_QUEUE_COUNT 10
207 179 #define ACTION_MSG_PKTS_COUNT 50
208 180 //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
209 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
181 #define ACTION_MSG_PKTS_MAX_SIZE 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
210 182 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
211 183
212 184 #define QUEUE_RECV 0
213 185 #define QUEUE_SEND 1
214 186
215 187 //*******
216 188 // MACROS
217 189 #ifdef PRINT_MESSAGES_ON_CONSOLE
218 190 #define PRINTF(x) printf(x);
219 191 #define PRINTF1(x,y) printf(x,y);
220 192 #define PRINTF2(x,y,z) printf(x,y,z);
221 193 #else
222 194 #define PRINTF(x) ;
223 195 #define PRINTF1(x,y) ;
224 196 #define PRINTF2(x,y,z) ;
225 197 #endif
226 198
227 199 #ifdef BOOT_MESSAGES
228 200 #define BOOT_PRINTF(x) printf(x);
229 201 #define BOOT_PRINTF1(x,y) printf(x,y);
230 202 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
231 203 #else
232 204 #define BOOT_PRINTF(x) ;
233 205 #define BOOT_PRINTF1(x,y) ;
234 206 #define BOOT_PRINTF2(x,y,z) ;
235 207 #endif
236 208
237 209 #ifdef DEBUG_MESSAGES
238 210 #define DEBUG_PRINTF(x) printf(x);
239 211 #define DEBUG_PRINTF1(x,y) printf(x,y);
240 212 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
241 213 #else
242 214 #define DEBUG_PRINTF(x) ;
243 215 #define DEBUG_PRINTF1(x,y) ;
244 216 #define DEBUG_PRINTF2(x,y,z) ;
245 217 #endif
246 218
247 219 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
248 220
249 221 struct param_local_str{
250 222 unsigned int local_sbm1_nb_cwf_sent;
251 223 unsigned int local_sbm1_nb_cwf_max;
252 224 unsigned int local_sbm2_nb_cwf_sent;
253 225 unsigned int local_sbm2_nb_cwf_max;
254 226 unsigned int local_nb_interrupt_f0_MAX;
255 227 };
256 228
257 229 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,53 +1,57
1 1 #ifndef FSW_PARAMS_PROCESSING_H
2 2 #define FSW_PARAMS_PROCESSING_H
3 3
4 4 #define NB_BINS_PER_SM 128
5 5 #define NB_VALUES_PER_SM 25
6 6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 11 //
12 12 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
13 13 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
14 14 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
15 #define NB_RING_NODES_BP1_SBM1 10 // AT LEAST 3
15 #define NB_RING_NODES_SBM1_BP1 10 // AT LEAST 3
16 #define NB_RING_NODES_SBM1_BP2 5 // AT LEAST 3
16 17 //
17 18 #define NB_BINS_PER_ASM_F0 88
18 19 #define NB_BINS_PER_PKT_ASM_F0 44
19 20 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
20 21 #define ASM_F0_INDICE_START 17 // 88 bins
21 22 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
22 23 //
23 24 #define NB_BINS_PER_ASM_F1 104
24 25 #define NB_BINS_PER_PKT_ASM_F1 52
25 26 #define TOTAL_SIZE_ASM_F1 2600 // 25 * 104
26 27 #define ASM_F1_INDICE_START 6 // 104 bins
27 28 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
28 29 //
29 30 #define NB_BINS_PER_ASM_F2 96
30 31 #define NB_BINS_PER_PKT_ASM_F2 48
31 32 #define TOTAL_SIZE_ASM_F2 2400 // 25 * 96
32 33 #define ASM_F2_INDICE_START 7 // 96 bins
33 34 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
34 35 //
35 36 #define NB_BINS_COMPRESSED_SM_F0 11
36 37 #define NB_BINS_COMPRESSED_SM_F1 13
37 38 #define NB_BINS_COMPRESSED_SM_F2 12
38 39 #define NB_BINS_COMPRESSED_SM_SBM1_F0 22
39 40 //
40 41 #define NB_BINS_TO_AVERAGE_ASM_F0 8
41 42 #define NB_BINS_TO_AVERAGE_ASM_F1 8
42 43 #define NB_BINS_TO_AVERAGE_ASM_F2 8
43 44 #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4
44 45 //
45 46 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
46 47 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
47 48 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
48 49 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
49 #define NB_AVERAGE_NORMAL_F0 384 // 96 * 4
50 #define NB_AVERAGE_SBM1_F0 24 // 24 matrices at f0 = 0.25 second
51 #define NB_SM_TO_RECEIVE_BEFORE_AVF0 8
50 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
51 #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20
52 #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second
53 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
54 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
55 #define NB_SM_BEFORE_AVF0 8
52 56
53 57 #endif // FSW_PARAMS_PROCESSING_H
@@ -1,64 +1,108
1 1 #ifndef FSW_PROCESSING_H_INCLUDED
2 2 #define FSW_PROCESSING_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <math.h>
7 7 #include <stdlib.h> // abs() is in the stdlib
8 8 #include <stdio.h> // printf()
9 9 #include <math.h>
10 10
11 11 #include "fsw_params.h"
12 12 #include "fsw_spacewire.h"
13 13
14 typedef struct ring_node_sm
15 {
16 struct ring_node_sm *previous;
17 int buffer_address;
18 struct ring_node_sm *next;
19 unsigned int status;
20 unsigned int coarseTime;
21 unsigned int fineTime;
22 } ring_node_sm;
23
24 typedef struct ring_node_bp
25 {
26 struct ring_node_bp *previous;
27 struct ring_node_bp *next;
28 unsigned int status;
29 unsigned int coarseTime;
30 unsigned int fineTime;
31 Header_TM_LFR_SCIENCE_BP_t header;
32 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 TM_LFR_SCIENCE_BURST_BP2_F1
33 } ring_node_bp;
34
35 typedef struct ring_node_bp_with_spare
36 {
37 struct ring_node_bp_with_spare *previous;
38 struct ring_node_bp_with_spare *next;
39 unsigned int status;
40 unsigned int coarseTime;
41 unsigned int fineTime;
42 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
43 unsigned char data[ 9 * 22 ];
44 } ring_node_bp_with_spare;
45
14 46 extern volatile int sm_f0[ ];
15 47 extern volatile int sm_f1[ ];
16 48 extern volatile int sm_f2[ ];
17 49
18 50 // parameters
19 51 extern struct param_local_str param_local;
20 52
21 53 // registers
22 54 extern time_management_regs_t *time_management_regs;
23 55 extern spectral_matrix_regs_t *spectral_matrix_regs;
24 56
25 57 extern rtems_name misc_name[5];
26 58 extern rtems_id Task_id[20]; /* array of task ids */
27 59
28 60 void init_sm_rings( void );
29 61 void reset_current_sm_ring_nodes( void );
62 void reset_current_bp_ring_nodes( void );
30 63
31 64 // ISR
32 65 void reset_nb_sm_f0( void );
33 66 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
34 67 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
35 68
36 69 // RTEMS TASKS
37 70 rtems_task avf0_task(rtems_task_argument argument);
38 71 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
39 72 rtems_task matr_task(rtems_task_argument argument);
40 73
41 74 //*****************************
42 75 // Spectral matrices processing
43 76
44 void ASM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
77 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
45 78 ring_node_sm *ring_node_tab[],
46 79 unsigned int firstTimeF0, unsigned int firstTimeF1 );
47 80 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
48 81 float divider );
49 82 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
50 83 float divider,
51 84 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
52 85 void ASM_convert(volatile float *input_matrix, char *output_matrix);
53 86 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
54 87 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
55 88
56 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id );
89 void BP_send(char *data,
90 rtems_id queue_id ,
91 unsigned int nbBytesToSend );
57 92
58 93 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
59 void init_headers_bp_ring_sbm1();
60 void init_header_bp( Header_TM_LFR_SCIENCE_BP_SBM_t *header);
94 void init_bp_ring_sbm1_bp1( void );
95 void init_bp_ring_sbm1_bp2( void );
96 void init_headers_bp_ring_sbm1_bp1();
97 void init_header_bp(Header_TM_LFR_SCIENCE_BP_t *header,
98 unsigned int apid, unsigned char sid,
99 unsigned int packetLength , unsigned char blkNr);
100 void init_header_bp_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
101 unsigned int apid, unsigned char sid,
102 unsigned int packetLength, unsigned char blkNr );
61 103
62 104 void reset_spectral_matrix_regs( void );
63 105
106 void set_time( unsigned char *time, unsigned int coarseTime, unsigned int fineTime );
107
64 108 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,644 +1,646
1 1 /** This is the RTEMS initialization module.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * This module contains two very different information:
7 7 * - specific instructions to configure the compilation of the RTEMS executive
8 8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 9 *
10 10 */
11 11
12 12 //*************************
13 13 // GPL reminder to be added
14 14 //*************************
15 15
16 16 #include <rtems.h>
17 17
18 18 /* configuration information */
19 19
20 20 #define CONFIGURE_INIT
21 21
22 22 #include <bsp.h> /* for device driver prototypes */
23 23
24 24 /* configuration information */
25 25
26 26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28 28
29 29 #define CONFIGURE_MAXIMUM_TASKS 20
30 30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
39 39 #ifdef PRINT_STACK_REPORT
40 40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 41 #endif
42 42
43 43 #include <rtems/confdefs.h>
44 44
45 45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 46 #ifdef RTEMS_DRVMGR_STARTUP
47 47 #ifdef LEON3
48 48 /* Add Timer and UART Driver */
49 49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 51 #endif
52 52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 54 #endif
55 55 #endif
56 56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 57 #include <drvmgr/drvmgr_confdefs.h>
58 58 #endif
59 59
60 60 #include "fsw_init.h"
61 61 #include "fsw_config.c"
62 62
63 63 rtems_task Init( rtems_task_argument ignored )
64 64 {
65 65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 66 *
67 67 * @param unused is the starting argument of the RTEMS task
68 68 *
69 69 * The INIT task create and run all other RTEMS tasks.
70 70 *
71 71 */
72 72
73 73 reset_local_time();
74 74
75 75 rtems_status_code status;
76 76 rtems_status_code status_spw;
77 77 rtems_isr_entry old_isr_handler;
78 78
79 79 // UART settings
80 80 send_console_outputs_on_apbuart_port();
81 81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
82 82 enable_apbuart_transmitter();
83 83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
84 84
85 85 PRINTF("\n\n\n\n\n")
86 86 PRINTF("*************************\n")
87 87 PRINTF("** LFR Flight Software **\n")
88 88 PRINTF1("** %d.", SW_VERSION_N1)
89 89 PRINTF1("%d.", SW_VERSION_N2)
90 90 PRINTF1("%d.", SW_VERSION_N3)
91 91 PRINTF1("%d **\n", SW_VERSION_N4)
92 92 PRINTF("*************************\n")
93 93 PRINTF("\n\n")
94 94
95 95 init_parameter_dump();
96 96 init_local_mode_parameters();
97 97 init_housekeeping_parameters();
98 98
99 99 init_waveform_rings(); // initialize the waveform rings
100 100 init_sm_rings(); // initialize spectral matrices rings
101 init_bp_ring_sbm1_bp1(); // initialize basic parameter ring for SBM1 BP1 set
102 init_bp_ring_sbm1_bp2(); // initialize basic parameter ring for SBM1 BP2 set
101 103
102 104 reset_wfp_burst_enable();
103 105 reset_wfp_status();
104 106 set_wfp_data_shaping();
105 107
106 108 updateLFRCurrentMode();
107 109
108 110 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
109 111
110 112 create_names(); // create all names
111 113
112 114 status = create_message_queues(); // create message queues
113 115 if (status != RTEMS_SUCCESSFUL)
114 116 {
115 117 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
116 118 }
117 119
118 120 status = create_all_tasks(); // create all tasks
119 121 if (status != RTEMS_SUCCESSFUL)
120 122 {
121 123 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
122 124 }
123 125
124 126 // **************************
125 127 // <SPACEWIRE INITIALIZATION>
126 128 grspw_timecode_callback = &timecode_irq_handler;
127 129
128 130 status_spw = spacewire_open_link(); // (1) open the link
129 131 if ( status_spw != RTEMS_SUCCESSFUL )
130 132 {
131 133 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
132 134 }
133 135
134 136 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
135 137 {
136 138 status_spw = spacewire_configure_link( fdSPW );
137 139 if ( status_spw != RTEMS_SUCCESSFUL )
138 140 {
139 141 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
140 142 }
141 143 }
142 144
143 145 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
144 146 {
145 147 status_spw = spacewire_start_link( fdSPW );
146 148 if ( status_spw != RTEMS_SUCCESSFUL )
147 149 {
148 150 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
149 151 }
150 152 }
151 153 // </SPACEWIRE INITIALIZATION>
152 154 // ***************************
153 155
154 156 status = start_all_tasks(); // start all tasks
155 157 if (status != RTEMS_SUCCESSFUL)
156 158 {
157 159 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
158 160 }
159 161
160 162 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
161 163 status = start_recv_send_tasks();
162 164 if ( status != RTEMS_SUCCESSFUL )
163 165 {
164 166 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
165 167 }
166 168
167 169 // suspend science tasks, they will be restarted later depending on the mode
168 170 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
169 171 if (status != RTEMS_SUCCESSFUL)
170 172 {
171 173 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
172 174 }
173 175
174 176 //******************************
175 177 // <SPECTRAL MATRICES SIMULATOR>
176 178 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
177 179 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
178 180 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
179 181 // </SPECTRAL MATRICES SIMULATOR>
180 182 //*******************************
181 183
182 184 // configure IRQ handling for the waveform picker unit
183 185 status = rtems_interrupt_catch( waveforms_isr,
184 186 IRQ_SPARC_WAVEFORM_PICKER,
185 187 &old_isr_handler) ;
186 188 // configure IRQ handling for the spectral matrices unit
187 189 status = rtems_interrupt_catch( spectral_matrices_isr,
188 190 IRQ_SPARC_SPECTRAL_MATRIX,
189 191 &old_isr_handler) ;
190 192
191 193 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
192 194 if ( status_spw != RTEMS_SUCCESSFUL )
193 195 {
194 196 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
195 197 if ( status != RTEMS_SUCCESSFUL ) {
196 198 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
197 199 }
198 200 }
199 201
200 202 BOOT_PRINTF("delete INIT\n")
201 203
202 204 send_dumb_hk();
203 205
204 206 status = rtems_task_delete(RTEMS_SELF);
205 207
206 208 }
207 209
208 210 void init_local_mode_parameters( void )
209 211 {
210 212 /** This function initialize the param_local global variable with default values.
211 213 *
212 214 */
213 215
214 216 unsigned int i;
215 217
216 218 // LOCAL PARAMETERS
217 219 set_local_nb_interrupt_f0_MAX();
218 220
219 221 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
220 222 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
221 223 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
222 224
223 225 // init sequence counters
224 226
225 227 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
226 228 {
227 229 sequenceCounters_TC_EXE[i] = 0x00;
228 230 }
229 231 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
230 232 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
231 233 }
232 234
233 235 void reset_local_time( void )
234 236 {
235 237 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
236 238 }
237 239
238 240 void create_names( void ) // create all names for tasks and queues
239 241 {
240 242 /** This function creates all RTEMS names used in the software for tasks and queues.
241 243 *
242 244 * @return RTEMS directive status codes:
243 245 * - RTEMS_SUCCESSFUL - successful completion
244 246 *
245 247 */
246 248
247 249 // task names
248 250 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
249 251 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
250 252 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
251 253 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
252 254 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
253 255 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
254 256 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
255 257 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
256 258 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
257 259 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
258 260 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
259 261 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
260 262 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
261 263 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
262 264 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
263 265 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
264 266
265 267 // rate monotonic period names
266 268 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
267 269
268 270 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
269 271 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
270 272 }
271 273
272 274 int create_all_tasks( void ) // create all tasks which run in the software
273 275 {
274 276 /** This function creates all RTEMS tasks used in the software.
275 277 *
276 278 * @return RTEMS directive status codes:
277 279 * - RTEMS_SUCCESSFUL - task created successfully
278 280 * - RTEMS_INVALID_ADDRESS - id is NULL
279 281 * - RTEMS_INVALID_NAME - invalid task name
280 282 * - RTEMS_INVALID_PRIORITY - invalid task priority
281 283 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
282 284 * - RTEMS_TOO_MANY - too many tasks created
283 285 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
284 286 * - RTEMS_TOO_MANY - too many global objects
285 287 *
286 288 */
287 289
288 290 rtems_status_code status;
289 291
290 292 //**********
291 293 // SPACEWIRE
292 294 // RECV
293 295 status = rtems_task_create(
294 296 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
295 297 RTEMS_DEFAULT_MODES,
296 298 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
297 299 );
298 300 if (status == RTEMS_SUCCESSFUL) // SEND
299 301 {
300 302 status = rtems_task_create(
301 303 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
302 304 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 305 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
304 306 );
305 307 }
306 308 if (status == RTEMS_SUCCESSFUL) // WTDG
307 309 {
308 310 status = rtems_task_create(
309 311 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
310 312 RTEMS_DEFAULT_MODES,
311 313 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
312 314 );
313 315 }
314 316 if (status == RTEMS_SUCCESSFUL) // ACTN
315 317 {
316 318 status = rtems_task_create(
317 319 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
318 320 RTEMS_DEFAULT_MODES,
319 321 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
320 322 );
321 323 }
322 324 if (status == RTEMS_SUCCESSFUL) // SPIQ
323 325 {
324 326 status = rtems_task_create(
325 327 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
326 328 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
327 329 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
328 330 );
329 331 }
330 332
331 333 //******************
332 334 // SPECTRAL MATRICES
333 335 if (status == RTEMS_SUCCESSFUL) // SMIQ
334 336 {
335 337 status = rtems_task_create(
336 338 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
337 339 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
338 340 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
339 341 );
340 342 }
341 343 if (status == RTEMS_SUCCESSFUL) // AVF0
342 344 {
343 345 status = rtems_task_create(
344 346 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
345 347 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
346 348 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
347 349 );
348 350 }
349 351 if (status == RTEMS_SUCCESSFUL) // MATR
350 352 {
351 353 status = rtems_task_create(
352 354 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
353 355 RTEMS_DEFAULT_MODES,
354 356 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
355 357 );
356 358 }
357 359
358 360 //****************
359 361 // WAVEFORM PICKER
360 362 if (status == RTEMS_SUCCESSFUL) // WFRM
361 363 {
362 364 status = rtems_task_create(
363 365 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
364 366 RTEMS_DEFAULT_MODES,
365 367 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
366 368 );
367 369 }
368 370 if (status == RTEMS_SUCCESSFUL) // CWF3
369 371 {
370 372 status = rtems_task_create(
371 373 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
372 374 RTEMS_DEFAULT_MODES,
373 375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
374 376 );
375 377 }
376 378 if (status == RTEMS_SUCCESSFUL) // CWF2
377 379 {
378 380 status = rtems_task_create(
379 381 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
380 382 RTEMS_DEFAULT_MODES,
381 383 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
382 384 );
383 385 }
384 386 if (status == RTEMS_SUCCESSFUL) // CWF1
385 387 {
386 388 status = rtems_task_create(
387 389 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
388 390 RTEMS_DEFAULT_MODES,
389 391 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
390 392 );
391 393 }
392 394 if (status == RTEMS_SUCCESSFUL) // SWBD
393 395 {
394 396 status = rtems_task_create(
395 397 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
396 398 RTEMS_DEFAULT_MODES,
397 399 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
398 400 );
399 401 }
400 402
401 403 //*****
402 404 // MISC
403 405 if (status == RTEMS_SUCCESSFUL) // STAT
404 406 {
405 407 status = rtems_task_create(
406 408 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
407 409 RTEMS_DEFAULT_MODES,
408 410 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
409 411 );
410 412 }
411 413 if (status == RTEMS_SUCCESSFUL) // DUMB
412 414 {
413 415 status = rtems_task_create(
414 416 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
415 417 RTEMS_DEFAULT_MODES,
416 418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
417 419 );
418 420 }
419 421 if (status == RTEMS_SUCCESSFUL) // HOUS
420 422 {
421 423 status = rtems_task_create(
422 424 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
423 425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
424 426 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
425 427 );
426 428 }
427 429
428 430 return status;
429 431 }
430 432
431 433 int start_recv_send_tasks( void )
432 434 {
433 435 rtems_status_code status;
434 436
435 437 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
436 438 if (status!=RTEMS_SUCCESSFUL) {
437 439 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
438 440 }
439 441
440 442 if (status == RTEMS_SUCCESSFUL) // SEND
441 443 {
442 444 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
443 445 if (status!=RTEMS_SUCCESSFUL) {
444 446 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
445 447 }
446 448 }
447 449
448 450 return status;
449 451 }
450 452
451 453 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
452 454 {
453 455 /** This function starts all RTEMS tasks used in the software.
454 456 *
455 457 * @return RTEMS directive status codes:
456 458 * - RTEMS_SUCCESSFUL - ask started successfully
457 459 * - RTEMS_INVALID_ADDRESS - invalid task entry point
458 460 * - RTEMS_INVALID_ID - invalid task id
459 461 * - RTEMS_INCORRECT_STATE - task not in the dormant state
460 462 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
461 463 *
462 464 */
463 465 // starts all the tasks fot eh flight software
464 466
465 467 rtems_status_code status;
466 468
467 469 //**********
468 470 // SPACEWIRE
469 471 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
470 472 if (status!=RTEMS_SUCCESSFUL) {
471 473 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
472 474 }
473 475
474 476 if (status == RTEMS_SUCCESSFUL) // WTDG
475 477 {
476 478 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
477 479 if (status!=RTEMS_SUCCESSFUL) {
478 480 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
479 481 }
480 482 }
481 483
482 484 if (status == RTEMS_SUCCESSFUL) // ACTN
483 485 {
484 486 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
485 487 if (status!=RTEMS_SUCCESSFUL) {
486 488 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
487 489 }
488 490 }
489 491
490 492 //******************
491 493 // SPECTRAL MATRICES
492 494 if (status == RTEMS_SUCCESSFUL) // SMIQ
493 495 {
494 496 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
495 497 if (status!=RTEMS_SUCCESSFUL) {
496 498 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
497 499 }
498 500 }
499 501
500 502 if (status == RTEMS_SUCCESSFUL) // AVF0
501 503 {
502 504 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
503 505 if (status!=RTEMS_SUCCESSFUL) {
504 506 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
505 507 }
506 508 }
507 509
508 510 if (status == RTEMS_SUCCESSFUL) // MATR
509 511 {
510 512 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
511 513 if (status!=RTEMS_SUCCESSFUL) {
512 514 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
513 515 }
514 516 }
515 517
516 518 //****************
517 519 // WAVEFORM PICKER
518 520 if (status == RTEMS_SUCCESSFUL) // WFRM
519 521 {
520 522 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
521 523 if (status!=RTEMS_SUCCESSFUL) {
522 524 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
523 525 }
524 526 }
525 527
526 528 if (status == RTEMS_SUCCESSFUL) // CWF3
527 529 {
528 530 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
529 531 if (status!=RTEMS_SUCCESSFUL) {
530 532 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
531 533 }
532 534 }
533 535
534 536 if (status == RTEMS_SUCCESSFUL) // CWF2
535 537 {
536 538 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
537 539 if (status!=RTEMS_SUCCESSFUL) {
538 540 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
539 541 }
540 542 }
541 543
542 544 if (status == RTEMS_SUCCESSFUL) // CWF1
543 545 {
544 546 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
545 547 if (status!=RTEMS_SUCCESSFUL) {
546 548 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
547 549 }
548 550 }
549 551
550 552 if (status == RTEMS_SUCCESSFUL) // SWBD
551 553 {
552 554 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
553 555 if (status!=RTEMS_SUCCESSFUL) {
554 556 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
555 557 }
556 558 }
557 559
558 560 //*****
559 561 // MISC
560 562 if (status == RTEMS_SUCCESSFUL) // HOUS
561 563 {
562 564 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
563 565 if (status!=RTEMS_SUCCESSFUL) {
564 566 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
565 567 }
566 568 }
567 569
568 570 if (status == RTEMS_SUCCESSFUL) // DUMB
569 571 {
570 572 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
571 573 if (status!=RTEMS_SUCCESSFUL) {
572 574 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
573 575 }
574 576 }
575 577
576 578 if (status == RTEMS_SUCCESSFUL) // STAT
577 579 {
578 580 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
579 581 if (status!=RTEMS_SUCCESSFUL) {
580 582 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
581 583 }
582 584 }
583 585
584 586 return status;
585 587 }
586 588
587 589 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
588 590 {
589 591 rtems_status_code status_recv;
590 592 rtems_status_code status_send;
591 593 rtems_status_code ret;
592 594 rtems_id queue_id;
593 595
594 596 // create the queue for handling valid TCs
595 597 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
596 598 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
597 599 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
598 600 if ( status_recv != RTEMS_SUCCESSFUL ) {
599 601 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
600 602 }
601 603
602 604 // create the queue for handling TM packet sending
603 605 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
604 606 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
605 607 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
606 608 if ( status_send != RTEMS_SUCCESSFUL ) {
607 609 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
608 610 }
609 611
610 612 if ( status_recv != RTEMS_SUCCESSFUL )
611 613 {
612 614 ret = status_recv;
613 615 }
614 616 else
615 617 {
616 618 ret = status_send;
617 619 }
618 620
619 621 return ret;
620 622 }
621 623
622 624 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
623 625 {
624 626 rtems_status_code status;
625 627 rtems_name queue_name;
626 628
627 629 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
628 630
629 631 status = rtems_message_queue_ident( queue_name, 0, queue_id );
630 632
631 633 return status;
632 634 }
633 635
634 636 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
635 637 {
636 638 rtems_status_code status;
637 639 rtems_name queue_name;
638 640
639 641 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
640 642
641 643 status = rtems_message_queue_ident( queue_name, 0, queue_id );
642 644
643 645 return status;
644 646 }
@@ -1,420 +1,420
1 1 /** General usage functions and RTEMS tasks.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 */
7 7
8 8 #include "fsw_misc.h"
9 9
10 10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 12 {
13 13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 14 *
15 15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 18 * @param interrupt_level is the interrupt level that the timer drives.
19 19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 20 *
21 21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 22 *
23 23 */
24 24
25 25 rtems_status_code status;
26 26 rtems_isr_entry old_isr_handler;
27 27
28 28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29 29
30 30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 31 if (status!=RTEMS_SUCCESSFUL)
32 32 {
33 33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 34 }
35 35
36 36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 37 }
38 38
39 39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 40 {
41 41 /** This function starts a GPTIMER timer.
42 42 *
43 43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 45 *
46 46 */
47 47
48 48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 53 }
54 54
55 55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 56 {
57 57 /** This function stops a GPTIMER timer.
58 58 *
59 59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 61 *
62 62 */
63 63
64 64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 67 }
68 68
69 69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 70 {
71 71 /** This function sets the clock divider of a GPTIMER timer.
72 72 *
73 73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 76 *
77 77 */
78 78
79 79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 80 }
81 81
82 82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 83 {
84 84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85 85
86 86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87 87
88 88 return 0;
89 89 }
90 90
91 91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 92 {
93 93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94 94
95 95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96 96
97 97 return 0;
98 98 }
99 99
100 100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 101 {
102 102 /** This function sets the scaler reload register of the apbuart module
103 103 *
104 104 * @param regs is the address of the apbuart registers in memory
105 105 * @param value is the value that will be stored in the scaler register
106 106 *
107 107 * The value shall be set by the software to get data on the serial interface.
108 108 *
109 109 */
110 110
111 111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112 112
113 113 apbuart_regs->scaler = value;
114 114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 115 }
116 116
117 117 //************
118 118 // RTEMS TASKS
119 119
120 120 rtems_task stat_task(rtems_task_argument argument)
121 121 {
122 122 int i;
123 123 int j;
124 124 i = 0;
125 125 j = 0;
126 126 BOOT_PRINTF("in STAT *** \n")
127 127 while(1){
128 128 rtems_task_wake_after(1000);
129 129 PRINTF1("%d\n", j)
130 130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 131 // #ifdef PRINT_TASK_STATISTICS
132 132 // rtems_cpu_usage_report();
133 133 // rtems_cpu_usage_reset();
134 134 // #endif
135 135 i = 0;
136 136 }
137 137 else i++;
138 138 j++;
139 139 }
140 140 }
141 141
142 142 rtems_task hous_task(rtems_task_argument argument)
143 143 {
144 144 rtems_status_code status;
145 145 rtems_id queue_id;
146 146 rtems_rate_monotonic_period_status period_status;
147 147
148 148 status = get_message_queue_id_send( &queue_id );
149 149 if (status != RTEMS_SUCCESSFUL)
150 150 {
151 151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 152 }
153 153
154 154 BOOT_PRINTF("in HOUS ***\n")
155 155
156 156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 158 if( status != RTEMS_SUCCESSFUL ) {
159 159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 160 }
161 161 }
162 162
163 163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 177 housekeeping_packet.sid = SID_HK;
178 178
179 179 status = rtems_rate_monotonic_cancel(HK_id);
180 180 if( status != RTEMS_SUCCESSFUL ) {
181 181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 182 }
183 183 else {
184 184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 185 }
186 186
187 187 // startup phase
188 188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 192 {
193 193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 194 {
195 195 break; // break if LFR is synchronized
196 196 }
197 197 else
198 198 {
199 199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 200 sched_yield();
201 201 }
202 202 }
203 203 status = rtems_rate_monotonic_cancel(HK_id);
204 204 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
205 205
206 206 while(1){ // launch the rate monotonic task
207 207 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
208 208 if ( status != RTEMS_SUCCESSFUL ) {
209 209 PRINTF1( "in HOUS *** ERR period: %d\n", status);
210 210 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
211 211 }
212 212 else {
213 213 increment_seq_counter( housekeeping_packet.packetSequenceControl );
214 214 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
215 215 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
216 216 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
217 217 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
218 218 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
219 219 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
220 220
221 221 spacewire_update_statistics();
222 222
223 223 // SEND PACKET
224 224 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
225 225 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
226 226 if (status != RTEMS_SUCCESSFUL) {
227 227 PRINTF1("in HOUS *** ERR send: %d\n", status)
228 228 }
229 229 }
230 230 }
231 231
232 232 PRINTF("in HOUS *** deleting task\n")
233 233
234 234 status = rtems_task_delete( RTEMS_SELF ); // should not return
235 235 printf( "rtems_task_delete returned with status of %d.\n", status );
236 236 return;
237 237 }
238 238
239 239 rtems_task dumb_task( rtems_task_argument unused )
240 240 {
241 241 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
242 242 *
243 243 * @param unused is the starting argument of the RTEMS task
244 244 *
245 245 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
246 246 *
247 247 */
248 248
249 249 unsigned int i;
250 250 unsigned int intEventOut;
251 251 unsigned int coarse_time = 0;
252 252 unsigned int fine_time = 0;
253 253 rtems_event_set event_out;
254 254
255 255 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
256 256 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
257 257 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
258 258 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
259 259 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
260 260 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
261 261 "ERR HK", // RTEMS_EVENT_6
262 262 "ready for dump", // RTEMS_EVENT_7
263 263 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
264 264 "tick" // RTEMS_EVENT_9
265 265 };
266 266
267 267 BOOT_PRINTF("in DUMB *** \n")
268 268
269 269 while(1){
270 270 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
271 271 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
272 272 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
273 273 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
274 274 intEventOut = (unsigned int) event_out;
275 275 for ( i=0; i<32; i++)
276 276 {
277 277 if ( ((intEventOut >> i) & 0x0001) != 0)
278 278 {
279 279 coarse_time = time_management_regs->coarse_time;
280 280 fine_time = time_management_regs->fine_time;
281 281 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
282 282 }
283 283 }
284 284 }
285 285 }
286 286
287 287 //*****************************
288 288 // init housekeeping parameters
289 289
290 290 void init_housekeeping_parameters( void )
291 291 {
292 292 /** This function initialize the housekeeping_packet global variable with default values.
293 293 *
294 294 */
295 295
296 296 unsigned int i = 0;
297 297 unsigned char *parameters;
298 298
299 299 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
300 300 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
301 301 {
302 302 parameters[i] = 0x00;
303 303 }
304 304 // init status word
305 305 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
306 306 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
307 307 // init software version
308 308 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
309 309 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
310 310 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
311 311 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
312 312 // init fpga version
313 313 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
314 314 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
315 315 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
316 316 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
317 317 }
318 318
319 319 void increment_seq_counter( unsigned char *packet_sequence_control)
320 320 {
321 321 /** This function increment the sequence counter psased in argument.
322 322 *
323 323 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
324 324 *
325 325 */
326 326
327 327 unsigned short sequence_cnt;
328 328 unsigned short segmentation_grouping_flag;
329 329 unsigned short new_packet_sequence_control;
330 330
331 331 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
332 332 sequence_cnt = (unsigned short) (
333 333 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
334 334 + packet_sequence_control[1]
335 335 );
336 336
337 337 if ( sequence_cnt < SEQ_CNT_MAX)
338 338 {
339 339 sequence_cnt = sequence_cnt + 1;
340 340 }
341 341 else
342 342 {
343 343 sequence_cnt = 0;
344 344 }
345 345
346 346 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
347 347
348 348 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
349 349 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
350 350 }
351 351
352 352 void getTime( unsigned char *time)
353 353 {
354 354 /** This function write the current local time in the time buffer passed in argument.
355 355 *
356 356 */
357 357
358 358 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
359 359 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
360 360 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
361 361 time[3] = (unsigned char) (time_management_regs->coarse_time);
362 362 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
363 363 time[5] = (unsigned char) (time_management_regs->fine_time);
364 364 }
365 365
366 366 void send_dumb_hk( void )
367 367 {
368 368 Packet_TM_LFR_HK_t dummy_hk_packet;
369 369 unsigned char *parameters;
370 370 unsigned int i;
371 371 rtems_id queue_id;
372 372
373 373 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
374 374 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
375 375 dummy_hk_packet.reserved = DEFAULT_RESERVED;
376 376 dummy_hk_packet.userApplication = CCSDS_USER_APP;
377 dummy_hk_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
378 dummy_hk_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
377 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
378 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
379 379 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
380 380 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
381 381 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
382 382 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
383 383 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
384 384 dummy_hk_packet.serviceType = TM_TYPE_HK;
385 385 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
386 386 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
387 387 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
388 388 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
389 389 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
390 390 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
391 391 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
392 392 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
393 393 dummy_hk_packet.sid = SID_HK;
394 394
395 395 // init status word
396 396 dummy_hk_packet.lfr_status_word[0] = 0xff;
397 397 dummy_hk_packet.lfr_status_word[1] = 0xff;
398 398 // init software version
399 399 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
400 400 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
401 401 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
402 402 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
403 403 // init fpga version
404 404 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
405 405 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
406 406 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
407 407 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
408 408
409 409 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
410 410
411 411 for (i=0; i<100; i++)
412 412 {
413 413 parameters[i] = 0xff;
414 414 }
415 415
416 416 get_message_queue_id_send( &queue_id );
417 417
418 418 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
419 419 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
420 420 }
@@ -1,704 +1,824
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include <fsw_processing.h>
11 11
12 12 #include "fsw_processing_globals.c"
13 13
14 14 //************************
15 15 // spectral matrices rings
16 16 ring_node_sm sm_ring_f0[ NB_RING_NODES_ASM_F0 ];
17 17 ring_node_sm sm_ring_f1[ NB_RING_NODES_ASM_F1 ];
18 18 ring_node_sm sm_ring_f2[ NB_RING_NODES_ASM_F2 ];
19 19 ring_node_sm *current_ring_node_sm_f0;
20 20 ring_node_sm *ring_node_for_averaging_sm_f0;
21 21 ring_node_sm *current_ring_node_sm_f1;
22 22 ring_node_sm *current_ring_node_sm_f2;
23 23
24 24 //**********************
25 25 // basic parameter rings
26 26 ring_node_bp *current_node_sbm1_bp1_f0;
27 ring_node_bp bp_ring_sbm1[ NB_RING_NODES_BP1_SBM1 ];
27 ring_node_bp *current_node_sbm1_bp2_f0;
28 ring_node_bp bp_ring_sbm1_bp1[ NB_RING_NODES_SBM1_BP1 ];
29 ring_node_bp bp_ring_sbm1_bp2[ NB_RING_NODES_SBM1_BP2 ];
28 30
29 31 //*****
30 32 // NORM
31 33 // F0
32 float asm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
34 float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
33 35 float asm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
34 36 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
35 float compressed_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
37 float compressed_sm_norm_f0[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
36 38
37 39 //*****
38 40 // SBM1
39 float averaged_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_SM ];
41 float asm_sbm1_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
40 42 float compressed_sm_sbm1 [ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
41 43
42 44 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
43 45 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
44 46 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ];
45 47
46 48 unsigned int nb_sm_f0;
47 49
48 50 void init_sm_rings( void )
49 51 {
50 52 unsigned char i;
51 53
52 54 // F0 RING
53 55 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
54 56 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
55 57 sm_ring_f0[0].buffer_address =
56 58 (int) &sm_f0[ 0 ];
57 59
58 60 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
59 61 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
60 62 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address =
61 63 (int) &sm_f0[ (NB_RING_NODES_ASM_F0-1) * TOTAL_SIZE_SM ];
62 64
63 65 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
64 66 {
65 67 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
66 68 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
67 69 sm_ring_f0[i].buffer_address =
68 70 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
69 71 }
70 72
71 73 // F1 RING
72 74 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
73 75 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
74 76 sm_ring_f1[0].buffer_address =
75 77 (int) &sm_f1[ 0 ];
76 78
77 79 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
78 80 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
79 81 sm_ring_f1[NB_RING_NODES_ASM_F1-1].buffer_address =
80 82 (int) &sm_f1[ (NB_RING_NODES_ASM_F1-1) * TOTAL_SIZE_SM ];
81 83
82 84 for(i=1; i<NB_RING_NODES_ASM_F1-1; i++)
83 85 {
84 86 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
85 87 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
86 88 sm_ring_f1[i].buffer_address =
87 89 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
88 90 }
89 91
90 92 // F2 RING
91 93 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
92 94 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
93 95 sm_ring_f2[0].buffer_address =
94 96 (int) &sm_f2[ 0 ];
95 97
96 98 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
97 99 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
98 100 sm_ring_f2[NB_RING_NODES_ASM_F2-1].buffer_address =
99 101 (int) &sm_f2[ (NB_RING_NODES_ASM_F2-1) * TOTAL_SIZE_SM ];
100 102
101 103 for(i=1; i<NB_RING_NODES_ASM_F2-1; i++)
102 104 {
103 105 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
104 106 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
105 107 sm_ring_f2[i].buffer_address =
106 108 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
107 109 }
108 110
109 111 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
110 112 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
111 113 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
112 114
113 115 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
114 116 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
115 117 }
116 118
117 119 void reset_current_sm_ring_nodes( void )
118 120 {
119 121 current_ring_node_sm_f0 = sm_ring_f0;
120 122 current_ring_node_sm_f1 = sm_ring_f1;
121 123 current_ring_node_sm_f2 = sm_ring_f2;
122 124
123 125 ring_node_for_averaging_sm_f0 = sm_ring_f0;
124 126 }
125 127
126 void reset_current_node_sbm1_bp1_f0( void )
128 void reset_current_bp_ring_nodes( void )
127 129 {
128 current_node_sbm1_bp1_f0 = bp_ring_sbm1;
130 current_node_sbm1_bp1_f0 = bp_ring_sbm1_bp1;
131 current_node_sbm1_bp2_f0 = bp_ring_sbm1_bp2;
129 132 }
130 133
131 134 //***********************************************************
132 135 // Interrupt Service Routine for spectral matrices processing
133 136 void reset_nb_sm_f0( void )
134 137 {
135 138 nb_sm_f0 = 0;
136 139 }
137 140
138 141 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
139 142 {
140 143 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
141 144
142 145 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
143 146 {
144 147 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
145 148 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
146 149 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
147 150 nb_sm_f0 = nb_sm_f0 + 1;
148 151 }
149 152 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
150 153 {
151 154 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
152 155 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
153 156 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
154 157 nb_sm_f0 = nb_sm_f0 + 1;
155 158 }
156 159
157 160 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
158 161 {
159 162 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
160 163 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
161 164 }
162 165
163 166 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
164 167
165 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
168 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
166 169 {
167 170 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
168 171 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
169 172 {
170 173 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
171 174 }
172 175 nb_sm_f0 = 0;
173 176 }
174 177 else
175 178 {
176 179 nb_sm_f0 = nb_sm_f0 + 1;
177 180 }
178 181 }
179 182
180 183 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
181 184 {
182 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
185 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
183 186 {
184 187 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
185 188 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
186 189 {
187 190 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
188 191 }
189 192 nb_sm_f0 = 0;
190 193 }
191 194 else
192 195 {
193 196 nb_sm_f0 = nb_sm_f0 + 1;
194 197 }
195 198 }
196 199
197 200 //************
198 201 // RTEMS TASKS
199 202
200 203 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
201 204 {
202 205 rtems_event_set event_out;
203 206
204 207 BOOT_PRINTF("in SMIQ *** \n")
205 208
206 209 while(1){
207 210 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
208 211 }
209 212 }
210 213
211 214 rtems_task avf0_task(rtems_task_argument argument)
212 215 {
213 216 int i;
214 static unsigned int nb_average_norm_f0;
215 static unsigned int nb_average_sbm1_f0;
217 static unsigned int nb_sm_norm_bp1_f0;
218 static unsigned int nb_sm_norm_bp2_f0;
219 static unsigned int nb_sm_norm_asm_f0;
220 static unsigned int nb_sm_sbm1_bp1_f0;
221 static unsigned int nb_sm_sbm1_bp2_f0;
216 222 rtems_event_set event_out;
223 rtems_event_set event_for_matr;
217 224 rtems_status_code status;
218 225 ring_node_sm *ring_node_tab[8];
219 226
220 nb_average_norm_f0 = 0;
221 nb_average_sbm1_f0 = 0;
227 nb_sm_norm_bp1_f0 = 0;
228 nb_sm_norm_bp2_f0 = 0;
229 nb_sm_norm_asm_f0 = 0;
230 nb_sm_sbm1_bp1_f0 = 0;
231 nb_sm_sbm1_bp2_f0 = 0;
222 232
223 233 BOOT_PRINTF("in AVFO *** \n")
224 234
225 235 while(1){
226 236 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
227 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
228 for ( i = 2; i < (NB_SM_TO_RECEIVE_BEFORE_AVF0+1); i++ )
237 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
238 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
229 239 {
230 240 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
231 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
241 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
232 242 }
233 243
234 244 // copy time information in the asm_f0 buffer
235 asm_f0[0] = ring_node_tab[7]->coarseTime;
236 asm_f0[1] = ring_node_tab[7]->fineTime;
237 averaged_sm_sbm1[0] = ring_node_tab[7]->coarseTime;
238 averaged_sm_sbm1[1] = ring_node_tab[7]->fineTime;
245 asm_norm_f0[0] = ring_node_tab[7]->coarseTime;
246 asm_norm_f0[1] = ring_node_tab[7]->fineTime;
247 asm_sbm1_f0[0] = ring_node_tab[7]->coarseTime;
248 asm_sbm1_f0[1] = ring_node_tab[7]->fineTime;
239 249
240 250 // compute the average and store it in the averaged_sm_f1 buffer
241 ASM_average( asm_f0, averaged_sm_sbm1,
251 SM_average( asm_norm_f0, asm_sbm1_f0,
242 252 ring_node_tab,
243 nb_average_norm_f0, nb_average_sbm1_f0 );
244
253 nb_sm_norm_bp1_f0, nb_sm_sbm1_bp1_f0 );
245 254
246 255 // update nb_average
247 nb_average_norm_f0 = nb_average_norm_f0 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
248 nb_average_sbm1_f0 = nb_average_sbm1_f0 + NB_SM_TO_RECEIVE_BEFORE_AVF0;
256 nb_sm_norm_bp1_f0 = nb_sm_norm_bp1_f0 + NB_SM_BEFORE_AVF0;
257 nb_sm_norm_bp2_f0 = nb_sm_norm_bp2_f0 + NB_SM_BEFORE_AVF0;
258 nb_sm_norm_asm_f0 = nb_sm_norm_asm_f0 + NB_SM_BEFORE_AVF0;
259 nb_sm_sbm1_bp1_f0 = nb_sm_sbm1_bp1_f0 + NB_SM_BEFORE_AVF0;
260 nb_sm_sbm1_bp2_f0 = nb_sm_sbm1_bp2_f0 + NB_SM_BEFORE_AVF0;
249 261
250 // launch actions depending on the current mode
262 //***********************************************************
263 // build a composite event that will be sent to the MATR task
264 event_for_matr = 0x00;
251 265
252 if (nb_average_sbm1_f0 == NB_AVERAGE_SBM1_F0)
266 if (nb_sm_sbm1_bp1_f0 == NB_SM_BEFORE_SBM1_BP1_F0)
253 267 {
254 nb_average_sbm1_f0 = 0;
268 nb_sm_sbm1_bp1_f0 = 0;
255 269 if (lfrCurrentMode == LFR_MODE_SBM1)
256 270 {
257 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_SBM1 ); // sending an event to the task 7, BPF0
258 if (status != RTEMS_SUCCESSFUL)
259 {
260 printf("in AVF0 *** Error sending RTEMS_EVENT_MODE_SBM1, code %d\n", status);
261 }
271 event_for_matr = event_for_matr | RTEMS_EVENT_SBM1_BP1_F0;
262 272 }
263 273 }
264 274
265 if (nb_average_norm_f0 == NB_AVERAGE_NORMAL_F0) {
266 nb_average_norm_f0 = 0;
267 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_MODE_NORMAL ); // sending an event to the task 7, BPF0
275 if (nb_sm_sbm1_bp2_f0 == NB_SM_BEFORE_SBM1_BP2_F0)
276 {
277 nb_sm_sbm1_bp2_f0 = 0;
278 if (lfrCurrentMode == LFR_MODE_SBM1)
279 {
280 event_for_matr = event_for_matr | RTEMS_EVENT_SBM1_BP2_F0;
281 }
282 }
283
284 if (nb_sm_norm_bp1_f0 == NB_SM_BEFORE_NORM_BP1_F0) {
285 nb_sm_norm_bp1_f0 = 0;
286 if (lfrCurrentMode == LFR_MODE_NORMAL)
287 {
288 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP1_F0;
289 }
290 }
291
292 if (nb_sm_norm_bp2_f0 == NB_SM_BEFORE_NORM_BP2_F0) {
293 nb_sm_norm_bp2_f0 = 0;
294 if (lfrCurrentMode == LFR_MODE_NORMAL)
295 {
296 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP2_F0;
297 }
298 }
299
300 if (nb_sm_norm_asm_f0 == NB_SM_BEFORE_NORM_ASM_F0) {
301 nb_sm_norm_asm_f0 = 0;
302 if (lfrCurrentMode == LFR_MODE_NORMAL)
303 {
304 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_ASM_F0;
305 }
306 }
307
308 //*********************************
309 // send the composite event to MATR
310 status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr );
268 311 if (status != RTEMS_SUCCESSFUL) {
269 312 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
270 313 }
271 314 }
272 315 }
273 }
274 316
275 317 rtems_task matr_task(rtems_task_argument argument)
276 318 {
277 319 spw_ioctl_pkt_send spw_ioctl_send_ASM;
278 320 rtems_event_set event_out;
279 321 rtems_status_code status;
280 322 rtems_id queue_id;
281 323 Header_TM_LFR_SCIENCE_ASM_t headerASM;
282 ring_node_norm_bp current_node_norm_bp1_f0;
324 ring_node_bp_with_spare current_node_norm_bp1_f0;
325 ring_node_bp current_node_norm_bp2_f0;
283 326
284 327 init_header_asm( &headerASM );
285 // init_header_bp( &current_node_norm_bp1_f0.header );
328 init_header_bp_with_spare( &current_node_norm_bp1_f0.header,
329 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
331 init_header_bp( &current_node_norm_bp2_f0.header,
332 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
333 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
286 334
287 335 status = get_message_queue_id_send( &queue_id );
288 336 if (status != RTEMS_SUCCESSFUL)
289 337 {
290 338 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
291 339 }
292 340
293 341 BOOT_PRINTF("in MATR *** \n")
294 342
295 343 while(1){
296 rtems_event_receive( RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1,
344 rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0
345 | RTEMS_EVENT_SBM1_BP1_F0 | RTEMS_EVENT_SBM1_BP2_F0,
297 346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
298 if (event_out==RTEMS_EVENT_MODE_NORMAL)
347 //*****
348 //*****
349 // SBM1
350 //*****
351 //*****
352 if (event_out & RTEMS_EVENT_SBM1_BP1_F0)
299 353 {
300 354 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( asm_f0, compressed_sm_f0,
302 NB_AVERAGE_NORMAL_F0,
355 ASM_compress_reorganize_and_divide( asm_sbm1_f0, compressed_sm_sbm1,
356 NB_SM_BEFORE_SBM1_BP1_F0,
357 NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0,
358 ASM_F0_INDICE_START);
359 // 2) compute the BP1 set
360
361 // 3) send the BP1 set
362 set_time( current_node_sbm1_bp1_f0->header.time,
363 current_node_sbm1_bp1_f0->coarseTime, current_node_sbm1_bp1_f0->fineTime);
364 set_time( current_node_sbm1_bp1_f0->header.acquisitionTime,
365 current_node_sbm1_bp1_f0->coarseTime, current_node_sbm1_bp1_f0->fineTime);
366 BP_send( (char *) &current_node_sbm1_bp1_f0->header, queue_id,
367 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + PACKET_LENGTH_DELTA);
368 // 4) update current_node_sbm1_bp1_f0
369 current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next;
370 if (event_out & RTEMS_EVENT_SBM1_BP2_F0)
371 {
372 // 1) compute the BP2 set
373
374 // 2) send the BP2 set
375 set_time( current_node_sbm1_bp2_f0->header.time,
376 current_node_sbm1_bp2_f0->coarseTime, current_node_sbm1_bp2_f0->fineTime);
377 set_time( current_node_sbm1_bp2_f0->header.acquisitionTime,
378 current_node_sbm1_bp2_f0->coarseTime, current_node_sbm1_bp2_f0->fineTime);
379 BP_send( (char *) &current_node_sbm1_bp2_f0->header, queue_id,
380 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 + PACKET_LENGTH_DELTA);
381 }
382 }
383
384 //*****
385 //*****
386 // NORM
387 //*****
388 //*****
389 if (event_out & RTEMS_EVENT_NORM_BP1_F0)
390 {
391 // 1) compress the matrix for Basic Parameters calculation
392 ASM_compress_reorganize_and_divide( asm_norm_f0, compressed_sm_norm_f0,
393 NB_SM_BEFORE_NORM_BP1_F0,
303 394 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 395 ASM_F0_INDICE_START );
305 396 // 2) compute the BP1 set
306 397
307 398 // 3) send the BP1 set
308 BP1_send( &current_node_norm_bp1_f0, SID_NORM_BP1_F0, queue_id );
309 // 4) reorganize the ASM and divide
310 ASM_reorganize_and_divide( asm_f0, asm_f0_reorganized, NB_AVERAGE_NORMAL_F0 );
311 // 5) convert the float array in a char array
399 set_time( current_node_norm_bp1_f0.header.time,
400 current_node_norm_bp1_f0.coarseTime, current_node_norm_bp1_f0.fineTime);
401 set_time( current_node_norm_bp1_f0.header.acquisitionTime,
402 current_node_norm_bp1_f0.coarseTime, current_node_norm_bp1_f0.fineTime);
403 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
404 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
405 if (event_out & RTEMS_EVENT_NORM_BP2_F0)
406 {
407 // 1) compute the BP2 set
408
409 // 2) send the BP2 set
410 set_time( current_node_norm_bp2_f0.header.time,
411 current_node_norm_bp2_f0.coarseTime, current_node_norm_bp2_f0.fineTime);
412 set_time( current_node_norm_bp2_f0.header.acquisitionTime,
413 current_node_norm_bp2_f0.coarseTime, current_node_norm_bp2_f0.fineTime);
414 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
415 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
416 }
417 }
418
419 if (event_out & RTEMS_EVENT_NORM_ASM_F0)
420 {
421 // 1) reorganize the ASM and divide
422 ASM_reorganize_and_divide( asm_norm_f0, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
423 // 2) convert the float array in a char array
312 424 ASM_convert( asm_f0_reorganized, asm_f0_char);
313 // 6) send the spectral matrix packets
425 // 3) send the spectral matrix packets
314 426 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
315 427 }
316 else if (event_out==RTEMS_EVENT_MODE_SBM1)
317 {
318 // 1) compress the matrix for Basic Parameters calculation
319 ASM_compress_reorganize_and_divide( averaged_sm_sbm1, compressed_sm_sbm1,
320 NB_AVERAGE_SBM1_F0,
321 NB_BINS_COMPRESSED_SM_SBM1_F0, NB_BINS_TO_AVERAGE_ASM_SBM1_F0,
322 ASM_F0_INDICE_START);
323 // 2) compute the BP1 set
324 428
325 // 3) send the basic parameters set 1 packet
326 BP1_send( current_node_sbm1_bp1_f0, SID_SBM1_BP1_F0, queue_id );
327 // 4) update current_node_sbm1_bp1_f0
328 current_node_sbm1_bp1_f0 = current_node_sbm1_bp1_f0->next;
329 }
330 else
331 {
332 PRINTF1("ERR *** in MATR *** unexect event = %x\n", (unsigned int) event_out)
333 }
334 429 }
335 430 }
336 431
337 432 //*****************************
338 433 // Spectral matrices processing
339 434
340 void ASM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
435 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
341 436 ring_node_sm *ring_node_tab[],
342 437 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
343 438 {
344 439 float sum;
345 440 unsigned int i;
346 441
347 442 for(i=0; i<TOTAL_SIZE_SM; i++)
348 443 {
349 444 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
350 445 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
351 446 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
352 447 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
353 448 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
354 449 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
355 450 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
356 451 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
357 452
358 453 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
359 454 {
360 455 averaged_spec_mat_f0[ TIME_OFFSET + i ] = sum;
361 456 averaged_spec_mat_f1[ TIME_OFFSET + i ] = sum;
362 457 }
363 458 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
364 459 {
365 460 averaged_spec_mat_f0[ TIME_OFFSET + i ] = ( averaged_spec_mat_f0[ TIME_OFFSET + i ] + sum );
366 461 averaged_spec_mat_f1[ TIME_OFFSET + i ] = ( averaged_spec_mat_f1[ TIME_OFFSET + i ] + sum );
367 462 }
368 463 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
369 464 {
370 465 averaged_spec_mat_f0[ TIME_OFFSET + i ] = ( averaged_spec_mat_f0[ TIME_OFFSET + i ] + sum );
371 466 averaged_spec_mat_f1[ TIME_OFFSET + i ] = sum;
372 467 }
373 468 else
374 469 {
375 PRINTF2("ERR *** in ASM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
470 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
376 471 }
377 472 }
378 473 }
379 474
380 475 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
381 476 {
382 477 int frequencyBin;
383 478 int asmComponent;
384 479
385 480 // copy the time information
386 481 averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ];
387 482 averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ];
388 483
389 484 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
390 485 {
391 486 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
392 487 {
393 488 averaged_spec_mat_reorganized[ TIME_OFFSET + frequencyBin * NB_VALUES_PER_SM + asmComponent ] =
394 489 averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ] / divider;
395 490 }
396 491 }
397 492 }
398 493
399 494 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
400 495 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
401 496 {
402 497 int frequencyBin;
403 498 int asmComponent;
404 499 int offsetASM;
405 500 int offsetCompressed;
406 501 int k;
407 502
408 503 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
409 504 {
410 505 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
411 506 {
412 507 offsetCompressed = TIME_OFFSET
413 508 + frequencyBin * NB_VALUES_PER_SM
414 509 + asmComponent;
415 510 offsetASM = TIME_OFFSET
416 511 + asmComponent * NB_BINS_PER_SM
417 512 + ASMIndexStart
418 513 + frequencyBin * nbBinsToAverage;
419 514 compressed_spec_mat[ offsetCompressed ] = 0;
420 515 for ( k = 0; k < nbBinsToAverage; k++ )
421 516 {
422 517 compressed_spec_mat[offsetCompressed ] =
423 518 ( compressed_spec_mat[ offsetCompressed ]
424 519 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
425 520 }
426 521 }
427 522 }
428 523 }
429 524
430 525 void ASM_convert( volatile float *input_matrix, char *output_matrix)
431 526 {
432 527 unsigned int i;
433 528 unsigned int frequencyBin;
434 529 unsigned int asmComponent;
435 530 char * pt_char_input;
436 531 char * pt_char_output;
437 532
438 533 pt_char_input = (char*) &input_matrix;
439 534 pt_char_output = (char*) &output_matrix;
440 535
441 536 // copy the time information
442 537 for (i=0; i<TIME_OFFSET_IN_BYTES; i++)
443 538 {
444 539 pt_char_output[ i ] = pt_char_output[ i ];
445 540 }
446 541
447 542 // convert all other data
448 543 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
449 544 {
450 545 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
451 546 {
452 547 pt_char_input = (char*) &input_matrix [ (frequencyBin*NB_VALUES_PER_SM) + asmComponent + TIME_OFFSET ];
453 548 pt_char_output = (char*) &output_matrix[ 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) + TIME_OFFSET_IN_BYTES ];
454 549 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
455 550 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
456 551 }
457 552 }
458 553 }
459 554
460 555 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
461 556 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
462 557 {
463 558 unsigned int i;
464 559 unsigned int length = 0;
465 560 rtems_status_code status;
466 561
467 562 for (i=0; i<2; i++)
468 563 {
469 564 // (1) BUILD THE DATA
470 565 switch(sid)
471 566 {
472 567 case SID_NORM_ASM_F0:
473 568 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
474 569 spw_ioctl_send->data = &spectral_matrix[
475 570 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
476 571 + TIME_OFFSET_IN_BYTES
477 572 ];
478 573 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
479 574 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
480 575 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
481 576 break;
482 577 case SID_NORM_ASM_F1:
483 578 break;
484 579 case SID_NORM_ASM_F2:
485 580 break;
486 581 default:
487 582 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
488 583 break;
489 584 }
490 585 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
491 586 spw_ioctl_send->hdr = (char *) header;
492 587 spw_ioctl_send->options = 0;
493 588
494 589 // (2) BUILD THE HEADER
495 590 header->packetLength[0] = (unsigned char) (length>>8);
496 591 header->packetLength[1] = (unsigned char) (length);
497 592 header->sid = (unsigned char) sid; // SID
498 593 header->pa_lfr_pkt_cnt_asm = 2;
499 594 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
500 595
501 596 // (3) SET PACKET TIME
502 597 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
503 598 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
504 599 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
505 600 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
506 601 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
507 602 header->time[5] = (unsigned char) (time_management_regs->fine_time);
508 603 //
509 604 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
510 605 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
511 606 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
512 607 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
513 608 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
514 609 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
515 610
516 611 // (4) SEND PACKET
517 612 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
518 613 if (status != RTEMS_SUCCESSFUL) {
519 614 printf("in ASM_send *** ERR %d\n", (int) status);
520 615 }
521 616 }
522 617 }
523 618
524 void BP1_send( ring_node_bp *ring_node_to_send, unsigned int sid, rtems_id queue_id )
525 {
526 unsigned int length = 0;
527 rtems_status_code status;
528 unsigned char nbBytesTosend;
529
530 // (1) BUILD THE DATA
531 switch(sid)
619 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
532 620 {
533 case SID_NORM_BP1_F0:
534 length = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0;
535 ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
536 ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
537 ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_F0) >> 8 ); // BLK_NR MSB
538 ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_F0); // BLK_NR LSB
539 nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0
540 + CCSDS_TC_TM_PACKET_OFFSET
541 + CCSDS_PROTOCOLE_EXTRA_BYTES;
542 case SID_SBM1_BP1_F0:
543 length = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0;
544 ring_node_to_send->header.packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
545 ring_node_to_send->header.packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
546 ring_node_to_send->header.pa_lfr_bp_blk_nr[0] = (unsigned char) ( (NB_BINS_COMPRESSED_SM_SBM1_F0) >> 8 ); // BLK_NR MSB
547 ring_node_to_send->header.pa_lfr_bp_blk_nr[1] = (unsigned char) (NB_BINS_COMPRESSED_SM_SBM1_F0); // BLK_NR LSB
548 nbBytesTosend = PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0
549 + CCSDS_TC_TM_PACKET_OFFSET
550 + CCSDS_PROTOCOLE_EXTRA_BYTES;
551 break;
552 default:
553 nbBytesTosend = 0;
554 PRINTF1("ERR *** in BP1_send *** unexpected sid %d\n", sid)
555 break;
556 }
621 rtems_status_code status;
557 622
558 // (2) BUILD THE HEADER
559 ring_node_to_send->header.packetLength[0] = (unsigned char) (length>>8);
560 ring_node_to_send->header.packetLength[1] = (unsigned char) (length);
561 ring_node_to_send->header.sid = sid;
562
563 // (3) SET PACKET TIME
564 ring_node_to_send->header.time[0] = (unsigned char) (ring_node_to_send->coarseTime>>24);
565 ring_node_to_send->header.time[1] = (unsigned char) (ring_node_to_send->coarseTime>>16);
566 ring_node_to_send->header.time[2] = (unsigned char) (ring_node_to_send->coarseTime>>8);
567 ring_node_to_send->header.time[3] = (unsigned char) (ring_node_to_send->coarseTime);
568 ring_node_to_send->header.time[4] = (unsigned char) (ring_node_to_send->fineTime>>8);
569 ring_node_to_send->header.time[5] = (unsigned char) (ring_node_to_send->fineTime);
570 //
571 ring_node_to_send->header.acquisitionTime[0] = (unsigned char) (ring_node_to_send->coarseTime>>24);
572 ring_node_to_send->header.acquisitionTime[1] = (unsigned char) (ring_node_to_send->coarseTime>>16);
573 ring_node_to_send->header.acquisitionTime[2] = (unsigned char) (ring_node_to_send->coarseTime>>8);
574 ring_node_to_send->header.acquisitionTime[3] = (unsigned char) (ring_node_to_send->coarseTime);
575 ring_node_to_send->header.acquisitionTime[4] = (unsigned char) (ring_node_to_send->fineTime>>8);
576 ring_node_to_send->header.acquisitionTime[5] = (unsigned char) (ring_node_to_send->fineTime);
577
578 // (4) SEND PACKET
579 status = rtems_message_queue_send( queue_id, &ring_node_to_send->header, nbBytesTosend);
623 // SEND PACKET
624 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
580 625 if (status != RTEMS_SUCCESSFUL)
581 626 {
582 printf("ERR *** in BP1_send *** ERR %d\n", (int) status);
627 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
583 628 }
584 629 }
585 630
586 631 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
587 632 {
588 633 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
589 634 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
590 635 header->reserved = 0x00;
591 636 header->userApplication = CCSDS_USER_APP;
592 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
593 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
637 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
638 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
594 639 header->packetSequenceControl[0] = 0xc0;
595 640 header->packetSequenceControl[1] = 0x00;
596 641 header->packetLength[0] = 0x00;
597 642 header->packetLength[1] = 0x00;
598 643 // DATA FIELD HEADER
599 644 header->spare1_pusVersion_spare2 = 0x10;
600 645 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
601 646 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
602 647 header->destinationID = TM_DESTINATION_ID_GROUND;
603 648 // AUXILIARY DATA HEADER
604 649 header->sid = 0x00;
605 650 header->biaStatusInfo = 0x00;
606 651 header->pa_lfr_pkt_cnt_asm = 0x00;
607 652 header->pa_lfr_pkt_nr_asm = 0x00;
608 653 header->time[0] = 0x00;
609 654 header->time[0] = 0x00;
610 655 header->time[0] = 0x00;
611 656 header->time[0] = 0x00;
612 657 header->time[0] = 0x00;
613 658 header->time[0] = 0x00;
614 659 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
615 660 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
616 661 }
617 662
618 void init_bp_ring_sbm1()
663 void init_bp_ring_sbm1_bp1( void )
664 {
665 unsigned int i;
666
667 //********
668 // F0 RING
669 bp_ring_sbm1_bp1[0].next = (ring_node_bp*) &bp_ring_sbm1_bp1[1];
670 bp_ring_sbm1_bp1[0].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1];
671
672 bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1].next = (ring_node_bp*) &bp_ring_sbm1_bp1[0];
673 bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-1].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[NB_RING_NODES_SBM1_BP1-2];
674
675 for(i=1; i<NB_RING_NODES_SBM1_BP1-1; i++)
676 {
677 bp_ring_sbm1_bp1[i].next = (ring_node_bp*) &bp_ring_sbm1_bp1[i+1];
678 bp_ring_sbm1_bp1[i].previous = (ring_node_bp*) &bp_ring_sbm1_bp1[i-1];
679 }
680 //
681 //********
682
683 for (i=0; i<NB_RING_NODES_SBM1_BP1; i++)
684 {
685 init_header_bp( &bp_ring_sbm1_bp1[ i ].header,
686 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
687 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0, NB_BINS_COMPRESSED_SM_SBM1_F0
688 );
689 bp_ring_sbm1_bp1[ i ].status = 0;
690 }
691 }
692
693 void init_bp_ring_sbm1_bp2( void )
619 694 {
620 695 unsigned int i;
621 696
622 697 //********
623 698 // F0 RING
624 bp_ring_sbm1[0].next = (ring_node_bp*) &bp_ring_sbm1[1];
625 bp_ring_sbm1[0].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1];
699 bp_ring_sbm1_bp2[0].next = (ring_node_bp*) &bp_ring_sbm1_bp2[1];
700 bp_ring_sbm1_bp2[0].previous = (ring_node_bp*) &bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-1];
626 701
627 bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].next = (ring_node_bp*) &bp_ring_sbm1[0];
628 bp_ring_sbm1[NB_RING_NODES_BP1_SBM1-1].previous = (ring_node_bp*) &bp_ring_sbm1[NB_RING_NODES_ASM_F0-2];
702 bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-1].next = (ring_node_bp*) &bp_ring_sbm1_bp2[0];
703 bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-1].previous = (ring_node_bp*) &bp_ring_sbm1_bp2[NB_RING_NODES_SBM1_BP2-2];
629 704
630 for(i=1; i<NB_RING_NODES_BP1_SBM1-1; i++)
705 for(i=1; i<NB_RING_NODES_SBM1_BP2-1; i++)
631 706 {
632 bp_ring_sbm1[i].next = (ring_node_bp*) &bp_ring_sbm1[i+1];
633 bp_ring_sbm1[i].previous = (ring_node_bp*) &bp_ring_sbm1[i-1];
707 bp_ring_sbm1_bp2[i].next = (ring_node_bp*) &bp_ring_sbm1_bp2[i+1];
708 bp_ring_sbm1_bp2[i].previous = (ring_node_bp*) &bp_ring_sbm1_bp2[i-1];
634 709 }
635 710 //
636 711 //********
637 712
638 for (i=0; i<NB_RING_NODES_BP1_SBM1; i++)
713 for (i=0; i<NB_RING_NODES_SBM1_BP2; i++)
639 714 {
640 init_header_bp( (Header_TM_LFR_SCIENCE_BP_SBM_t*) &bp_ring_sbm1[ i ] );
641 bp_ring_sbm1[ i ].status = 0;
715 init_header_bp( &bp_ring_sbm1_bp2[ i ].header,
716 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
717 PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP2_F0, NB_BINS_COMPRESSED_SM_SBM1_F0
718 );
719 bp_ring_sbm1_bp2[ i ].status = 0;
642 720 }
643 721 }
644 722
645 void init_header_bp(Header_TM_LFR_SCIENCE_BP_SBM_t *header )
723 void init_header_bp( Header_TM_LFR_SCIENCE_BP_t *header,
724 unsigned int apid, unsigned char sid,
725 unsigned int packetLength, unsigned char blkNr )
646 726 {
647 727 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
648 728 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
649 729 header->reserved = 0x00;
650 730 header->userApplication = CCSDS_USER_APP;
651 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
652 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
653 header->packetSequenceControl[0] = 0xc0;
731 header->packetID[0] = (unsigned char) (apid >> 8);
732 header->packetID[1] = (unsigned char) (apid);
733 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
654 734 header->packetSequenceControl[1] = 0x00;
655 header->packetLength[0] = 0x00;
656 header->packetLength[1] = 0x00;
735 header->packetLength[0] = (unsigned char) (packetLength >> 8);
736 header->packetLength[1] = (unsigned char) (packetLength);
657 737 // DATA FIELD HEADER
658 738 header->spare1_pusVersion_spare2 = 0x10;
659 739 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
660 740 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
661 741 header->destinationID = TM_DESTINATION_ID_GROUND;
662 742 // AUXILIARY DATA HEADER
663 header->sid = 0x00;
743 header->sid = sid;
664 744 header->biaStatusInfo = 0x00;
665 745 header->time[0] = 0x00;
666 746 header->time[0] = 0x00;
667 747 header->time[0] = 0x00;
668 748 header->time[0] = 0x00;
669 749 header->time[0] = 0x00;
670 750 header->time[0] = 0x00;
671 751 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
672 header->pa_lfr_bp_blk_nr[1] = 0x00; // BLK_NR LSB
752 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
753 }
754
755 void init_header_bp_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
756 unsigned int apid, unsigned char sid,
757 unsigned int packetLength , unsigned char blkNr)
758 {
759 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
760 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
761 header->reserved = 0x00;
762 header->userApplication = CCSDS_USER_APP;
763 header->packetID[0] = (unsigned char) (apid >> 8);
764 header->packetID[1] = (unsigned char) (apid);
765 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
766 header->packetSequenceControl[1] = 0x00;
767 header->packetLength[0] = (unsigned char) (packetLength >> 8);
768 header->packetLength[1] = (unsigned char) (packetLength);
769 // DATA FIELD HEADER
770 header->spare1_pusVersion_spare2 = 0x10;
771 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
772 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
773 header->destinationID = TM_DESTINATION_ID_GROUND;
774 // AUXILIARY DATA HEADER
775 header->sid = sid;
776 header->biaStatusInfo = 0x00;
777 header->time[0] = 0x00;
778 header->time[0] = 0x00;
779 header->time[0] = 0x00;
780 header->time[0] = 0x00;
781 header->time[0] = 0x00;
782 header->time[0] = 0x00;
783 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
784 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
673 785 }
674 786
675 787 void reset_spectral_matrix_regs( void )
676 788 {
677 789 /** This function resets the spectral matrices module registers.
678 790 *
679 791 * The registers affected by this function are located at the following offset addresses:
680 792 *
681 793 * - 0x00 config
682 794 * - 0x04 status
683 795 * - 0x08 matrixF0_Address0
684 796 * - 0x10 matrixFO_Address1
685 797 * - 0x14 matrixF1_Address
686 798 * - 0x18 matrixF2_Address
687 799 *
688 800 */
689 801
690 802 spectral_matrix_regs->config = 0x00;
691 803 spectral_matrix_regs->status = 0x00;
692 804
693 805 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
694 806 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
695 807 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
696 808 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
697 809 }
698 810
699 811 //******************
700 812 // general functions
701 813
814 void set_time( unsigned char *time, unsigned int coarseTime, unsigned int fineTime )
815 {
816 time[0] = (unsigned char) (coarseTime>>24);
817 time[1] = (unsigned char) (coarseTime>>16);
818 time[2] = (unsigned char) (coarseTime>>8);
819 time[3] = (unsigned char) (coarseTime);
820 time[4] = (unsigned char) (fineTime>>8);
821 time[5] = (unsigned char) (fineTime);
822 }
702 823
703 824
704
@@ -1,879 +1,881
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 60 if (status!=RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 63 }
64 64 else
65 65 {
66 66 subtype = TC.serviceSubType;
67 67 switch(subtype)
68 68 {
69 69 case TC_SUBTYPE_RESET:
70 70 result = action_reset( &TC, queue_snd_id, time );
71 71 close_action( &TC, result, queue_snd_id );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_COMM:
75 75 result = action_load_common_par( &TC );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_NORM:
80 80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 81 close_action( &TC, result, queue_snd_id );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_BURST:
85 85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 86 close_action( &TC, result, queue_snd_id );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM1:
90 90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 91 close_action( &TC, result, queue_snd_id );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_LOAD_SBM2:
95 95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_DUMP:
100 100 result = action_dump_par( queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id );
106 106 close_action( &TC, result, queue_snd_id );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_UPDT_INFO:
110 110 result = action_update_info( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_EN_CAL:
115 115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_DIS_CAL:
120 120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 121 close_action( &TC, result, queue_snd_id );
122 122 break;
123 123 //
124 124 case TC_SUBTYPE_UPDT_TIME:
125 125 result = action_update_time( &TC );
126 126 close_action( &TC, result, queue_snd_id );
127 127 break;
128 128 //
129 129 default:
130 130 break;
131 131 }
132 132 }
133 133 }
134 134 }
135 135
136 136 //***********
137 137 // TC ACTIONS
138 138
139 139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 140 {
141 141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 142 *
143 143 * @param TC points to the TeleCommand packet that is being processed
144 144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 145 *
146 146 */
147 147
148 148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 149 return LFR_DEFAULT;
150 150 }
151 151
152 152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
153 153 {
154 154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 155 *
156 156 * @param TC points to the TeleCommand packet that is being processed
157 157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 158 *
159 159 */
160 160
161 161 rtems_status_code status;
162 162 unsigned char requestedMode;
163 163 unsigned int *transitionCoarseTime_ptr;
164 164 unsigned int transitionCoarseTime;
165 165 unsigned char * bytePosPtr;
166 166
167 167 bytePosPtr = (unsigned char *) &TC->packetID;
168 168
169 169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
171 171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
172 172
173 173 status = check_mode_value( requestedMode );
174 174
175 175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
176 176 {
177 177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
178 178 }
179 179 else // the mode value is consistent, check the transition
180 180 {
181 181 status = check_mode_transition(requestedMode);
182 182 if (status != LFR_SUCCESSFUL)
183 183 {
184 184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
185 185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
186 186 }
187 187 }
188 188
189 189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
190 190 {
191 191 status = check_transition_date( transitionCoarseTime );
192 192 if (status != LFR_SUCCESSFUL)
193 193 {
194 194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
195 195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
198 198 }
199 199 }
200 200
201 201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
202 202 {
203 203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
204 204 status = enter_mode( requestedMode, transitionCoarseTime );
205 205 }
206 206
207 207 return status;
208 208 }
209 209
210 210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
211 211 {
212 212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
213 213 *
214 214 * @param TC points to the TeleCommand packet that is being processed
215 215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
216 216 *
217 217 * @return LFR directive status code:
218 218 * - LFR_DEFAULT
219 219 * - LFR_SUCCESSFUL
220 220 *
221 221 */
222 222
223 223 unsigned int val;
224 224 int result;
225 225 unsigned int status;
226 226 unsigned char mode;
227 227 unsigned char * bytePosPtr;
228 228
229 229 bytePosPtr = (unsigned char *) &TC->packetID;
230 230
231 231 // check LFR mode
232 232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
233 233 status = check_update_info_hk_lfr_mode( mode );
234 234 if (status == LFR_SUCCESSFUL) // check TDS mode
235 235 {
236 236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
237 237 status = check_update_info_hk_tds_mode( mode );
238 238 }
239 239 if (status == LFR_SUCCESSFUL) // check THR mode
240 240 {
241 241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
242 242 status = check_update_info_hk_thr_mode( mode );
243 243 }
244 244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
245 245 {
246 246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
247 247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
248 248 val++;
249 249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
250 250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
251 251 }
252 252
253 253 result = status;
254 254
255 255 return result;
256 256 }
257 257
258 258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 259 {
260 260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
261 261 *
262 262 * @param TC points to the TeleCommand packet that is being processed
263 263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
264 264 *
265 265 */
266 266
267 267 int result;
268 268 unsigned char lfrMode;
269 269
270 270 result = LFR_DEFAULT;
271 271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272 272
273 273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
274 274 result = LFR_DEFAULT;
275 275
276 276 return result;
277 277 }
278 278
279 279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 280 {
281 281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
282 282 *
283 283 * @param TC points to the TeleCommand packet that is being processed
284 284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
285 285 *
286 286 */
287 287
288 288 int result;
289 289 unsigned char lfrMode;
290 290
291 291 result = LFR_DEFAULT;
292 292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
293 293
294 294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
295 295 result = LFR_DEFAULT;
296 296
297 297 return result;
298 298 }
299 299
300 300 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 301 {
302 302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 303 *
304 304 * @param TC points to the TeleCommand packet that is being processed
305 305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 306 *
307 307 * @return LFR_SUCCESSFUL
308 308 *
309 309 */
310 310
311 311 unsigned int val;
312 312
313 313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 314 + (TC->dataAndCRC[1] << 16)
315 315 + (TC->dataAndCRC[2] << 8)
316 316 + TC->dataAndCRC[3];
317 317
318 318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
319 319
320 320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 322 val++;
323 323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326 326
327 327 return LFR_SUCCESSFUL;
328 328 }
329 329
330 330 //*******************
331 331 // ENTERING THE MODES
332 332 int check_mode_value( unsigned char requestedMode )
333 333 {
334 334 int status;
335 335
336 336 if ( (requestedMode != LFR_MODE_STANDBY)
337 337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
338 338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
339 339 {
340 340 status = LFR_DEFAULT;
341 341 }
342 342 else
343 343 {
344 344 status = LFR_SUCCESSFUL;
345 345 }
346 346
347 347 return status;
348 348 }
349 349
350 350 int check_mode_transition( unsigned char requestedMode )
351 351 {
352 352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
353 353 *
354 354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
355 355 *
356 356 * @return LFR directive status codes:
357 357 * - LFR_SUCCESSFUL - the transition is authorized
358 358 * - LFR_DEFAULT - the transition is not authorized
359 359 *
360 360 */
361 361
362 362 int status;
363 363
364 364 switch (requestedMode)
365 365 {
366 366 case LFR_MODE_STANDBY:
367 367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
368 368 status = LFR_DEFAULT;
369 369 }
370 370 else
371 371 {
372 372 status = LFR_SUCCESSFUL;
373 373 }
374 374 break;
375 375 case LFR_MODE_NORMAL:
376 376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
377 377 status = LFR_DEFAULT;
378 378 }
379 379 else {
380 380 status = LFR_SUCCESSFUL;
381 381 }
382 382 break;
383 383 case LFR_MODE_BURST:
384 384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
385 385 status = LFR_DEFAULT;
386 386 }
387 387 else {
388 388 status = LFR_SUCCESSFUL;
389 389 }
390 390 break;
391 391 case LFR_MODE_SBM1:
392 392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
393 393 status = LFR_DEFAULT;
394 394 }
395 395 else {
396 396 status = LFR_SUCCESSFUL;
397 397 }
398 398 break;
399 399 case LFR_MODE_SBM2:
400 400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
401 401 status = LFR_DEFAULT;
402 402 }
403 403 else {
404 404 status = LFR_SUCCESSFUL;
405 405 }
406 406 break;
407 407 default:
408 408 status = LFR_DEFAULT;
409 409 break;
410 410 }
411 411
412 412 return status;
413 413 }
414 414
415 415 int check_transition_date( unsigned int transitionCoarseTime )
416 416 {
417 417 int status;
418 418 unsigned int localCoarseTime;
419 419 unsigned int deltaCoarseTime;
420 420
421 421 status = LFR_SUCCESSFUL;
422 422
423 423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
424 424 {
425 425 status = LFR_SUCCESSFUL;
426 426 }
427 427 else
428 428 {
429 429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
430 430
431 431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
432 432 {
433 433 status = LFR_DEFAULT;
434 434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
435 435 }
436 436
437 437 if (status == LFR_SUCCESSFUL)
438 438 {
439 439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
440 440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
441 441 {
442 442 status = LFR_DEFAULT;
443 443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
444 444 }
445 445 }
446 446 }
447 447
448 448 return status;
449 449 }
450 450
451 451 int stop_current_mode( void )
452 452 {
453 453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
454 454 *
455 455 * @return RTEMS directive status codes:
456 456 * - RTEMS_SUCCESSFUL - task restarted successfully
457 457 * - RTEMS_INVALID_ID - task id invalid
458 458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
459 459 *
460 460 */
461 461
462 462 rtems_status_code status;
463 463
464 464 status = RTEMS_SUCCESSFUL;
465 465
466 466 // (1) mask interruptions
467 467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
468 468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469 469
470 470 // (2) clear interruptions
471 471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
472 472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
473 473
474 474 // (3) reset waveform picker registers
475 475 reset_wfp_burst_enable(); // reset burst and enable bits
476 476 reset_wfp_status(); // reset all the status bits
477 477
478 478 // (4) reset spectral matrices registers
479 479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
480 480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
481 481 reset_extractSWF(); // reset the extractSWF flag to false
482 482
483 483 // <Spectral Matrices simulator>
484 484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
485 485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
486 486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
487 487 // </Spectral Matrices simulator>
488 488
489 489 // suspend several tasks
490 490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
491 491 status = suspend_science_tasks();
492 492 }
493 493
494 494 if (status != RTEMS_SUCCESSFUL)
495 495 {
496 496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
497 497 }
498 498
499 499 return status;
500 500 }
501 501
502 502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
503 503 {
504 504 /** This function is launched after a mode transition validation.
505 505 *
506 506 * @param mode is the mode in which LFR will be put.
507 507 *
508 508 * @return RTEMS directive status codes:
509 509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
510 510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
511 511 *
512 512 */
513 513
514 514 rtems_status_code status;
515 515
516 516 //**********************
517 517 // STOP THE CURRENT MODE
518 518 status = stop_current_mode();
519 519 if (status != RTEMS_SUCCESSFUL)
520 520 {
521 521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
522 522 }
523 523
524 524 //*************************
525 525 // ENTER THE REQUESTED MODE
526 526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
527 527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
528 528 {
529 529 #ifdef PRINT_TASK_STATISTICS
530 530 rtems_cpu_usage_reset();
531 531 maxCount = 0;
532 532 #endif
533 533 status = restart_science_tasks();
534 534 launch_waveform_picker( mode, transitionCoarseTime );
535 535 launch_spectral_matrix_simu( mode );
536 536 }
537 537 else if ( mode == LFR_MODE_STANDBY )
538 538 {
539 539 #ifdef PRINT_TASK_STATISTICS
540 540 rtems_cpu_usage_report();
541 541 #endif
542 542
543 543 #ifdef PRINT_STACK_REPORT
544 544 rtems_stack_checker_report_usage();
545 545 #endif
546 546 PRINTF1("maxCount = %d\n", maxCount)
547 547 }
548 548 else
549 549 {
550 550 status = RTEMS_UNSATISFIED;
551 551 }
552 552
553 553 if (status != RTEMS_SUCCESSFUL)
554 554 {
555 555 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
556 556 status = RTEMS_UNSATISFIED;
557 557 }
558 558
559 559 return status;
560 560 }
561 561
562 562 int restart_science_tasks()
563 563 {
564 564 /** This function is used to restart all science tasks.
565 565 *
566 566 * @return RTEMS directive status codes:
567 567 * - RTEMS_SUCCESSFUL - task restarted successfully
568 568 * - RTEMS_INVALID_ID - task id invalid
569 569 * - RTEMS_INCORRECT_STATE - task never started
570 570 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
571 571 *
572 572 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
573 573 *
574 574 */
575 575
576 576 rtems_status_code status[6];
577 577 rtems_status_code ret;
578 578
579 579 ret = RTEMS_SUCCESSFUL;
580 580
581 581 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
582 582 if (status[0] != RTEMS_SUCCESSFUL)
583 583 {
584 584 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
585 585 }
586 586
587 587 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
588 588 if (status[2] != RTEMS_SUCCESSFUL)
589 589 {
590 590 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
591 591 }
592 592
593 593 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
594 594 if (status[3] != RTEMS_SUCCESSFUL)
595 595 {
596 596 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
597 597 }
598 598
599 599 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
600 600 if (status[4] != RTEMS_SUCCESSFUL)
601 601 {
602 602 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
603 603 }
604 604
605 605 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
606 606 if (status[5] != RTEMS_SUCCESSFUL)
607 607 {
608 608 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
609 609 }
610 610
611 611 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
612 612 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
613 613 {
614 614 ret = RTEMS_UNSATISFIED;
615 615 }
616 616
617 617 return ret;
618 618 }
619 619
620 620 int suspend_science_tasks()
621 621 {
622 622 /** This function suspends the science tasks.
623 623 *
624 624 * @return RTEMS directive status codes:
625 625 * - RTEMS_SUCCESSFUL - task restarted successfully
626 626 * - RTEMS_INVALID_ID - task id invalid
627 627 * - RTEMS_ALREADY_SUSPENDED - task already suspended
628 628 *
629 629 */
630 630
631 631 rtems_status_code status;
632 632
633 633 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
634 634 if (status != RTEMS_SUCCESSFUL)
635 635 {
636 636 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
637 637 }
638 638
639 639 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
640 640 {
641 641 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
642 642 if (status != RTEMS_SUCCESSFUL)
643 643 {
644 644 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
645 645 }
646 646 }
647 647
648 648 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
649 649 {
650 650 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
651 651 if (status != RTEMS_SUCCESSFUL)
652 652 {
653 653 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
654 654 }
655 655 }
656 656
657 657 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
658 658 {
659 659 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
660 660 if (status != RTEMS_SUCCESSFUL)
661 661 {
662 662 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
663 663 }
664 664 }
665 665
666 666 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
667 667 {
668 668 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
669 669 if (status != RTEMS_SUCCESSFUL)
670 670 {
671 671 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
672 672 }
673 673 }
674 674
675 675 return status;
676 676 }
677 677
678 678 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
679 679 {
680 680 reset_current_ring_nodes();
681 681 reset_waveform_picker_regs();
682 682 set_wfp_burst_enable_register( mode );
683 683
684 684 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
685 685 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
686 686
687 687 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
688 688 if (transitionCoarseTime == 0)
689 689 {
690 690 waveform_picker_regs->start_date = time_management_regs->coarse_time;
691 691 }
692 692 else
693 693 {
694 694 waveform_picker_regs->start_date = transitionCoarseTime;
695 695 }
696 696 }
697 697
698 698 void launch_spectral_matrix( unsigned char mode )
699 699 {
700 700 reset_nb_sm_f0();
701 701 reset_current_sm_ring_nodes();
702 reset_current_bp_ring_nodes();
702 703 reset_spectral_matrix_regs();
703 704
704 705 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
705 706 grgpio_regs->io_port_direction_register =
706 707 grgpio_regs->io_port_direction_register | 0x01; // [0001 1000], 0 = output disabled, 1 = output enabled
707 708 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x00; // set the bit 0 to 1
708 709 set_irq_on_new_ready_matrix( 1 );
709 710 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
710 711 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
711 712 set_run_matrix_spectral( 1 );
712 713
713 714 }
714 715
715 716 void set_irq_on_new_ready_matrix( unsigned char value )
716 717 {
717 718 if (value == 1)
718 719 {
719 720 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
720 721 }
721 722 else
722 723 {
723 724 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
724 725 }
725 726 }
726 727
727 728 void set_run_matrix_spectral( unsigned char value )
728 729 {
729 730 if (value == 1)
730 731 {
731 732 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
732 733 }
733 734 else
734 735 {
735 736 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
736 737 }
737 738 }
738 739
739 740 void launch_spectral_matrix_simu( unsigned char mode )
740 741 {
741 742 reset_nb_sm_f0();
742 743 reset_current_sm_ring_nodes();
744 reset_current_bp_ring_nodes();
743 745 reset_spectral_matrix_regs();
744 746
745 747 // Spectral Matrices simulator
746 748 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
747 749 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
748 750 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
749 751 set_local_nb_interrupt_f0_MAX();
750 752 }
751 753
752 754 //****************
753 755 // CLOSING ACTIONS
754 756 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
755 757 {
756 758 /** This function is used to update the HK packets statistics after a successful TC execution.
757 759 *
758 760 * @param TC points to the TC being processed
759 761 * @param time is the time used to date the TC execution
760 762 *
761 763 */
762 764
763 765 unsigned int val;
764 766
765 767 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
766 768 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
767 769 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
768 770 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
769 771 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
770 772 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
771 773 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
772 774 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
773 775 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
774 776 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
775 777 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
776 778 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
777 779
778 780 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
779 781 val++;
780 782 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
781 783 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
782 784 }
783 785
784 786 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
785 787 {
786 788 /** This function is used to update the HK packets statistics after a TC rejection.
787 789 *
788 790 * @param TC points to the TC being processed
789 791 * @param time is the time used to date the TC rejection
790 792 *
791 793 */
792 794
793 795 unsigned int val;
794 796
795 797 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
796 798 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
797 799 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
798 800 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
799 801 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
800 802 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
801 803 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
802 804 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
803 805 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
804 806 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
805 807 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
806 808 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
807 809
808 810 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
809 811 val++;
810 812 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
811 813 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
812 814 }
813 815
814 816 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
815 817 {
816 818 /** This function is the last step of the TC execution workflow.
817 819 *
818 820 * @param TC points to the TC being processed
819 821 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
820 822 * @param queue_id is the id of the RTEMS message queue used to send TM packets
821 823 * @param time is the time used to date the TC execution
822 824 *
823 825 */
824 826
825 827 unsigned char requestedMode;
826 828
827 829 if (result == LFR_SUCCESSFUL)
828 830 {
829 831 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
830 832 &
831 833 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
832 834 )
833 835 {
834 836 send_tm_lfr_tc_exe_success( TC, queue_id );
835 837 }
836 838 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
837 839 {
838 840 //**********************************
839 841 // UPDATE THE LFRMODE LOCAL VARIABLE
840 842 requestedMode = TC->dataAndCRC[1];
841 843 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
842 844 updateLFRCurrentMode();
843 845 }
844 846 }
845 847 else if (result == LFR_EXE_ERROR)
846 848 {
847 849 send_tm_lfr_tc_exe_error( TC, queue_id );
848 850 }
849 851 }
850 852
851 853 //***************************
852 854 // Interrupt Service Routines
853 855 rtems_isr commutation_isr1( rtems_vector_number vector )
854 856 {
855 857 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
856 858 printf("In commutation_isr1 *** Error sending event to DUMB\n");
857 859 }
858 860 }
859 861
860 862 rtems_isr commutation_isr2( rtems_vector_number vector )
861 863 {
862 864 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
863 865 printf("In commutation_isr2 *** Error sending event to DUMB\n");
864 866 }
865 867 }
866 868
867 869 //****************
868 870 // OTHER FUNCTIONS
869 871 void updateLFRCurrentMode()
870 872 {
871 873 /** This function updates the value of the global variable lfrCurrentMode.
872 874 *
873 875 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
874 876 *
875 877 */
876 878 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
877 879 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
878 880 }
879 881
@@ -1,539 +1,539
1 1 /** Functions to load and dump parameters in the LFR registers.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 7 * TC_LFR_LOAD_COMMON_PAR\n
8 8 * TC_LFR_LOAD_NORMAL_PAR\n
9 9 * TC_LFR_LOAD_BURST_PAR\n
10 10 * TC_LFR_LOAD_SBM1_PAR\n
11 11 * TC_LFR_LOAD_SBM2_PAR\n
12 12 *
13 13 */
14 14
15 15 #include "tc_load_dump_parameters.h"
16 16
17 17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 18 {
19 19 /** This function updates the LFR registers with the incoming common parameters.
20 20 *
21 21 * @param TC points to the TeleCommand packet that is being processed
22 22 *
23 23 *
24 24 */
25 25
26 26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 28 set_wfp_data_shaping( );
29 29 return LFR_SUCCESSFUL;
30 30 }
31 31
32 32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 33 {
34 34 /** This function updates the LFR registers with the incoming normal parameters.
35 35 *
36 36 * @param TC points to the TeleCommand packet that is being processed
37 37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 38 *
39 39 */
40 40
41 41 int result;
42 42 int flag;
43 43 rtems_status_code status;
44 44
45 45 flag = LFR_SUCCESSFUL;
46 46
47 47 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
48 48 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
49 49 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
50 50 flag = LFR_DEFAULT;
51 51 }
52 52
53 53 //***************
54 54 // sy_lfr_n_swf_l
55 55 if (flag == LFR_SUCCESSFUL)
56 56 {
57 57 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
58 58 if (result != LFR_SUCCESSFUL)
59 59 {
60 60 flag = LFR_DEFAULT;
61 61 }
62 62 }
63 63
64 64 //***************
65 65 // sy_lfr_n_swf_p
66 66 if (flag == LFR_SUCCESSFUL)
67 67 {
68 68 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
69 69 if (result != LFR_SUCCESSFUL)
70 70 {
71 71 flag = LFR_DEFAULT;
72 72 }
73 73 }
74 74
75 75 //***************
76 76 // sy_lfr_n_asm_p
77 77 if (flag == LFR_SUCCESSFUL)
78 78 {
79 79 result = set_sy_lfr_n_asm_p( TC, queue_id );
80 80 if (result != LFR_SUCCESSFUL)
81 81 {
82 82 flag = LFR_DEFAULT;
83 83 }
84 84 }
85 85
86 86 //***************
87 87 // sy_lfr_n_bp_p0
88 88 if (flag == LFR_SUCCESSFUL)
89 89 {
90 90 result = set_sy_lfr_n_bp_p0( TC, queue_id );
91 91 if (result != LFR_SUCCESSFUL)
92 92 {
93 93 flag = LFR_DEFAULT;
94 94 }
95 95 }
96 96
97 97 //***************
98 98 // sy_lfr_n_bp_p1
99 99 if (flag == LFR_SUCCESSFUL)
100 100 {
101 101 result = set_sy_lfr_n_bp_p1( TC, queue_id );
102 102 if (result != LFR_SUCCESSFUL)
103 103 {
104 104 flag = LFR_DEFAULT;
105 105 }
106 106 }
107 107
108 108 //*********************
109 109 // sy_lfr_n_cwf_long_f3
110 110 if (flag == LFR_SUCCESSFUL)
111 111 {
112 112 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
113 113 if (result != LFR_SUCCESSFUL)
114 114 {
115 115 flag = LFR_DEFAULT;
116 116 }
117 117 }
118 118
119 119 return flag;
120 120 }
121 121
122 122 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
123 123 {
124 124 /** This function updates the LFR registers with the incoming burst parameters.
125 125 *
126 126 * @param TC points to the TeleCommand packet that is being processed
127 127 * @param queue_id is the id of the queue which handles TM related to this execution step
128 128 *
129 129 */
130 130
131 131 int result;
132 132 unsigned char lfrMode;
133 133 rtems_status_code status;
134 134
135 135 result = LFR_DEFAULT;
136 136 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
137 137
138 138 if ( lfrMode == LFR_MODE_BURST ) {
139 139 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
140 140 result = LFR_DEFAULT;
141 141 }
142 142 else {
143 143 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
144 144 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
145 145
146 146 result = LFR_SUCCESSFUL;
147 147 }
148 148
149 149 return result;
150 150 }
151 151
152 152 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
153 153 {
154 154 /** This function updates the LFR registers with the incoming sbm1 parameters.
155 155 *
156 156 * @param TC points to the TeleCommand packet that is being processed
157 157 * @param queue_id is the id of the queue which handles TM related to this execution step
158 158 *
159 159 */
160 160 int result;
161 161 unsigned char lfrMode;
162 162 rtems_status_code status;
163 163
164 164 result = LFR_DEFAULT;
165 165 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
166 166
167 167 if ( lfrMode == LFR_MODE_SBM1 ) {
168 168 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
169 169 result = LFR_DEFAULT;
170 170 }
171 171 else {
172 172 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
173 173 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
174 174
175 175 result = LFR_SUCCESSFUL;
176 176 }
177 177
178 178 return result;
179 179 }
180 180
181 181 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
182 182 {
183 183 /** This function updates the LFR registers with the incoming sbm2 parameters.
184 184 *
185 185 * @param TC points to the TeleCommand packet that is being processed
186 186 * @param queue_id is the id of the queue which handles TM related to this execution step
187 187 *
188 188 */
189 189
190 190 int result;
191 191 unsigned char lfrMode;
192 192 rtems_status_code status;
193 193
194 194 result = LFR_DEFAULT;
195 195 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
196 196
197 197 if ( lfrMode == LFR_MODE_SBM2 ) {
198 198 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
199 199 result = LFR_DEFAULT;
200 200 }
201 201 else {
202 202 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
203 203 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
204 204
205 205 result = LFR_SUCCESSFUL;
206 206 }
207 207
208 208 return result;
209 209 }
210 210
211 211 int action_dump_par( rtems_id queue_id )
212 212 {
213 213 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
214 214 *
215 215 * @param queue_id is the id of the queue which handles TM related to this execution step.
216 216 *
217 217 * @return RTEMS directive status codes:
218 218 * - RTEMS_SUCCESSFUL - message sent successfully
219 219 * - RTEMS_INVALID_ID - invalid queue id
220 220 * - RTEMS_INVALID_SIZE - invalid message size
221 221 * - RTEMS_INVALID_ADDRESS - buffer is NULL
222 222 * - RTEMS_UNSATISFIED - out of message buffers
223 223 * - RTEMS_TOO_MANY - queue s limit has been reached
224 224 *
225 225 */
226 226
227 227 int status;
228 228
229 229 // UPDATE TIME
230 230 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
231 231 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
232 232 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
233 233 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
234 234 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
235 235 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
236 236 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
237 237 // SEND DATA
238 238 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
239 239 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
240 240 if (status != RTEMS_SUCCESSFUL) {
241 241 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
242 242 }
243 243
244 244 return status;
245 245 }
246 246
247 247 //***********************
248 248 // NORMAL MODE PARAMETERS
249 249
250 250 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
251 251 {
252 252 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
253 253 *
254 254 * @param TC points to the TeleCommand packet that is being processed
255 255 * @param queue_id is the id of the queue which handles TM related to this execution step
256 256 *
257 257 */
258 258
259 259 unsigned int tmp;
260 260 int result;
261 261 unsigned char msb;
262 262 unsigned char lsb;
263 263 rtems_status_code status;
264 264
265 265 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
266 266 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
267 267
268 268 tmp = ( unsigned int ) floor(
269 269 ( ( msb*256 ) + lsb ) / 16
270 270 ) * 16;
271 271
272 272 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
273 273 { // 2048 is the maximum limit due to the size of the buffers
274 274 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
275 275 result = WRONG_APP_DATA;
276 276 }
277 277 else if (tmp != 2048)
278 278 {
279 279 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
280 280 result = FUNCT_NOT_IMPL;
281 281 }
282 282 else
283 283 {
284 284 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
285 285 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
286 286 result = LFR_SUCCESSFUL;
287 287 }
288 288
289 289 return result;
290 290 }
291 291
292 292 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
293 293 {
294 294 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
295 295 *
296 296 * @param TC points to the TeleCommand packet that is being processed
297 297 * @param queue_id is the id of the queue which handles TM related to this execution step
298 298 *
299 299 */
300 300
301 301 unsigned int tmp;
302 302 int result;
303 303 unsigned char msb;
304 304 unsigned char lsb;
305 305 rtems_status_code status;
306 306
307 307 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
308 308 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
309 309
310 310 tmp = msb * 256 + lsb;
311 311
312 312 if ( tmp < 16 )
313 313 {
314 314 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
315 315 result = WRONG_APP_DATA;
316 316 }
317 317 else
318 318 {
319 319 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
320 320 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
321 321 result = LFR_SUCCESSFUL;
322 322 }
323 323
324 324 return result;
325 325 }
326 326
327 327 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
328 328 {
329 329 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
330 330 *
331 331 * @param TC points to the TeleCommand packet that is being processed
332 332 * @param queue_id is the id of the queue which handles TM related to this execution step
333 333 *
334 334 */
335 335
336 336 int result;
337 337 unsigned char msb;
338 338 unsigned char lsb;
339 339
340 340 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
341 341 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
342 342
343 343 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
344 344 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
345 345 result = LFR_SUCCESSFUL;
346 346
347 347 return result;
348 348 }
349 349
350 350 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
351 351 {
352 352 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
353 353 *
354 354 * @param TC points to the TeleCommand packet that is being processed
355 355 * @param queue_id is the id of the queue which handles TM related to this execution step
356 356 *
357 357 */
358 358
359 359 int status;
360 360
361 361 status = LFR_SUCCESSFUL;
362 362
363 363 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
364 364
365 365 return status;
366 366 }
367 367
368 368 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
369 369 {
370 370 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
371 371 *
372 372 * @param TC points to the TeleCommand packet that is being processed
373 373 * @param queue_id is the id of the queue which handles TM related to this execution step
374 374 *
375 375 */
376 376
377 377 int status;
378 378
379 379 status = LFR_SUCCESSFUL;
380 380
381 381 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
382 382
383 383 return status;
384 384 }
385 385
386 386 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
387 387 {
388 388 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
389 389 *
390 390 * @param TC points to the TeleCommand packet that is being processed
391 391 * @param queue_id is the id of the queue which handles TM related to this execution step
392 392 *
393 393 */
394 394
395 395 int status;
396 396
397 397 status = LFR_SUCCESSFUL;
398 398
399 399 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
400 400
401 401 return status;
402 402 }
403 403
404 404 //**********************
405 405 // BURST MODE PARAMETERS
406 406
407 407 //*********************
408 408 // SBM1 MODE PARAMETERS
409 409
410 410 //*********************
411 411 // SBM2 MODE PARAMETERS
412 412
413 413 //*******************
414 414 // TC_LFR_UPDATE_INFO
415 415 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
416 416 {
417 417 unsigned int status;
418 418
419 419 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
420 420 || (mode == LFR_MODE_BURST)
421 421 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
422 422 {
423 423 status = LFR_SUCCESSFUL;
424 424 }
425 425 else
426 426 {
427 427 status = LFR_DEFAULT;
428 428 }
429 429
430 430 return status;
431 431 }
432 432
433 433 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
434 434 {
435 435 unsigned int status;
436 436
437 437 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
438 438 || (mode == TDS_MODE_BURST)
439 439 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
440 440 || (mode == TDS_MODE_LFM))
441 441 {
442 442 status = LFR_SUCCESSFUL;
443 443 }
444 444 else
445 445 {
446 446 status = LFR_DEFAULT;
447 447 }
448 448
449 449 return status;
450 450 }
451 451
452 452 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
453 453 {
454 454 unsigned int status;
455 455
456 456 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
457 457 || (mode == THR_MODE_BURST))
458 458 {
459 459 status = LFR_SUCCESSFUL;
460 460 }
461 461 else
462 462 {
463 463 status = LFR_DEFAULT;
464 464 }
465 465
466 466 return status;
467 467 }
468 468
469 469 //**********
470 470 // init dump
471 471
472 472 void init_parameter_dump( void )
473 473 {
474 474 /** This function initialize the parameter_dump_packet global variable with default values.
475 475 *
476 476 */
477 477
478 478 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
479 479 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
480 480 parameter_dump_packet.reserved = CCSDS_RESERVED;
481 481 parameter_dump_packet.userApplication = CCSDS_USER_APP;
482 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
483 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
482 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
483 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
484 484 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
485 485 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
486 486 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
487 487 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
488 488 // DATA FIELD HEADER
489 489 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
490 490 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
491 491 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
492 492 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
493 493 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
494 494 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
495 495 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
496 496 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
497 497 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
498 498 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
499 499 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
500 500
501 501 //******************
502 502 // COMMON PARAMETERS
503 503 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
504 504 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
505 505
506 506 //******************
507 507 // NORMAL PARAMETERS
508 508 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
509 509 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
510 510 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
511 511 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
512 512 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
513 513 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
514 514 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
515 515 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
516 516 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
517 517
518 518 //*****************
519 519 // BURST PARAMETERS
520 520 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
521 521 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
522 522
523 523 //****************
524 524 // SBM1 PARAMETERS
525 525 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
526 526 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
527 527
528 528 //****************
529 529 // SBM2 PARAMETERS
530 530 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
531 531 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
532 532 }
533 533
534 534
535 535
536 536
537 537
538 538
539 539
@@ -1,511 +1,511
1 1 /** Functions to send TM packets related to TC parsing and execution.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to send appropriate TM packets after parsing and execution:
7 7 * - TM_LFR_TC_EXE_SUCCESS
8 8 * - TM_LFR_TC_EXE_INCONSISTENT
9 9 * - TM_LFR_TC_EXE_NOT_EXECUTABLE
10 10 * - TM_LFR_TC_EXE_NOT_IMPLEMENTED
11 11 * - TM_LFR_TC_EXE_ERROR
12 12 * - TM_LFR_TC_EXE_CORRUPTED
13 13 *
14 14 */
15 15
16 16 #include "tm_lfr_tc_exe.h"
17 17
18 18 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
19 19 {
20 20 /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue.
21 21 *
22 22 * @param TC points to the TeleCommand packet that is being processed
23 23 * @param queue_id is the id of the queue which handles TM
24 24 *
25 25 * @return RTEMS directive status code:
26 26 * - RTEMS_SUCCESSFUL - message sent successfully
27 27 * - RTEMS_INVALID_ID - invalid queue id
28 28 * - RTEMS_INVALID_SIZE - invalid message size
29 29 * - RTEMS_INVALID_ADDRESS - buffer is NULL
30 30 * - RTEMS_UNSATISFIED - out of message buffers
31 31 * - RTEMS_TOO_MANY - queue s limit has been reached
32 32 *
33 33 */
34 34
35 35 rtems_status_code status;
36 36 Packet_TM_LFR_TC_EXE_SUCCESS_t TM;
37 37 unsigned char messageSize;
38 38
39 39 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
40 40 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
41 41 TM.reserved = DEFAULT_RESERVED;
42 42 TM.userApplication = CCSDS_USER_APP;
43 43 // PACKET HEADER
44 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
45 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
44 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
45 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
46 46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
48 48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
49 49 // DATA FIELD HEADER
50 50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
51 51 TM.serviceType = TM_TYPE_TC_EXE;
52 52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
53 53 TM.destinationID = TC->sourceID;
54 54 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
55 55 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
56 56 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
57 57 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
58 58 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
59 59 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
60 60 //
61 61 TM.telecommand_pkt_id[0] = TC->packetID[0];
62 62 TM.telecommand_pkt_id[1] = TC->packetID[1];
63 63 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
64 64 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
65 65
66 66 messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
67 67
68 68 // SEND DATA
69 69 status = rtems_message_queue_send( queue_id, &TM, messageSize);
70 70 if (status != RTEMS_SUCCESSFUL) {
71 71 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
72 72 }
73 73
74 74 // UPDATE HK FIELDS
75 75 update_last_TC_exe( TC, TM.time );
76 76
77 77 return status;
78 78 }
79 79
80 80 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
81 81 unsigned char byte_position, unsigned char rcv_value )
82 82 {
83 83 /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue.
84 84 *
85 85 * @param TC points to the TeleCommand packet that is being processed
86 86 * @param queue_id is the id of the queue which handles TM
87 87 * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent
88 88 * @param rcv_value is the value of the LSB of the parameter that has been deteced as inconsistent
89 89 *
90 90 * @return RTEMS directive status code:
91 91 * - RTEMS_SUCCESSFUL - message sent successfully
92 92 * - RTEMS_INVALID_ID - invalid queue id
93 93 * - RTEMS_INVALID_SIZE - invalid message size
94 94 * - RTEMS_INVALID_ADDRESS - buffer is NULL
95 95 * - RTEMS_UNSATISFIED - out of message buffers
96 96 * - RTEMS_TOO_MANY - queue s limit has been reached
97 97 *
98 98 */
99 99
100 100 rtems_status_code status;
101 101 Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM;
102 102 unsigned char messageSize;
103 103
104 104 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
105 105 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
106 106 TM.reserved = DEFAULT_RESERVED;
107 107 TM.userApplication = CCSDS_USER_APP;
108 108 // PACKET HEADER
109 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
110 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
109 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
110 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
111 111 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
112 112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
113 113 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
114 114 // DATA FIELD HEADER
115 115 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
116 116 TM.serviceType = TM_TYPE_TC_EXE;
117 117 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
118 118 TM.destinationID = TC->sourceID;
119 119 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
120 120 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
121 121 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
122 122 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
123 123 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
124 124 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
125 125 //
126 126 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
127 127 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
128 128 TM.telecommand_pkt_id[0] = TC->packetID[0];
129 129 TM.telecommand_pkt_id[1] = TC->packetID[1];
130 130 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
131 131 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
132 132 TM.tc_service = TC->serviceType; // type of the rejected TC
133 133 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
134 134 TM.byte_position = byte_position;
135 135 TM.rcv_value = rcv_value;
136 136
137 137 messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
138 138
139 139 // SEND DATA
140 140 status = rtems_message_queue_send( queue_id, &TM, messageSize);
141 141 if (status != RTEMS_SUCCESSFUL) {
142 142 PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n")
143 143 }
144 144
145 145 // UPDATE HK FIELDS
146 146 update_last_TC_rej( TC, TM.time );
147 147
148 148 return status;
149 149 }
150 150
151 151 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
152 152 {
153 153 /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue.
154 154 *
155 155 * @param TC points to the TeleCommand packet that is being processed
156 156 * @param queue_id is the id of the queue which handles TM
157 157 *
158 158 * @return RTEMS directive status code:
159 159 * - RTEMS_SUCCESSFUL - message sent successfully
160 160 * - RTEMS_INVALID_ID - invalid queue id
161 161 * - RTEMS_INVALID_SIZE - invalid message size
162 162 * - RTEMS_INVALID_ADDRESS - buffer is NULL
163 163 * - RTEMS_UNSATISFIED - out of message buffers
164 164 * - RTEMS_TOO_MANY - queue s limit has been reached
165 165 *
166 166 */
167 167
168 168 rtems_status_code status;
169 169 Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM;
170 170 unsigned char messageSize;
171 171
172 172 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
173 173 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
174 174 TM.reserved = DEFAULT_RESERVED;
175 175 TM.userApplication = CCSDS_USER_APP;
176 176 // PACKET HEADER
177 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
178 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
177 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
178 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
179 179 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
180 180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
181 181 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
182 182 // DATA FIELD HEADER
183 183 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
184 184 TM.serviceType = TM_TYPE_TC_EXE;
185 185 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
186 186 TM.destinationID = TC->sourceID; // default destination id
187 187 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
188 188 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
189 189 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
190 190 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
191 191 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
192 192 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
193 193 //
194 194 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
195 195 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
196 196 TM.telecommand_pkt_id[0] = TC->packetID[0];
197 197 TM.telecommand_pkt_id[1] = TC->packetID[1];
198 198 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
199 199 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
200 200 TM.tc_service = TC->serviceType; // type of the rejected TC
201 201 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
202 202 TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0];
203 203 TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1];
204 204
205 205 messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
206 206
207 207 // SEND DATA
208 208 status = rtems_message_queue_send( queue_id, &TM, messageSize);
209 209 if (status != RTEMS_SUCCESSFUL) {
210 210 PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n")
211 211 }
212 212
213 213 // UPDATE HK FIELDS
214 214 update_last_TC_rej( TC, TM.time );
215 215
216 216 return status;
217 217 }
218 218
219 219 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
220 220 {
221 221 /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue.
222 222 *
223 223 * @param TC points to the TeleCommand packet that is being processed
224 224 * @param queue_id is the id of the queue which handles TM
225 225 *
226 226 * @return RTEMS directive status code:
227 227 * - RTEMS_SUCCESSFUL - message sent successfully
228 228 * - RTEMS_INVALID_ID - invalid queue id
229 229 * - RTEMS_INVALID_SIZE - invalid message size
230 230 * - RTEMS_INVALID_ADDRESS - buffer is NULL
231 231 * - RTEMS_UNSATISFIED - out of message buffers
232 232 * - RTEMS_TOO_MANY - queue s limit has been reached
233 233 *
234 234 */
235 235
236 236 rtems_status_code status;
237 237 Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM;
238 238 unsigned char messageSize;
239 239
240 240 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
241 241 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
242 242 TM.reserved = DEFAULT_RESERVED;
243 243 TM.userApplication = CCSDS_USER_APP;
244 244 // PACKET HEADER
245 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
246 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
245 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
246 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
247 247 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
248 248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
249 249 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
250 250 // DATA FIELD HEADER
251 251 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
252 252 TM.serviceType = TM_TYPE_TC_EXE;
253 253 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
254 254 TM.destinationID = TC->sourceID; // default destination id
255 255 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
256 256 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
257 257 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
258 258 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
259 259 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
260 260 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
261 261 //
262 262 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
263 263 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
264 264 TM.telecommand_pkt_id[0] = TC->packetID[0];
265 265 TM.telecommand_pkt_id[1] = TC->packetID[1];
266 266 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
267 267 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
268 268 TM.tc_service = TC->serviceType; // type of the rejected TC
269 269 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
270 270
271 271 messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
272 272
273 273 // SEND DATA
274 274 status = rtems_message_queue_send( queue_id, &TM, messageSize);
275 275 if (status != RTEMS_SUCCESSFUL) {
276 276 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
277 277 }
278 278
279 279 // UPDATE HK FIELDS
280 280 update_last_TC_rej( TC, TM.time );
281 281
282 282 return status;
283 283 }
284 284
285 285 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
286 286 {
287 287 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
288 288 *
289 289 * @param TC points to the TeleCommand packet that is being processed
290 290 * @param queue_id is the id of the queue which handles TM
291 291 *
292 292 * @return RTEMS directive status code:
293 293 * - RTEMS_SUCCESSFUL - message sent successfully
294 294 * - RTEMS_INVALID_ID - invalid queue id
295 295 * - RTEMS_INVALID_SIZE - invalid message size
296 296 * - RTEMS_INVALID_ADDRESS - buffer is NULL
297 297 * - RTEMS_UNSATISFIED - out of message buffers
298 298 * - RTEMS_TOO_MANY - queue s limit has been reached
299 299 *
300 300 */
301 301
302 302 rtems_status_code status;
303 303 Packet_TM_LFR_TC_EXE_ERROR_t TM;
304 304 unsigned char messageSize;
305 305
306 306 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
307 307 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
308 308 TM.reserved = DEFAULT_RESERVED;
309 309 TM.userApplication = CCSDS_USER_APP;
310 310 // PACKET HEADER
311 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
312 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
311 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
312 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
313 313 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
314 314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
315 315 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
316 316 // DATA FIELD HEADER
317 317 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
318 318 TM.serviceType = TM_TYPE_TC_EXE;
319 319 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
320 320 TM.destinationID = TC->sourceID; // default destination id
321 321 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
322 322 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
323 323 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
324 324 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
325 325 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
326 326 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
327 327 //
328 328 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
329 329 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
330 330 TM.telecommand_pkt_id[0] = TC->packetID[0];
331 331 TM.telecommand_pkt_id[1] = TC->packetID[1];
332 332 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
333 333 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
334 334 TM.tc_service = TC->serviceType; // type of the rejected TC
335 335 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
336 336
337 337 messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
338 338
339 339 // SEND DATA
340 340 status = rtems_message_queue_send( queue_id, &TM, messageSize);
341 341 if (status != RTEMS_SUCCESSFUL) {
342 342 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
343 343 }
344 344
345 345 // UPDATE HK FIELDS
346 346 update_last_TC_rej( TC, TM.time );
347 347
348 348 return status;
349 349 }
350 350
351 351 int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
352 352 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV,
353 353 unsigned char destinationID )
354 354 {
355 355 /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue.
356 356 *
357 357 * @param TC points to the TeleCommand packet that is being processed
358 358 * @param queue_id is the id of the queue which handles TM
359 359 * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand
360 360 * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data
361 361 *
362 362 * @return RTEMS directive status code:
363 363 * - RTEMS_SUCCESSFUL - message sent successfully
364 364 * - RTEMS_INVALID_ID - invalid queue id
365 365 * - RTEMS_INVALID_SIZE - invalid message size
366 366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 367 * - RTEMS_UNSATISFIED - out of message buffers
368 368 * - RTEMS_TOO_MANY - queue s limit has been reached
369 369 *
370 370 */
371 371
372 372 rtems_status_code status;
373 373 Packet_TM_LFR_TC_EXE_CORRUPTED_t TM;
374 374 unsigned char messageSize;
375 375 unsigned int packetLength;
376 376 unsigned char *packetDataField;
377 377
378 378 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter
379 379 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
380 380
381 381 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
382 382 TM.protocolIdentifier = CCSDS_PROTOCOLE_ID;
383 383 TM.reserved = DEFAULT_RESERVED;
384 384 TM.userApplication = CCSDS_USER_APP;
385 385 // PACKET HEADER
386 TM.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
387 TM.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
386 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
387 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
388 388 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
389 389 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
390 390 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
391 391 // DATA FIELD HEADER
392 392 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
393 393 TM.serviceType = TM_TYPE_TC_EXE;
394 394 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
395 395 TM.destinationID = destinationID;
396 396 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
397 397 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
398 398 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
399 399 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
400 400 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
401 401 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
402 402 //
403 403 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
404 404 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
405 405 TM.telecommand_pkt_id[0] = TC->packetID[0];
406 406 TM.telecommand_pkt_id[1] = TC->packetID[1];
407 407 TM.pkt_seq_control[0] = TC->packetSequenceControl[0];
408 408 TM.pkt_seq_control[1] = TC->packetSequenceControl[1];
409 409 TM.tc_service = TC->serviceType; // type of the rejected TC
410 410 TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC
411 411 TM.pkt_len_rcv_value[0] = TC->packetLength[0];
412 412 TM.pkt_len_rcv_value[1] = TC->packetLength[1];
413 413 TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
414 414 TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
415 415 TM.rcv_crc[0] = packetDataField[ packetLength - 1 ];
416 416 TM.rcv_crc[1] = packetDataField[ packetLength ];
417 417 TM.computed_crc[0] = computed_CRC[0];
418 418 TM.computed_crc[1] = computed_CRC[1];
419 419
420 420 messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
421 421
422 422 // SEND DATA
423 423 status = rtems_message_queue_send( queue_id, &TM, messageSize);
424 424 if (status != RTEMS_SUCCESSFUL) {
425 425 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
426 426 }
427 427
428 428 // UPDATE HK FIELDS
429 429 update_last_TC_rej( TC, TM.time );
430 430
431 431 return status;
432 432 }
433 433
434 434 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id )
435 435 {
436 436 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
437 437 *
438 438 * @param packet_sequence_control points to the packet sequence control which will be incremented
439 439 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
440 440 *
441 441 * If the destination ID is not known, a dedicated counter is incremented.
442 442 *
443 443 */
444 444
445 445 unsigned short sequence_cnt;
446 446 unsigned short segmentation_grouping_flag;
447 447 unsigned short new_packet_sequence_control;
448 448 unsigned char i;
449 449
450 450 switch (destination_id)
451 451 {
452 452 case SID_TC_GROUND:
453 453 i = GROUND;
454 454 break;
455 455 case SID_TC_MISSION_TIMELINE:
456 456 i = MISSION_TIMELINE;
457 457 break;
458 458 case SID_TC_TC_SEQUENCES:
459 459 i = TC_SEQUENCES;
460 460 break;
461 461 case SID_TC_RECOVERY_ACTION_CMD:
462 462 i = RECOVERY_ACTION_CMD;
463 463 break;
464 464 case SID_TC_BACKUP_MISSION_TIMELINE:
465 465 i = BACKUP_MISSION_TIMELINE;
466 466 break;
467 467 case SID_TC_DIRECT_CMD:
468 468 i = DIRECT_CMD;
469 469 break;
470 470 case SID_TC_SPARE_GRD_SRC1:
471 471 i = SPARE_GRD_SRC1;
472 472 break;
473 473 case SID_TC_SPARE_GRD_SRC2:
474 474 i = SPARE_GRD_SRC2;
475 475 break;
476 476 case SID_TC_OBCP:
477 477 i = OBCP;
478 478 break;
479 479 case SID_TC_SYSTEM_CONTROL:
480 480 i = SYSTEM_CONTROL;
481 481 break;
482 482 case SID_TC_AOCS:
483 483 i = AOCS;
484 484 break;
485 485 case SID_TC_RPW_INTERNAL:
486 486 i = RPW_INTERNAL;
487 487 break;
488 488 default:
489 489 i = GROUND;
490 490 break;
491 491 }
492 492
493 493 // increment the sequence counter
494 494 if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX )
495 495 {
496 496 sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1;
497 497 }
498 498 else
499 499 {
500 500 sequenceCounters_TC_EXE[ i ] = 0;
501 501 }
502 502
503 503 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
504 504 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
505 505
506 506 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
507 507
508 508 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
509 509 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
510 510
511 511 }
@@ -1,1351 +1,1351
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 //*****************
13 13 // waveform headers
14 14 // SWF
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 18 // CWF
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24 24
25 25 //**************
26 26 // waveform ring
27 27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 30 ring_node *current_ring_node_f0;
31 31 ring_node *ring_node_to_send_swf_f0;
32 32 ring_node *current_ring_node_f1;
33 33 ring_node *ring_node_to_send_swf_f1;
34 34 ring_node *ring_node_to_send_cwf_f1;
35 35 ring_node *current_ring_node_f2;
36 36 ring_node *ring_node_to_send_swf_f2;
37 37 ring_node *ring_node_to_send_cwf_f2;
38 38
39 39 bool extractSWF = false;
40 40 bool swf_f0_ready = false;
41 41 bool swf_f1_ready = false;
42 42 bool swf_f2_ready = false;
43 43
44 44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45 45
46 46 //*********************
47 47 // Interrupt SubRoutine
48 48
49 49 void reset_extractSWF( void )
50 50 {
51 51 extractSWF = false;
52 52 swf_f0_ready = false;
53 53 swf_f1_ready = false;
54 54 swf_f2_ready = false;
55 55 }
56 56
57 57 rtems_isr waveforms_isr( rtems_vector_number vector )
58 58 {
59 59 /** This is the interrupt sub routine called by the waveform picker core.
60 60 *
61 61 * This ISR launch different actions depending mainly on two pieces of information:
62 62 * 1. the values read in the registers of the waveform picker.
63 63 * 2. the current LFR mode.
64 64 *
65 65 */
66 66
67 67 rtems_status_code status;
68 68 static unsigned char nb_swf = 0;
69 69
70 70 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
71 71 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
72 72 { // in modes other than STANDBY and BURST, send the CWF_F3 data
73 73 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
74 74 // (1) change the receiving buffer for the waveform picker
75 75 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
76 76 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
77 77 }
78 78 else {
79 79 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
80 80 }
81 81 // (2) send an event for the waveforms transmission
82 82 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
83 83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
84 84 }
85 85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 86 }
87 87 }
88 88
89 89 switch(lfrCurrentMode)
90 90 {
91 91 //********
92 92 // STANDBY
93 93 case(LFR_MODE_STANDBY):
94 94 break;
95 95
96 96 //******
97 97 // NORMAL
98 98 case(LFR_MODE_NORMAL):
99 99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 100 {
101 101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 102 }
103 103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 104 {
105 105 // change F0 ring node
106 106 ring_node_to_send_swf_f0 = current_ring_node_f0;
107 107 current_ring_node_f0 = current_ring_node_f0->next;
108 108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
109 109 // change F1 ring node
110 110 ring_node_to_send_swf_f1 = current_ring_node_f1;
111 111 current_ring_node_f1 = current_ring_node_f1->next;
112 112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
113 113 // change F2 ring node
114 114 ring_node_to_send_swf_f2 = current_ring_node_f2;
115 115 current_ring_node_f2 = current_ring_node_f2->next;
116 116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
117 117 //
118 118 // if (nb_swf < 2)
119 119 if (true)
120 120 {
121 121 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
122 122 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
123 123 }
124 124 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
125 125 nb_swf = nb_swf + 1;
126 126 }
127 127 else
128 128 {
129 129 reset_wfp_burst_enable();
130 130 nb_swf = 0;
131 131 }
132 132
133 133 }
134 134
135 135 break;
136 136
137 137 //******
138 138 // BURST
139 139 case(LFR_MODE_BURST):
140 140 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
141 141 // (1) change the receiving buffer for the waveform picker
142 142 ring_node_to_send_cwf_f2 = current_ring_node_f2;
143 143 current_ring_node_f2 = current_ring_node_f2->next;
144 144 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
145 145 // (2) send an event for the waveforms transmission
146 146 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
147 147 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
148 148 }
149 149 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
150 150 }
151 151 break;
152 152
153 153 //*****
154 154 // SBM1
155 155 case(LFR_MODE_SBM1):
156 156 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
157 157 // (1) change the receiving buffer for the waveform picker
158 158 ring_node_to_send_cwf_f1 = current_ring_node_f1;
159 159 current_ring_node_f1 = current_ring_node_f1->next;
160 160 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
161 161 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
162 162 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
163 163 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
164 164 }
165 165 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
166 166 swf_f0_ready = true;
167 167 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
168 168 }
169 169 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
170 170 swf_f2_ready = true;
171 171 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
172 172 }
173 173 break;
174 174
175 175 //*****
176 176 // SBM2
177 177 case(LFR_MODE_SBM2):
178 178 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
179 179 // (1) change the receiving buffer for the waveform picker
180 180 ring_node_to_send_cwf_f2 = current_ring_node_f2;
181 181 current_ring_node_f2 = current_ring_node_f2->next;
182 182 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
183 183 // (2) send an event for the waveforms transmission
184 184 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
185 185 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
186 186 }
187 187 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
188 188 swf_f0_ready = true;
189 189 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
190 190 }
191 191 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
192 192 swf_f1_ready = true;
193 193 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
194 194 }
195 195 break;
196 196
197 197 //********
198 198 // DEFAULT
199 199 default:
200 200 break;
201 201 }
202 202 }
203 203
204 204 //************
205 205 // RTEMS TASKS
206 206
207 207 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
208 208 {
209 209 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
210 210 *
211 211 * @param unused is the starting argument of the RTEMS task
212 212 *
213 213 * The following data packets are sent by this task:
214 214 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
215 215 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
216 216 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
217 217 *
218 218 */
219 219
220 220 rtems_event_set event_out;
221 221 rtems_id queue_id;
222 222 rtems_status_code status;
223 223
224 224 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
225 225 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
226 226 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
227 227
228 228 init_waveforms();
229 229
230 230 status = get_message_queue_id_send( &queue_id );
231 231 if (status != RTEMS_SUCCESSFUL)
232 232 {
233 233 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
234 234 }
235 235
236 236 BOOT_PRINTF("in WFRM ***\n")
237 237
238 238 while(1){
239 239 // wait for an RTEMS_EVENT
240 240 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
241 241 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
242 242 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
243 243 if (event_out == RTEMS_EVENT_MODE_NORMAL)
244 244 {
245 245 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
246 246 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
247 247 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
248 248 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
249 249 }
250 250 if (event_out == RTEMS_EVENT_MODE_SBM1)
251 251 {
252 252 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
253 253 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
254 254 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
255 255 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
256 256 }
257 257 if (event_out == RTEMS_EVENT_MODE_SBM2)
258 258 {
259 259 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
260 260 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
261 261 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
262 262 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
263 263 }
264 264 }
265 265 }
266 266
267 267 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
268 268 {
269 269 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
270 270 *
271 271 * @param unused is the starting argument of the RTEMS task
272 272 *
273 273 * The following data packet is sent by this task:
274 274 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
275 275 *
276 276 */
277 277
278 278 rtems_event_set event_out;
279 279 rtems_id queue_id;
280 280 rtems_status_code status;
281 281
282 282 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
283 283 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
284 284
285 285 status = get_message_queue_id_send( &queue_id );
286 286 if (status != RTEMS_SUCCESSFUL)
287 287 {
288 288 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
289 289 }
290 290
291 291 BOOT_PRINTF("in CWF3 ***\n")
292 292
293 293 while(1){
294 294 // wait for an RTEMS_EVENT
295 295 rtems_event_receive( RTEMS_EVENT_0,
296 296 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
297 297 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
298 298 {
299 299 PRINTF("send CWF_LONG_F3\n")
300 300 }
301 301 else
302 302 {
303 303 PRINTF("send CWF_F3 (light)\n")
304 304 }
305 305 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
306 306 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
307 307 {
308 308 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
309 309 }
310 310 else
311 311 {
312 312 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
313 313 }
314 314 }
315 315 else
316 316 {
317 317 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
318 318 {
319 319 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
320 320 }
321 321 else
322 322 {
323 323 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
324 324 }
325 325
326 326 }
327 327 }
328 328 }
329 329
330 330 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
331 331 {
332 332 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
333 333 *
334 334 * @param unused is the starting argument of the RTEMS task
335 335 *
336 336 * The following data packet is sent by this function:
337 337 * - TM_LFR_SCIENCE_BURST_CWF_F2
338 338 * - TM_LFR_SCIENCE_SBM2_CWF_F2
339 339 *
340 340 */
341 341
342 342 rtems_event_set event_out;
343 343 rtems_id queue_id;
344 344 rtems_status_code status;
345 345
346 346 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
347 347 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
348 348
349 349 status = get_message_queue_id_send( &queue_id );
350 350 if (status != RTEMS_SUCCESSFUL)
351 351 {
352 352 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
353 353 }
354 354
355 355 BOOT_PRINTF("in CWF2 ***\n")
356 356
357 357 while(1){
358 358 // wait for an RTEMS_EVENT
359 359 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
360 360 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
361 361 if (event_out == RTEMS_EVENT_MODE_BURST)
362 362 {
363 363 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
364 364 }
365 365 if (event_out == RTEMS_EVENT_MODE_SBM2)
366 366 {
367 367 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
368 368 // launch snapshot extraction if needed
369 369 if (extractSWF == true)
370 370 {
371 371 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
372 372 // extract the snapshot
373 373 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
374 374 // send the snapshot when built
375 375 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
376 376 extractSWF = false;
377 377 }
378 378 if (swf_f0_ready && swf_f1_ready)
379 379 {
380 380 extractSWF = true;
381 381 swf_f0_ready = false;
382 382 swf_f1_ready = false;
383 383 }
384 384 }
385 385 }
386 386 }
387 387
388 388 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
389 389 {
390 390 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
391 391 *
392 392 * @param unused is the starting argument of the RTEMS task
393 393 *
394 394 * The following data packet is sent by this function:
395 395 * - TM_LFR_SCIENCE_SBM1_CWF_F1
396 396 *
397 397 */
398 398
399 399 rtems_event_set event_out;
400 400 rtems_id queue_id;
401 401 rtems_status_code status;
402 402
403 403 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
404 404
405 405 status = get_message_queue_id_send( &queue_id );
406 406 if (status != RTEMS_SUCCESSFUL)
407 407 {
408 408 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
409 409 }
410 410
411 411 BOOT_PRINTF("in CWF1 ***\n")
412 412
413 413 while(1){
414 414 // wait for an RTEMS_EVENT
415 415 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
416 416 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
417 417 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
418 418 // launch snapshot extraction if needed
419 419 if (extractSWF == true)
420 420 {
421 421 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
422 422 // launch the snapshot extraction
423 423 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
424 424 extractSWF = false;
425 425 }
426 426 if (swf_f0_ready == true)
427 427 {
428 428 extractSWF = true;
429 429 swf_f0_ready = false; // this step shall be executed only one time
430 430 }
431 431 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
432 432 {
433 433 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
434 434 swf_f1_ready = false;
435 435 swf_f2_ready = false;
436 436 }
437 437 }
438 438 }
439 439
440 440 rtems_task swbd_task(rtems_task_argument argument)
441 441 {
442 442 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
443 443 *
444 444 * @param unused is the starting argument of the RTEMS task
445 445 *
446 446 */
447 447
448 448 rtems_event_set event_out;
449 449
450 450 BOOT_PRINTF("in SWBD ***\n")
451 451
452 452 while(1){
453 453 // wait for an RTEMS_EVENT
454 454 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
455 455 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
456 456 if (event_out == RTEMS_EVENT_MODE_SBM1)
457 457 {
458 458 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
459 459 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
460 460 }
461 461 else
462 462 {
463 463 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
464 464 }
465 465 }
466 466 }
467 467
468 468 //******************
469 469 // general functions
470 470 void init_waveforms( void )
471 471 {
472 472 int i = 0;
473 473
474 474 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
475 475 {
476 476 //***
477 477 // F0
478 478 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
479 479 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
480 480 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
481 481
482 482 //***
483 483 // F1
484 484 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
485 485 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
486 486 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
487 487
488 488 //***
489 489 // F2
490 490 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
491 491 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
492 492 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
493 493
494 494 //***
495 495 // F3
496 496 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
497 497 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
498 498 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
499 499 }
500 500 }
501 501
502 502 void init_waveform_rings( void )
503 503 {
504 504 unsigned char i;
505 505
506 506 // F0 RING
507 507 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
508 508 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
509 509 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
510 510
511 511 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
512 512 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
513 513 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
514 514
515 515 for(i=1; i<NB_RING_NODES_F0-1; i++)
516 516 {
517 517 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
518 518 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
519 519 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
520 520 }
521 521
522 522 // F1 RING
523 523 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
524 524 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
525 525 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
526 526
527 527 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
528 528 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
529 529 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
530 530
531 531 for(i=1; i<NB_RING_NODES_F1-1; i++)
532 532 {
533 533 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
534 534 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
535 535 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
536 536 }
537 537
538 538 // F2 RING
539 539 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
540 540 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
541 541 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
542 542
543 543 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
544 544 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
545 545 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
546 546
547 547 for(i=1; i<NB_RING_NODES_F2-1; i++)
548 548 {
549 549 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
550 550 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
551 551 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
552 552 }
553 553
554 554 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
555 555 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
556 556 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
557 557
558 558 }
559 559
560 560 void reset_current_ring_nodes( void )
561 561 {
562 562 current_ring_node_f0 = waveform_ring_f0;
563 563 ring_node_to_send_swf_f0 = waveform_ring_f0;
564 564
565 565 current_ring_node_f1 = waveform_ring_f1;
566 566 ring_node_to_send_cwf_f1 = waveform_ring_f1;
567 567 ring_node_to_send_swf_f1 = waveform_ring_f1;
568 568
569 569 current_ring_node_f2 = waveform_ring_f2;
570 570 ring_node_to_send_cwf_f2 = waveform_ring_f2;
571 571 ring_node_to_send_swf_f2 = waveform_ring_f2;
572 572 }
573 573
574 574 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
575 575 {
576 576 unsigned char i;
577 577
578 578 for (i=0; i<7; i++)
579 579 {
580 580 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
581 581 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
582 582 headerSWF[ i ].reserved = DEFAULT_RESERVED;
583 583 headerSWF[ i ].userApplication = CCSDS_USER_APP;
584 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
585 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
584 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
585 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
586 586 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
587 587 if (i == 6)
588 588 {
589 589 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
590 590 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
591 591 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
592 592 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
593 593 }
594 594 else
595 595 {
596 596 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
597 597 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
598 598 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
599 599 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
600 600 }
601 601 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
602 602 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
603 603 headerSWF[ i ].pktNr = i+1; // PKT_NR
604 604 // DATA FIELD HEADER
605 605 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
606 606 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
607 607 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
608 608 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
609 609 // AUXILIARY DATA HEADER
610 610 headerSWF[ i ].time[0] = 0x00;
611 611 headerSWF[ i ].time[0] = 0x00;
612 612 headerSWF[ i ].time[0] = 0x00;
613 613 headerSWF[ i ].time[0] = 0x00;
614 614 headerSWF[ i ].time[0] = 0x00;
615 615 headerSWF[ i ].time[0] = 0x00;
616 616 headerSWF[ i ].sid = sid;
617 617 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
618 618 }
619 619 return LFR_SUCCESSFUL;
620 620 }
621 621
622 622 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
623 623 {
624 624 unsigned int i;
625 625
626 626 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
627 627 {
628 628 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
629 629 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
630 630 headerCWF[ i ].reserved = DEFAULT_RESERVED;
631 631 headerCWF[ i ].userApplication = CCSDS_USER_APP;
632 632 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
633 633 {
634 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
635 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
634 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
635 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
636 636 }
637 637 else
638 638 {
639 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
640 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
639 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
640 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
641 641 }
642 642 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
643 643 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
644 644 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
645 645 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
646 646 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
647 647 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
648 648 // DATA FIELD HEADER
649 649 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
650 650 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
651 651 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
652 652 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
653 653 // AUXILIARY DATA HEADER
654 654 headerCWF[ i ].sid = sid;
655 655 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
656 656 headerCWF[ i ].time[0] = 0x00;
657 657 headerCWF[ i ].time[0] = 0x00;
658 658 headerCWF[ i ].time[0] = 0x00;
659 659 headerCWF[ i ].time[0] = 0x00;
660 660 headerCWF[ i ].time[0] = 0x00;
661 661 headerCWF[ i ].time[0] = 0x00;
662 662 }
663 663 return LFR_SUCCESSFUL;
664 664 }
665 665
666 666 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
667 667 {
668 668 unsigned int i;
669 669
670 670 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
671 671 {
672 672 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
673 673 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
674 674 headerCWF[ i ].reserved = DEFAULT_RESERVED;
675 675 headerCWF[ i ].userApplication = CCSDS_USER_APP;
676 676
677 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
678 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
677 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
678 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
679 679
680 680 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
681 681 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
682 682 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
683 683 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
684 684 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
685 685
686 686 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
687 687 // DATA FIELD HEADER
688 688 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
689 689 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
690 690 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
691 691 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
692 692 // AUXILIARY DATA HEADER
693 693 headerCWF[ i ].sid = SID_NORM_CWF_F3;
694 694 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
695 695 headerCWF[ i ].time[0] = 0x00;
696 696 headerCWF[ i ].time[0] = 0x00;
697 697 headerCWF[ i ].time[0] = 0x00;
698 698 headerCWF[ i ].time[0] = 0x00;
699 699 headerCWF[ i ].time[0] = 0x00;
700 700 headerCWF[ i ].time[0] = 0x00;
701 701 }
702 702 return LFR_SUCCESSFUL;
703 703 }
704 704
705 705 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
706 706 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
707 707 {
708 708 /** This function sends SWF CCSDS packets (F2, F1 or F0).
709 709 *
710 710 * @param waveform points to the buffer containing the data that will be send.
711 711 * @param sid is the source identifier of the data that will be sent.
712 712 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
713 713 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
714 714 * contain information to setup the transmission of the data packets.
715 715 *
716 716 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
717 717 *
718 718 */
719 719
720 720 unsigned int i;
721 721 int ret;
722 722 unsigned int coarseTime;
723 723 unsigned int fineTime;
724 724 rtems_status_code status;
725 725 spw_ioctl_pkt_send spw_ioctl_send_SWF;
726 726
727 727 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
728 728 spw_ioctl_send_SWF.options = 0;
729 729
730 730 ret = LFR_DEFAULT;
731 731
732 732 coarseTime = waveform[0];
733 733 fineTime = waveform[1];
734 734
735 735 for (i=0; i<7; i++) // send waveform
736 736 {
737 737 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
738 738 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
739 739 // BUILD THE DATA
740 740 if (i==6) {
741 741 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
742 742 }
743 743 else {
744 744 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
745 745 }
746 746 // SET PACKET SEQUENCE COUNTER
747 747 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
748 748 // SET PACKET TIME
749 749 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
750 750 //
751 751 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
752 752 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
753 753 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
754 754 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
755 755 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
756 756 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
757 757 // SEND PACKET
758 758 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
759 759 if (status != RTEMS_SUCCESSFUL) {
760 760 printf("%d-%d, ERR %d\n", sid, i, (int) status);
761 761 ret = LFR_DEFAULT;
762 762 }
763 763 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
764 764 }
765 765
766 766 return ret;
767 767 }
768 768
769 769 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
770 770 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
771 771 {
772 772 /** This function sends CWF CCSDS packets (F2, F1 or F0).
773 773 *
774 774 * @param waveform points to the buffer containing the data that will be send.
775 775 * @param sid is the source identifier of the data that will be sent.
776 776 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
777 777 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
778 778 * contain information to setup the transmission of the data packets.
779 779 *
780 780 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
781 781 *
782 782 */
783 783
784 784 unsigned int i;
785 785 int ret;
786 786 unsigned int coarseTime;
787 787 unsigned int fineTime;
788 788 rtems_status_code status;
789 789 spw_ioctl_pkt_send spw_ioctl_send_CWF;
790 790
791 791 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
792 792 spw_ioctl_send_CWF.options = 0;
793 793
794 794 ret = LFR_DEFAULT;
795 795
796 796 coarseTime = waveform[0];
797 797 fineTime = waveform[1];
798 798
799 799 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
800 800 {
801 801 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
802 802 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
803 803 // BUILD THE DATA
804 804 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
805 805 // SET PACKET SEQUENCE COUNTER
806 806 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
807 807 // SET PACKET TIME
808 808 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
809 809 //
810 810 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
811 811 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
812 812 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
813 813 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
814 814 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
815 815 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
816 816 // SEND PACKET
817 817 if (sid == SID_NORM_CWF_LONG_F3)
818 818 {
819 819 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
820 820 if (status != RTEMS_SUCCESSFUL) {
821 821 printf("%d-%d, ERR %d\n", sid, i, (int) status);
822 822 ret = LFR_DEFAULT;
823 823 }
824 824 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
825 825 }
826 826 else
827 827 {
828 828 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
829 829 if (status != RTEMS_SUCCESSFUL) {
830 830 printf("%d-%d, ERR %d\n", sid, i, (int) status);
831 831 ret = LFR_DEFAULT;
832 832 }
833 833 }
834 834 }
835 835
836 836 return ret;
837 837 }
838 838
839 839 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
840 840 {
841 841 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
842 842 *
843 843 * @param waveform points to the buffer containing the data that will be send.
844 844 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
845 845 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
846 846 * contain information to setup the transmission of the data packets.
847 847 *
848 848 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
849 849 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
850 850 *
851 851 */
852 852
853 853 unsigned int i;
854 854 int ret;
855 855 unsigned int coarseTime;
856 856 unsigned int fineTime;
857 857 rtems_status_code status;
858 858 spw_ioctl_pkt_send spw_ioctl_send_CWF;
859 859 char *sample;
860 860
861 861 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
862 862 spw_ioctl_send_CWF.options = 0;
863 863
864 864 ret = LFR_DEFAULT;
865 865
866 866 //**********************
867 867 // BUILD CWF3_light DATA
868 868 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
869 869 {
870 870 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
871 871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
872 872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
873 873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
874 874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
875 875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
876 876 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
877 877 }
878 878
879 879 coarseTime = waveform[0];
880 880 fineTime = waveform[1];
881 881
882 882 //*********************
883 883 // SEND CWF3_light DATA
884 884 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
885 885 {
886 886 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
887 887 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
888 888 // BUILD THE DATA
889 889 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
890 890 // SET PACKET SEQUENCE COUNTER
891 891 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
892 892 // SET PACKET TIME
893 893 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
894 894 //
895 895 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
896 896 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
897 897 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
898 898 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
899 899 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
900 900 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
901 901 // SEND PACKET
902 902 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
903 903 if (status != RTEMS_SUCCESSFUL) {
904 904 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
905 905 ret = LFR_DEFAULT;
906 906 }
907 907 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
908 908 }
909 909
910 910 return ret;
911 911 }
912 912
913 913 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
914 914 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
915 915 {
916 916 unsigned long long int acquisitionTimeAsLong;
917 917 unsigned char localAcquisitionTime[6];
918 918 double deltaT;
919 919
920 920 deltaT = 0.;
921 921
922 922 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
923 923 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
924 924 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
925 925 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
926 926 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
927 927 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
928 928
929 929 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
930 930 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
931 931 + ( localAcquisitionTime[2] << 24 )
932 932 + ( localAcquisitionTime[3] << 16 )
933 933 + ( localAcquisitionTime[4] << 8 )
934 934 + ( localAcquisitionTime[5] );
935 935
936 936 switch( sid )
937 937 {
938 938 case SID_NORM_SWF_F0:
939 939 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
940 940 break;
941 941
942 942 case SID_NORM_SWF_F1:
943 943 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
944 944 break;
945 945
946 946 case SID_NORM_SWF_F2:
947 947 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
948 948 break;
949 949
950 950 case SID_SBM1_CWF_F1:
951 951 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
952 952 break;
953 953
954 954 case SID_SBM2_CWF_F2:
955 955 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
956 956 break;
957 957
958 958 case SID_BURST_CWF_F2:
959 959 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
960 960 break;
961 961
962 962 case SID_NORM_CWF_F3:
963 963 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
964 964 break;
965 965
966 966 case SID_NORM_CWF_LONG_F3:
967 967 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
968 968 break;
969 969
970 970 default:
971 971 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
972 972 deltaT = 0.;
973 973 break;
974 974 }
975 975
976 976 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
977 977 //
978 978 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
979 979 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
980 980 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
981 981 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
982 982 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
983 983 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
984 984
985 985 }
986 986
987 987 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
988 988 {
989 989 unsigned int i;
990 990 unsigned long long int centerTime_asLong;
991 991 unsigned long long int acquisitionTimeF0_asLong;
992 992 unsigned long long int acquisitionTime_asLong;
993 993 unsigned long long int bufferAcquisitionTime_asLong;
994 994 unsigned char *ptr1;
995 995 unsigned char *ptr2;
996 996 unsigned char nb_ring_nodes;
997 997 unsigned long long int frequency_asLong;
998 998 unsigned long long int nbTicksPerSample_asLong;
999 999 unsigned long long int nbSamplesPart1_asLong;
1000 1000 unsigned long long int sampleOffset_asLong;
1001 1001
1002 1002 unsigned int deltaT_F0;
1003 1003 unsigned int deltaT_F1;
1004 1004 unsigned long long int deltaT_F2;
1005 1005
1006 1006 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1007 1007 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1008 1008 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1009 1009 sampleOffset_asLong = 0x00;
1010 1010
1011 1011 // (1) get the f0 acquisition time
1012 1012 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1013 1013
1014 1014 // (2) compute the central reference time
1015 1015 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1016 1016
1017 1017 // (3) compute the acquisition time of the current snapshot
1018 1018 switch(frequencyChannel)
1019 1019 {
1020 1020 case 1: // 1 is for F1 = 4096 Hz
1021 1021 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1022 1022 nb_ring_nodes = NB_RING_NODES_F1;
1023 1023 frequency_asLong = 4096;
1024 1024 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1025 1025 break;
1026 1026 case 2: // 2 is for F2 = 256 Hz
1027 1027 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1028 1028 nb_ring_nodes = NB_RING_NODES_F2;
1029 1029 frequency_asLong = 256;
1030 1030 nbTicksPerSample_asLong = 256; // 65536 / 256;
1031 1031 break;
1032 1032 default:
1033 1033 acquisitionTime_asLong = centerTime_asLong;
1034 1034 frequency_asLong = 256;
1035 1035 nbTicksPerSample_asLong = 256;
1036 1036 break;
1037 1037 }
1038 1038
1039 1039 //****************************************************************************
1040 1040 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1041 1041 for (i=0; i<nb_ring_nodes; i++)
1042 1042 {
1043 1043 PRINTF1("%d ... ", i)
1044 1044 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1045 1045 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1046 1046 {
1047 1047 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1048 1048 break;
1049 1049 }
1050 1050 ring_node_to_send = ring_node_to_send->previous;
1051 1051 }
1052 1052
1053 1053 // (5) compute the number of samples to take in the current buffer
1054 1054 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1055 1055 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1056 1056 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1057 1057
1058 1058 // (6) compute the final acquisition time
1059 1059 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1060 1060 sampleOffset_asLong * nbTicksPerSample_asLong;
1061 1061
1062 1062 // (7) copy the acquisition time at the beginning of the extrated snapshot
1063 1063 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1064 1064 ptr2 = (unsigned char*) wf_snap_extracted;
1065 1065 ptr2[0] = ptr1[ 2 + 2 ];
1066 1066 ptr2[1] = ptr1[ 3 + 2 ];
1067 1067 ptr2[2] = ptr1[ 0 + 2 ];
1068 1068 ptr2[3] = ptr1[ 1 + 2 ];
1069 1069 ptr2[4] = ptr1[ 4 + 2 ];
1070 1070 ptr2[5] = ptr1[ 5 + 2 ];
1071 1071
1072 1072 // re set the synchronization bit
1073 1073
1074 1074
1075 1075 // copy the part 1 of the snapshot in the extracted buffer
1076 1076 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1077 1077 {
1078 1078 wf_snap_extracted[i + TIME_OFFSET] =
1079 1079 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1080 1080 }
1081 1081 // copy the part 2 of the snapshot in the extracted buffer
1082 1082 ring_node_to_send = ring_node_to_send->next;
1083 1083 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1084 1084 {
1085 1085 wf_snap_extracted[i + TIME_OFFSET] =
1086 1086 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1087 1087 }
1088 1088 }
1089 1089
1090 1090 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1091 1091 {
1092 1092 unsigned char *acquisitionTimeCharPtr;
1093 1093
1094 1094 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1095 1095
1096 1096 *acquisitionTimeAslong = 0x00;
1097 1097 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1098 1098 + ( acquisitionTimeCharPtr[1] << 16 )
1099 1099 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1100 1100 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1101 1101 + ( acquisitionTimeCharPtr[4] << 8 )
1102 1102 + ( acquisitionTimeCharPtr[5] );
1103 1103 }
1104 1104
1105 1105 //**************
1106 1106 // wfp registers
1107 1107 void reset_wfp_burst_enable(void)
1108 1108 {
1109 1109 /** This function resets the waveform picker burst_enable register.
1110 1110 *
1111 1111 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1112 1112 *
1113 1113 */
1114 1114
1115 1115 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1116 1116 }
1117 1117
1118 1118 void reset_wfp_status( void )
1119 1119 {
1120 1120 /** This function resets the waveform picker status register.
1121 1121 *
1122 1122 * All status bits are set to 0 [new_err full_err full].
1123 1123 *
1124 1124 */
1125 1125
1126 1126 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1127 1127 }
1128 1128
1129 1129 void reset_waveform_picker_regs(void)
1130 1130 {
1131 1131 /** This function resets the waveform picker module registers.
1132 1132 *
1133 1133 * The registers affected by this function are located at the following offset addresses:
1134 1134 * - 0x00 data_shaping
1135 1135 * - 0x04 run_burst_enable
1136 1136 * - 0x08 addr_data_f0
1137 1137 * - 0x0C addr_data_f1
1138 1138 * - 0x10 addr_data_f2
1139 1139 * - 0x14 addr_data_f3
1140 1140 * - 0x18 status
1141 1141 * - 0x1C delta_snapshot
1142 1142 * - 0x20 delta_f0
1143 1143 * - 0x24 delta_f0_2
1144 1144 * - 0x28 delta_f1
1145 1145 * - 0x2c delta_f2
1146 1146 * - 0x30 nb_data_by_buffer
1147 1147 * - 0x34 nb_snapshot_param
1148 1148 * - 0x38 start_date
1149 1149 * - 0x3c nb_word_in_buffer
1150 1150 *
1151 1151 */
1152 1152
1153 1153 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1154 1154 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1155 1155 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1156 1156 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1157 1157 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1158 1158 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1159 1159 reset_wfp_status(); // 0x18
1160 1160 //
1161 1161 set_wfp_delta_snapshot(); // 0x1c
1162 1162 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1163 1163 set_wfp_delta_f1(); // 0x28
1164 1164 set_wfp_delta_f2(); // 0x2c
1165 1165 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1166 1166 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1167 1167 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1168 1168 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1169 1169 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1170 1170 // 2688 = 8 * 336
1171 1171 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1172 1172 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1173 1173 waveform_picker_regs->start_date = 0x00; // 0x38
1174 1174 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1175 1175 }
1176 1176
1177 1177 void set_wfp_data_shaping( void )
1178 1178 {
1179 1179 /** This function sets the data_shaping register of the waveform picker module.
1180 1180 *
1181 1181 * The value is read from one field of the parameter_dump_packet structure:\n
1182 1182 * bw_sp0_sp1_r0_r1
1183 1183 *
1184 1184 */
1185 1185
1186 1186 unsigned char data_shaping;
1187 1187
1188 1188 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1189 1189 // waveform picker : [R1 R0 SP1 SP0 BW]
1190 1190
1191 1191 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1192 1192
1193 1193 waveform_picker_regs->data_shaping =
1194 1194 ( (data_shaping & 0x10) >> 4 ) // BW
1195 1195 + ( (data_shaping & 0x08) >> 2 ) // SP0
1196 1196 + ( (data_shaping & 0x04) ) // SP1
1197 1197 + ( (data_shaping & 0x02) << 2 ) // R0
1198 1198 + ( (data_shaping & 0x01) << 4 ); // R1
1199 1199 }
1200 1200
1201 1201 void set_wfp_burst_enable_register( unsigned char mode )
1202 1202 {
1203 1203 /** This function sets the waveform picker burst_enable register depending on the mode.
1204 1204 *
1205 1205 * @param mode is the LFR mode to launch.
1206 1206 *
1207 1207 * The burst bits shall be before the enable bits.
1208 1208 *
1209 1209 */
1210 1210
1211 1211 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1212 1212 // the burst bits shall be set first, before the enable bits
1213 1213 switch(mode) {
1214 1214 case(LFR_MODE_NORMAL):
1215 1215 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1216 1216 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1217 1217 break;
1218 1218 case(LFR_MODE_BURST):
1219 1219 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1220 1220 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1221 1221 break;
1222 1222 case(LFR_MODE_SBM1):
1223 1223 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1224 1224 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1225 1225 break;
1226 1226 case(LFR_MODE_SBM2):
1227 1227 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1228 1228 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1229 1229 break;
1230 1230 default:
1231 1231 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1232 1232 break;
1233 1233 }
1234 1234 }
1235 1235
1236 1236 void set_wfp_delta_snapshot( void )
1237 1237 {
1238 1238 /** This function sets the delta_snapshot register of the waveform picker module.
1239 1239 *
1240 1240 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1241 1241 * - sy_lfr_n_swf_p[0]
1242 1242 * - sy_lfr_n_swf_p[1]
1243 1243 *
1244 1244 */
1245 1245
1246 1246 unsigned int delta_snapshot;
1247 1247 unsigned int delta_snapshot_in_T2;
1248 1248
1249 1249 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1250 1250 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1251 1251
1252 1252 delta_snapshot_in_T2 = delta_snapshot * 256;
1253 1253 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1254 1254 }
1255 1255
1256 1256 void set_wfp_delta_f0_f0_2( void )
1257 1257 {
1258 1258 unsigned int delta_snapshot;
1259 1259 unsigned int nb_samples_per_snapshot;
1260 1260 float delta_f0_in_float;
1261 1261
1262 1262 delta_snapshot = waveform_picker_regs->delta_snapshot;
1263 1263 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1264 1264 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1265 1265
1266 1266 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1267 1267 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1268 1268 }
1269 1269
1270 1270 void set_wfp_delta_f1( void )
1271 1271 {
1272 1272 unsigned int delta_snapshot;
1273 1273 unsigned int nb_samples_per_snapshot;
1274 1274 float delta_f1_in_float;
1275 1275
1276 1276 delta_snapshot = waveform_picker_regs->delta_snapshot;
1277 1277 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1278 1278 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1279 1279
1280 1280 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1281 1281 }
1282 1282
1283 1283 void set_wfp_delta_f2()
1284 1284 {
1285 1285 unsigned int delta_snapshot;
1286 1286 unsigned int nb_samples_per_snapshot;
1287 1287
1288 1288 delta_snapshot = waveform_picker_regs->delta_snapshot;
1289 1289 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1290 1290
1291 1291 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1292 1292 }
1293 1293
1294 1294 //*****************
1295 1295 // local parameters
1296 1296 void set_local_nb_interrupt_f0_MAX( void )
1297 1297 {
1298 1298 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1299 1299 *
1300 1300 * This parameter is used for the SM validation only.\n
1301 1301 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1302 1302 * module before launching a basic processing.
1303 1303 *
1304 1304 */
1305 1305
1306 1306 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1307 1307 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1308 1308 }
1309 1309
1310 1310 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1311 1311 {
1312 1312 unsigned short *sequence_cnt;
1313 1313 unsigned short segmentation_grouping_flag;
1314 1314 unsigned short new_packet_sequence_control;
1315 1315
1316 1316 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1317 1317 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1318 1318 {
1319 1319 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1320 1320 }
1321 1321 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1322 1322 {
1323 1323 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1324 1324 }
1325 1325 else
1326 1326 {
1327 1327 sequence_cnt = NULL;
1328 1328 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1329 1329 }
1330 1330
1331 1331 if (sequence_cnt != NULL)
1332 1332 {
1333 1333 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1334 1334 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1335 1335
1336 1336 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1337 1337
1338 1338 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1339 1339 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1340 1340
1341 1341 // increment the sequence counter for the next packet
1342 1342 if ( *sequence_cnt < SEQ_CNT_MAX)
1343 1343 {
1344 1344 *sequence_cnt = *sequence_cnt + 1;
1345 1345 }
1346 1346 else
1347 1347 {
1348 1348 *sequence_cnt = 0;
1349 1349 }
1350 1350 }
1351 1351 }
General Comments 0
You need to be logged in to leave comments. Login now