##// END OF EJS Templates
the function asm_reorganize format the spectral matrix to the ICD format
paul -
r103:b24459a013ed VHDLib206
parent child
Show More
@@ -1,13 +1,13
1 1 #!/usr/bin/lppmon -e
2 2
3 proxy.loadSysDriver("RMAPPlugin","RMAPplugin0");
4 proxy.loadSysDriverToParent("dsu3plugin","RMAPplugin0");
3 proxy.loadSysDriver("RMAPPlugin","RMAPPlugin0");
4 proxy.loadSysDriverToParent("dsu3plugin","RMAPPlugin0");
5 5
6 6 #BUTTON_selectStarDundee.click()
7 7 BUTTON_selectGRESB.click()
8 BUTTON_rmapOpenCommunication.click()
8 9
9 BUTTON_rmapOpenCommunication.click()
10 10 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
11 11 dsu3plugin0.loadFile()
12 12 dsu3plugin0.run()
13 13
@@ -1,20 +1,21
1 1 #!/usr/bin/lppmon -e
2 2
3 3 address_to_read = 0x80000f08
4 4 val = RMAPPlugin0.Read( address_to_read, 1)
5 5 matrixF0_Address0 = val[0]
6 6 print hex(matrixF0_Address0)
7 7
8 8 # BUILD THE DATA
9 9 dataToWrite = []
10 for frequencyBin in range(128):
11 for component in range (25):
12 dataToWrite.append( component )
10 dataToWrite.append( 0x1234abcd )
11 dataToWrite.append( 0x4321dcba )
13 12
14 #for frequencyBin in range(64):
15 # for component in range (25):
16 # dataToWrite.append( 2 * component )
13 for component in range(25):
14 for frequencyBin in range (64):
15 dataToWrite.append( component + frequencyBin )
16 for frequencyBin in range (64):
17 dataToWrite.append( - (component + frequencyBin) )
17 18
18 19 # WRITE THE DATA
19 20 print len(dataToWrite)
20 21 RMAPPlugin0.Write( matrixF0_Address0, dataToWrite )
@@ -1,339 +1,339
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.0, 2014-02-21T15:56:03. -->
3 <!-- Written by QtCreator 3.0.0, 2014-03-03T07:03:32. -->
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,54 +1,55
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 #include "basic_parameters.h"
14 14
15 extern volatile int sm_f0[ ][ SM_HEADER + TOTAL_SIZE_SM ];
16 extern volatile int sm_f1[ ][ SM_HEADER + TOTAL_SIZE_SM ];
17 extern volatile int sm_f2[ ][ SM_HEADER + TOTAL_SIZE_SM ];
15 extern volatile int sm_f0[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
16 extern volatile int sm_f1[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
17 extern volatile int sm_f2[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
18 18
19 19 // parameters
20 20 extern struct param_local_str param_local;
21 21
22 22 // registers
23 23 extern time_management_regs_t *time_management_regs;
24 24 extern spectral_matrix_regs_t *spectral_matrix_regs;
25 25
26 26 extern rtems_name misc_name[5];
27 27 extern rtems_id Task_id[20]; /* array of task ids */
28 28
29 29 void init_sm_rings( void );
30 30 void reset_current_sm_ring_nodes( void );
31 31
32 32 // ISR
33 33 void reset_nb_sm_f0( void );
34 34 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
35 35 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
36 36
37 37 // RTEMS TASKS
38 38 rtems_task avf0_task(rtems_task_argument argument);
39 39 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
40 40 rtems_task matr_task(rtems_task_argument argument);
41 41
42 42 void matrix_reset(volatile float *averaged_spec_mat);
43 43 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
44 44 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
45 45 //
46 46 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
47 void compress_averaged_spectral_matrix( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
48 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
49 void send_averaged_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
47 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized );
48 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat );
49 void ASM_convert(volatile float *input_matrix, char *output_matrix);
50 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
50 51 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
51 52 void fill_averaged_spectral_matrix( void );
52 53 void reset_spectral_matrix_regs();
53 54
54 55 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,55 +1,58
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "tc_load_dump_parameters.h"
8 8 #include "tc_acceptance.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "wf_handler.h"
11 11 #include "fsw_processing.h"
12 12
13 13 // MODE PARAMETERS
14 14 extern unsigned int maxCount;
15 15
16 16 //****
17 17 // ISR
18 18 rtems_isr commutation_isr1( rtems_vector_number vector );
19 19 rtems_isr commutation_isr2( rtems_vector_number vector );
20 20
21 21 //***********
22 22 // RTEMS TASK
23 23 rtems_task actn_task( rtems_task_argument unused );
24 24
25 25 //***********
26 26 // TC ACTIONS
27 27 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
28 28 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
29 29 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
30 30 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 31 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 32 int action_update_time(ccsdsTelecommandPacket_t *TC);
33 33
34 34 // mode transition
35 35 int transition_validation(unsigned char requestedMode);
36 36 int stop_current_mode( void );
37 37 int enter_mode(unsigned char mode);
38 38 int restart_science_tasks();
39 39 int suspend_science_tasks();
40 40 void launch_waveform_picker( unsigned char mode );
41 41 void launch_spectral_matrix( unsigned char mode );
42 void enable_irq_on_new_ready_matrix( void );
43 void disable_irq_on_new_ready_matrix( void );
44 void launch_spectral_matrix_simu( unsigned char mode );
42 45
43 46 // other functions
44 47 void updateLFRCurrentMode();
45 48 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time);
46 49 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time);
47 50 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time);
48 51
49 52 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
50 53 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
51 54
52 55 #endif // TC_HANDLER_H_INCLUDED
53 56
54 57
55 58
@@ -1,72 +1,72
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
35 35 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
36 36 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
37 37 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
38 38 // F0
39 39 volatile int wf_snap_f0[ NB_RING_NODES_F0 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
40 40 // F1 F2
41 41 volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
42 42 volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 62 ] __attribute__((aligned(0x100)));
43 43 // F3
44 44 volatile int wf_cont_f3_a [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
45 45 volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
46 46 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
47 47
48 48 // SPECTRAL MATRICES GLOBAL VARIABLES
49 volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ SM_HEADER + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ SM_HEADER + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ SM_HEADER + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
49 volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ TIME_OFFSET + TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 52
53 53 // APB CONFIGURATION REGISTERS
54 54 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
55 55 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
56 56 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
57 57 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
58 58
59 59 // MODE PARAMETERS
60 60 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
61 61 struct param_local_str param_local;
62 62
63 63 // HK PACKETS
64 64 Packet_TM_LFR_HK_t housekeeping_packet;
65 65 // sequence counters are incremented by APID (PID + CAT) and destination ID
66 66 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
67 67 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
68 68 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
69 69 spw_stats spacewire_stats;
70 70 spw_stats spacewire_stats_backup;
71 71
72 72
@@ -1,594 +1,598
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
74 74 rtems_status_code status;
75 75 rtems_status_code status_spw;
76 76 rtems_isr_entry old_isr_handler;
77 77
78 78 // UART settings
79 79 send_console_outputs_on_apbuart_port();
80 80 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
81 81 enable_apbuart_transmitter();
82 82 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
83 83
84 84 PRINTF("\n\n\n\n\n")
85 85 PRINTF("*************************\n")
86 86 PRINTF("** LFR Flight Software **\n")
87 87 PRINTF1("** %d.", SW_VERSION_N1)
88 88 PRINTF1("%d.", SW_VERSION_N2)
89 89 PRINTF1("%d.", SW_VERSION_N3)
90 90 PRINTF1("%d **\n", SW_VERSION_N4)
91 91 PRINTF("*************************\n")
92 92 PRINTF("\n\n")
93 93
94 94 reset_wfp_burst_enable(); // stop the waveform picker if it was running
95 95 init_waveform_rings(); // initialize the waveform rings
96 96 init_sm_rings();
97 97
98 98 init_parameter_dump();
99 99 init_local_mode_parameters();
100 100 init_housekeeping_parameters();
101 101
102 102 updateLFRCurrentMode();
103 103
104 104 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
105 105
106 106 create_names(); // create all names
107 107
108 108 status = create_message_queues(); // create message queues
109 109 if (status != RTEMS_SUCCESSFUL)
110 110 {
111 111 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
112 112 }
113 113
114 114 status = create_all_tasks(); // create all tasks
115 115 if (status != RTEMS_SUCCESSFUL)
116 116 {
117 117 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
118 118 }
119 119
120 120 // **************************
121 121 // <SPACEWIRE INITIALIZATION>
122 122 grspw_timecode_callback = &timecode_irq_handler;
123 123
124 124 status_spw = spacewire_open_link(); // (1) open the link
125 125 if ( status_spw != RTEMS_SUCCESSFUL )
126 126 {
127 127 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
128 128 }
129 129
130 130 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
131 131 {
132 132 status_spw = spacewire_configure_link( fdSPW );
133 133 if ( status_spw != RTEMS_SUCCESSFUL )
134 134 {
135 135 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
136 136 }
137 137 }
138 138
139 139 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
140 140 {
141 141 status_spw = spacewire_start_link( fdSPW );
142 142 if ( status_spw != RTEMS_SUCCESSFUL )
143 143 {
144 144 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
145 145 }
146 146 }
147 147 // </SPACEWIRE INITIALIZATION>
148 148 // ***************************
149 149
150 150 status = start_all_tasks(); // start all tasks
151 151 if (status != RTEMS_SUCCESSFUL)
152 152 {
153 153 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
154 154 }
155 155
156 156 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
157 157 status = start_recv_send_tasks();
158 158 if ( status != RTEMS_SUCCESSFUL )
159 159 {
160 160 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
161 161 }
162 162
163 163 // suspend science tasks. they will be restarted later depending on the mode
164 164 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
165 165 if (status != RTEMS_SUCCESSFUL)
166 166 {
167 167 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
168 168 }
169 169
170 170 //******************************
171 171 // <SPECTRAL MATRICES SIMULATOR>
172 172 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
173 173 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
174 174 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
175 175 // </SPECTRAL MATRICES SIMULATOR>
176 176 //*******************************
177 177
178 178 // configure IRQ handling for the waveform picker unit
179 179 status = rtems_interrupt_catch( waveforms_isr,
180 180 IRQ_SPARC_WAVEFORM_PICKER,
181 181 &old_isr_handler) ;
182 // configure IRQ handling for the spectral matrices unit
183 status = rtems_interrupt_catch( spectral_matrices_isr,
184 IRQ_SPARC_SPECTRAL_MATRIX,
185 &old_isr_handler) ;
182 186
183 187 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
184 188 if ( status_spw != RTEMS_SUCCESSFUL )
185 189 {
186 190 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
187 191 if ( status != RTEMS_SUCCESSFUL ) {
188 192 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
189 193 }
190 194 }
191 195
192 196 BOOT_PRINTF("delete INIT\n")
193 197
194 198 status = rtems_task_delete(RTEMS_SELF);
195 199
196 200 }
197 201
198 202 void init_local_mode_parameters( void )
199 203 {
200 204 /** This function initialize the param_local global variable with default values.
201 205 *
202 206 */
203 207
204 208 unsigned int i;
205 209
206 210 // LOCAL PARAMETERS
207 211 set_local_nb_interrupt_f0_MAX();
208 212
209 213 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
210 214 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
211 215 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
212 216
213 217 // init sequence counters
214 218
215 219 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
216 220 {
217 221 sequenceCounters_TC_EXE[i] = 0x00;
218 222 }
219 223 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
220 224 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
221 225 }
222 226
223 227 void create_names( void ) // create all names for tasks and queues
224 228 {
225 229 /** This function creates all RTEMS names used in the software for tasks and queues.
226 230 *
227 231 * @return RTEMS directive status codes:
228 232 * - RTEMS_SUCCESSFUL - successful completion
229 233 *
230 234 */
231 235
232 236 // task names
233 237 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
234 238 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
235 239 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
236 240 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
237 241 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
238 242 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
239 243 // Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
240 244 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
241 245 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
242 246 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
243 247 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
244 248 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
245 249 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
246 250 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
247 251 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
248 252 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
249 253
250 254 // rate monotonic period names
251 255 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
252 256
253 257 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
254 258 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
255 259 }
256 260
257 261 int create_all_tasks( void ) // create all tasks which run in the software
258 262 {
259 263 /** This function creates all RTEMS tasks used in the software.
260 264 *
261 265 * @return RTEMS directive status codes:
262 266 * - RTEMS_SUCCESSFUL - task created successfully
263 267 * - RTEMS_INVALID_ADDRESS - id is NULL
264 268 * - RTEMS_INVALID_NAME - invalid task name
265 269 * - RTEMS_INVALID_PRIORITY - invalid task priority
266 270 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
267 271 * - RTEMS_TOO_MANY - too many tasks created
268 272 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
269 273 * - RTEMS_TOO_MANY - too many global objects
270 274 *
271 275 */
272 276
273 277 rtems_status_code status;
274 278
275 279 // RECV
276 280 status = rtems_task_create(
277 281 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
278 282 RTEMS_DEFAULT_MODES,
279 283 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
280 284 );
281 285
282 286 if (status == RTEMS_SUCCESSFUL) // ACTN
283 287 {
284 288 status = rtems_task_create(
285 289 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
286 290 RTEMS_DEFAULT_MODES,
287 291 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
288 292 );
289 293 }
290 294 if (status == RTEMS_SUCCESSFUL) // SPIQ
291 295 {
292 296 status = rtems_task_create(
293 297 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
294 298 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
295 299 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
296 300 );
297 301 }
298 302 if (status == RTEMS_SUCCESSFUL) // SMIQ
299 303 {
300 304 status = rtems_task_create(
301 305 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
302 306 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 307 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
304 308 );
305 309 }
306 310 if (status == RTEMS_SUCCESSFUL) // STAT
307 311 {
308 312 status = rtems_task_create(
309 313 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
310 314 RTEMS_DEFAULT_MODES,
311 315 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
312 316 );
313 317 }
314 318 if (status == RTEMS_SUCCESSFUL) // AVF0
315 319 {
316 320 status = rtems_task_create(
317 321 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
318 322 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
319 323 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
320 324 );
321 325 }
322 326 if (status == RTEMS_SUCCESSFUL) // WFRM
323 327 {
324 328 status = rtems_task_create(
325 329 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
326 330 RTEMS_DEFAULT_MODES,
327 331 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
328 332 );
329 333 }
330 334 if (status == RTEMS_SUCCESSFUL) // DUMB
331 335 {
332 336 status = rtems_task_create(
333 337 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
334 338 RTEMS_DEFAULT_MODES,
335 339 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
336 340 );
337 341 }
338 342 if (status == RTEMS_SUCCESSFUL) // HOUS
339 343 {
340 344 status = rtems_task_create(
341 345 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
342 346 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
343 347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
344 348 );
345 349 }
346 350 if (status == RTEMS_SUCCESSFUL) // MATR
347 351 {
348 352 status = rtems_task_create(
349 353 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
350 354 RTEMS_DEFAULT_MODES,
351 355 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
352 356 );
353 357 }
354 358 if (status == RTEMS_SUCCESSFUL) // CWF3
355 359 {
356 360 status = rtems_task_create(
357 361 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
358 362 RTEMS_DEFAULT_MODES,
359 363 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
360 364 );
361 365 }
362 366 if (status == RTEMS_SUCCESSFUL) // CWF2
363 367 {
364 368 status = rtems_task_create(
365 369 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
366 370 RTEMS_DEFAULT_MODES,
367 371 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
368 372 );
369 373 }
370 374 if (status == RTEMS_SUCCESSFUL) // CWF1
371 375 {
372 376 status = rtems_task_create(
373 377 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
374 378 RTEMS_DEFAULT_MODES,
375 379 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
376 380 );
377 381 }
378 382 if (status == RTEMS_SUCCESSFUL) // SEND
379 383 {
380 384 status = rtems_task_create(
381 385 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
382 386 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
383 387 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
384 388 );
385 389 }
386 390 if (status == RTEMS_SUCCESSFUL) // WTDG
387 391 {
388 392 status = rtems_task_create(
389 393 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
390 394 RTEMS_DEFAULT_MODES,
391 395 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
392 396 );
393 397 }
394 398
395 399 return status;
396 400 }
397 401
398 402 int start_recv_send_tasks( void )
399 403 {
400 404 rtems_status_code status;
401 405
402 406 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
403 407 if (status!=RTEMS_SUCCESSFUL) {
404 408 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
405 409 }
406 410
407 411 if (status == RTEMS_SUCCESSFUL) // SEND
408 412 {
409 413 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
410 414 if (status!=RTEMS_SUCCESSFUL) {
411 415 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
412 416 }
413 417 }
414 418
415 419 return status;
416 420 }
417 421
418 422 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
419 423 {
420 424 /** This function starts all RTEMS tasks used in the software.
421 425 *
422 426 * @return RTEMS directive status codes:
423 427 * - RTEMS_SUCCESSFUL - ask started successfully
424 428 * - RTEMS_INVALID_ADDRESS - invalid task entry point
425 429 * - RTEMS_INVALID_ID - invalid task id
426 430 * - RTEMS_INCORRECT_STATE - task not in the dormant state
427 431 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
428 432 *
429 433 */
430 434 // starts all the tasks fot eh flight software
431 435
432 436 rtems_status_code status;
433 437
434 438 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
435 439 if (status!=RTEMS_SUCCESSFUL) {
436 440 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
437 441 }
438 442
439 443 if (status == RTEMS_SUCCESSFUL) // WTDG
440 444 {
441 445 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
442 446 if (status!=RTEMS_SUCCESSFUL) {
443 447 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
444 448 }
445 449 }
446 450
447 451 if (status == RTEMS_SUCCESSFUL) // SMIQ
448 452 {
449 453 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
450 454 if (status!=RTEMS_SUCCESSFUL) {
451 455 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
452 456 }
453 457 }
454 458
455 459 if (status == RTEMS_SUCCESSFUL) // ACTN
456 460 {
457 461 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
458 462 if (status!=RTEMS_SUCCESSFUL) {
459 463 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
460 464 }
461 465 }
462 466
463 467 if (status == RTEMS_SUCCESSFUL) // STAT
464 468 {
465 469 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
466 470 if (status!=RTEMS_SUCCESSFUL) {
467 471 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
468 472 }
469 473 }
470 474
471 475 if (status == RTEMS_SUCCESSFUL) // AVF0
472 476 {
473 477 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
474 478 if (status!=RTEMS_SUCCESSFUL) {
475 479 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
476 480 }
477 481 }
478 482
479 483 if (status == RTEMS_SUCCESSFUL) // WFRM
480 484 {
481 485 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
482 486 if (status!=RTEMS_SUCCESSFUL) {
483 487 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
484 488 }
485 489 }
486 490
487 491 if (status == RTEMS_SUCCESSFUL) // DUMB
488 492 {
489 493 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
490 494 if (status!=RTEMS_SUCCESSFUL) {
491 495 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
492 496 }
493 497 }
494 498
495 499 if (status == RTEMS_SUCCESSFUL) // HOUS
496 500 {
497 501 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
498 502 if (status!=RTEMS_SUCCESSFUL) {
499 503 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
500 504 }
501 505 }
502 506
503 507 if (status == RTEMS_SUCCESSFUL) // MATR
504 508 {
505 509 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
506 510 if (status!=RTEMS_SUCCESSFUL) {
507 511 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
508 512 }
509 513 }
510 514
511 515 if (status == RTEMS_SUCCESSFUL) // CWF3
512 516 {
513 517 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
514 518 if (status!=RTEMS_SUCCESSFUL) {
515 519 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
516 520 }
517 521 }
518 522
519 523 if (status == RTEMS_SUCCESSFUL) // CWF2
520 524 {
521 525 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
522 526 if (status!=RTEMS_SUCCESSFUL) {
523 527 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
524 528 }
525 529 }
526 530
527 531 if (status == RTEMS_SUCCESSFUL) // CWF1
528 532 {
529 533 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
530 534 if (status!=RTEMS_SUCCESSFUL) {
531 535 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
532 536 }
533 537 }
534 538 return status;
535 539 }
536 540
537 541 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
538 542 {
539 543 rtems_status_code status_recv;
540 544 rtems_status_code status_send;
541 545 rtems_status_code ret;
542 546 rtems_id queue_id;
543 547
544 548 // create the queue for handling valid TCs
545 549 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
546 550 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
547 551 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
548 552 if ( status_recv != RTEMS_SUCCESSFUL ) {
549 553 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
550 554 }
551 555
552 556 // create the queue for handling TM packet sending
553 557 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
554 558 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
555 559 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
556 560 if ( status_send != RTEMS_SUCCESSFUL ) {
557 561 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
558 562 }
559 563
560 564 if ( status_recv != RTEMS_SUCCESSFUL )
561 565 {
562 566 ret = status_recv;
563 567 }
564 568 else
565 569 {
566 570 ret = status_send;
567 571 }
568 572
569 573 return ret;
570 574 }
571 575
572 576 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
573 577 {
574 578 rtems_status_code status;
575 579 rtems_name queue_name;
576 580
577 581 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
578 582
579 583 status = rtems_message_queue_ident( queue_name, 0, queue_id );
580 584
581 585 return status;
582 586 }
583 587
584 588 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
585 589 {
586 590 rtems_status_code status;
587 591 rtems_name queue_name;
588 592
589 593 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
590 594
591 595 status = rtems_message_queue_ident( queue_name, 0, queue_id );
592 596
593 597 return status;
594 598 }
@@ -1,343 +1,344
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
147 147 status = get_message_queue_id_send( &queue_id );
148 148 if (status != RTEMS_SUCCESSFUL)
149 149 {
150 150 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
151 151 }
152 152
153 153 BOOT_PRINTF("in HOUS ***\n")
154 154
155 155 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
156 156 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
157 157 if( status != RTEMS_SUCCESSFUL ) {
158 158 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
159 159 }
160 160 }
161 161
162 162 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
163 163 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
164 164 housekeeping_packet.reserved = DEFAULT_RESERVED;
165 165 housekeeping_packet.userApplication = CCSDS_USER_APP;
166 166 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
167 167 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
168 168 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
169 169 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
170 170 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
171 171 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
172 172 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
173 173 housekeeping_packet.serviceType = TM_TYPE_HK;
174 174 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
175 175 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
176 176 housekeeping_packet.sid = SID_HK;
177 177
178 178 status = rtems_rate_monotonic_cancel(HK_id);
179 179 if( status != RTEMS_SUCCESSFUL ) {
180 180 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
181 181 }
182 182 else {
183 183 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
184 184 }
185 185
186 186 while(1){ // launch the rate monotonic task
187 187 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
188 188 if ( status != RTEMS_SUCCESSFUL ) {
189 189 PRINTF1( "in HOUS *** ERR period: %d\n", status);
190 190 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
191 191 }
192 192 else {
193 193 increment_seq_counter( housekeeping_packet.packetSequenceControl );
194 194 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
195 195 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
196 196 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
197 197 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
198 198 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
199 199 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
200 200
201 201 spacewire_update_statistics();
202 202
203 203 // SEND PACKET
204 204 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
205 205 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
206 206 if (status != RTEMS_SUCCESSFUL) {
207 207 PRINTF1("in HOUS *** ERR send: %d\n", status)
208 208 }
209 209 }
210 210 }
211 211
212 212 PRINTF("in HOUS *** deleting task\n")
213 213
214 214 status = rtems_task_delete( RTEMS_SELF ); // should not return
215 215 printf( "rtems_task_delete returned with status of %d.\n", status );
216 216 return;
217 217 }
218 218
219 219 rtems_task dumb_task( rtems_task_argument unused )
220 220 {
221 221 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
222 222 *
223 223 * @param unused is the starting argument of the RTEMS task
224 224 *
225 225 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
226 226 *
227 227 */
228 228
229 229 unsigned int i;
230 230 unsigned int intEventOut;
231 231 unsigned int coarse_time = 0;
232 232 unsigned int fine_time = 0;
233 233 rtems_event_set event_out;
234 234
235 char *DumbMessages[8] = {"in DUMB *** default", // RTEMS_EVENT_0
235 char *DumbMessages[9] = {"in DUMB *** default", // RTEMS_EVENT_0
236 236 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
237 237 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
238 238 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
239 239 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
240 240 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
241 241 "ERR HK", // RTEMS_EVENT_6
242 "ready for dump" // RTEMS_EVENT_7
242 "ready for dump", // RTEMS_EVENT_7
243 "in DUMB *** spectral_matrices_isr" // RTEMS_EVENT_8
243 244 };
244 245
245 246 BOOT_PRINTF("in DUMB *** \n")
246 247
247 248 while(1){
248 249 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
249 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7,
250 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
251 | RTEMS_EVENT_8,
250 252 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
251 253 intEventOut = (unsigned int) event_out;
252 254 for ( i=0; i<32; i++)
253 255 {
254 256 if ( ((intEventOut >> i) & 0x0001) != 0)
255 257 {
256 258 coarse_time = time_management_regs->coarse_time;
257 259 fine_time = time_management_regs->fine_time;
258 260 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
259 PRINTF1("status = %x\n", waveform_picker_regs->status)
260 261 }
261 262 }
262 263 }
263 264 }
264 265
265 266 //*****************************
266 267 // init housekeeping parameters
267 268
268 269 void init_housekeeping_parameters( void )
269 270 {
270 271 /** This function initialize the housekeeping_packet global variable with default values.
271 272 *
272 273 */
273 274
274 275 unsigned int i = 0;
275 276 unsigned char *parameters;
276 277
277 278 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
278 279 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
279 280 {
280 281 parameters[i] = 0x00;
281 282 }
282 283 // init status word
283 284 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
284 285 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
285 286 // init software version
286 287 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
287 288 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
288 289 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
289 290 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
290 291 // init fpga version
291 292 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xd0);
292 293 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
293 294 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
294 295 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
295 296 }
296 297
297 298 void increment_seq_counter( unsigned char *packet_sequence_control)
298 299 {
299 300 /** This function increment the sequence counter psased in argument.
300 301 *
301 302 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
302 303 *
303 304 */
304 305
305 306 unsigned short sequence_cnt;
306 307 unsigned short segmentation_grouping_flag;
307 308 unsigned short new_packet_sequence_control;
308 309
309 310 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
310 311 sequence_cnt = (unsigned short) (
311 312 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
312 313 + packet_sequence_control[1]
313 314 );
314 315
315 316 if ( sequence_cnt < SEQ_CNT_MAX)
316 317 {
317 318 sequence_cnt = sequence_cnt + 1;
318 319 }
319 320 else
320 321 {
321 322 sequence_cnt = 0;
322 323 }
323 324
324 325 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
325 326
326 327 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
327 328 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
328 329 }
329 330
330 331 void getTime( unsigned char *time)
331 332 {
332 333 /** This function write the current local time in the time buffer passed in argument.
333 334 *
334 335 */
335 336
336 337 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
337 338 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
338 339 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
339 340 time[3] = (unsigned char) (time_management_regs->coarse_time);
340 341 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
341 342 time[5] = (unsigned char) (time_management_regs->fine_time);
342 343 }
343 344
@@ -1,679 +1,736
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_ring_f0[NB_RING_NODES_ASM_F0];
17 17 ring_node sm_ring_f1[NB_RING_NODES_ASM_F1];
18 18 ring_node sm_ring_f2[NB_RING_NODES_ASM_F2];
19 19 ring_node *current_ring_node_sm_f0;
20 20 ring_node *ring_node_for_averaging_sm_f0;
21 21 ring_node *current_ring_node_sm_f1;
22 22 ring_node *current_ring_node_sm_f2;
23 23
24 24 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
25 float averaged_sm_f0[ TOTAL_SIZE_SM ];
26 char averaged_sm_f0_char[ TOTAL_SIZE_SM * 2 ];
25 float averaged_sm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
26 float averaged_sm_f0_reorganized[ TIME_OFFSET + TOTAL_SIZE_SM ];
27 char averaged_sm_f0_char [ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_SM * 2 ];
27 28 float compressed_sm_f0[ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
28 29
29 30 unsigned int nb_sm_f0;
30 31
31 32 void init_sm_rings( void )
32 33 {
33 34 unsigned char i;
34 35
35 36 // F0 RING
36 37 sm_ring_f0[0].next = (ring_node*) &sm_ring_f0[1];
37 38 sm_ring_f0[0].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
38 39 sm_ring_f0[0].buffer_address = (int) &sm_f0[0][0];
39 40
40 41 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node*) &sm_ring_f0[0];
41 42 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
42 43 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address = (int) &sm_f0[NB_RING_NODES_ASM_F0-1][0];
43 44
44 45 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
45 46 {
46 47 sm_ring_f0[i].next = (ring_node*) &sm_ring_f0[i+1];
47 48 sm_ring_f0[i].previous = (ring_node*) &sm_ring_f0[i-1];
48 49 sm_ring_f0[i].buffer_address = (int) &sm_f0[i][0];
49 50 }
50 51
51 52 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
52 53
53 54 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
54 55 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
55 56 }
56 57
57 58 void reset_current_sm_ring_nodes( void )
58 59 {
59 60 current_ring_node_sm_f0 = sm_ring_f0;
60 61 ring_node_for_averaging_sm_f0 = sm_ring_f0;
61 62 }
62 63
63 64 //***********************************************************
64 65 // Interrupt Service Routine for spectral matrices processing
65 66 void reset_nb_sm_f0( void )
66 67 {
67 68 nb_sm_f0 = 0;
68 69 }
69 70
70 71 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
71 72 {
72 // unsigned char status;
73 // unsigned char i;
73 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
74
75 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
76 {
77 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
78 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
79 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
80 nb_sm_f0 = nb_sm_f0 + 1;
81 }
82 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
83 {
84 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
85 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
86 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
87 nb_sm_f0 = nb_sm_f0 + 1;
88 }
74 89
75 // status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0]
76 // for (i=0; i<4; i++)
77 // {
78 // if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation
79 // {
80 // switch(i)
81 // {
82 // case 0:
83 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
84 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
85 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
86 // nb_interrupt_f0 = nb_interrupt_f0 + 1;
87 // if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
88 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
89 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
90 // {
91 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
92 // }
93 // nb_interrupt_f0 = 0;
94 // }
95 // break;
96 // case 1:
97 // break;
98 // case 2:
99 // break;
100 // default:
101 // break;
102 // }
103 // }
104 // }
90 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
91 {
92 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
93 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
94 }
95
96 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
105 97
106 // // reset error codes to 0
107 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111]
98 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
99 {
100 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
101 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
102 {
103 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
104 }
105 nb_sm_f0 = 0;
106 }
107 else
108 {
109 nb_sm_f0 = nb_sm_f0 + 1;
110 }
108 111 }
109 112
110 113 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
111 114 {
115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
116
117 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
118 {
112 119 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
113 120 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
114 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
121 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
122 nb_sm_f0 = nb_sm_f0 + 1;
123 }
124 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
125 {
126 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
127 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
128 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
129 nb_sm_f0 = nb_sm_f0 + 1;
130 }
131
132 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
133 {
134 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
135 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
136 }
137
138 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
115 139
116 140 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
117 141 {
118 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
119 ring_node_for_averaging_sm_f0 = &sm_ring_f0[NB_SM_TO_RECEIVE_BEFORE_AVF0-1];
142 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
120 143 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
121 144 {
122 145 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
123 146 }
124 147 nb_sm_f0 = 0;
125 148 }
126 149 else
127 150 {
128 151 nb_sm_f0 = nb_sm_f0 + 1;
129 152 }
130 153 }
131 154
132 155 //************
133 156 // RTEMS TASKS
134 157
135 158 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
136 159 {
137 160 rtems_event_set event_out;
138 161
139 162 BOOT_PRINTF("in SMIQ *** \n")
140 163
141 164 while(1){
142 165 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
143 166 }
144 167 }
145 168
146 169 rtems_task avf0_task(rtems_task_argument argument)
147 170 {
148 171 int i;
149 172 static int nb_average;
150 173 rtems_event_set event_out;
151 174 rtems_status_code status;
152 175 ring_node *ring_node_tab[8];
153 176
154 177 nb_average = 0;
155 178
156 179 BOOT_PRINTF("in AVFO *** \n")
157 180
158 181 while(1){
159 182 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
160 183 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
161 184 for (i=2; i<NB_SM_TO_RECEIVE_BEFORE_AVF0+1; i++)
162 185 {
163 186 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
164 187 ring_node_tab[NB_SM_TO_RECEIVE_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
165 188 }
166 189 for(i=0; i<TOTAL_SIZE_SM; i++)
167 190 {
168 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i]
169 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i]
170 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i]
171 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i]
172 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i]
173 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i]
174 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i]
175 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i];
191 averaged_sm_f0[i] = ( (int *) (ring_node_tab[0]->buffer_address) ) [i + TIME_OFFSET]
192 + ( (int *) (ring_node_tab[1]->buffer_address) ) [i + TIME_OFFSET]
193 + ( (int *) (ring_node_tab[2]->buffer_address) ) [i + TIME_OFFSET]
194 + ( (int *) (ring_node_tab[3]->buffer_address) ) [i + TIME_OFFSET]
195 + ( (int *) (ring_node_tab[4]->buffer_address) ) [i + TIME_OFFSET]
196 + ( (int *) (ring_node_tab[5]->buffer_address) ) [i + TIME_OFFSET]
197 + ( (int *) (ring_node_tab[6]->buffer_address) ) [i + TIME_OFFSET]
198 + ( (int *) (ring_node_tab[7]->buffer_address) ) [i + TIME_OFFSET];
176 199 }
200
177 201 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
178 202 if (nb_average == NB_AVERAGE_NORMAL_f0) {
179 203 nb_average = 0;
180 204 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
181 205 if (status != RTEMS_SUCCESSFUL) {
182 206 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
183 207 }
184 208 }
185 209 }
186 210 }
187 211
188 212 rtems_task matr_task(rtems_task_argument argument)
189 213 {
190 214 spw_ioctl_pkt_send spw_ioctl_send_ASM;
191 215 rtems_event_set event_out;
192 216 rtems_status_code status;
193 217 rtems_id queue_id;
194 218 Header_TM_LFR_SCIENCE_ASM_t headerASM;
195 219
196 220 init_header_asm( &headerASM );
197 221
198 222 status = get_message_queue_id_send( &queue_id );
199 223 if (status != RTEMS_SUCCESSFUL)
200 224 {
201 225 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
202 226 }
203 227
204 228 BOOT_PRINTF("in MATR *** \n")
205 229
206 230 fill_averaged_spectral_matrix( );
207 231
208 232 while(1){
209 233 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
210 234 // 1) compress the matrix for Basic Parameters calculation
211 compress_averaged_spectral_matrix( averaged_sm_f0, 0, compressed_sm_f0 );
235 ASM_compress( averaged_sm_f0, 0, compressed_sm_f0 );
212 236 // 2)
213 237 //BP1_set(compressed_sm_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
214 238 // 3) convert the float array in a char array
215 convert_averaged_spectral_matrix( averaged_sm_f0, averaged_sm_f0_char);
239 ASM_reorganize( averaged_sm_f0, averaged_sm_f0_reorganized );
240 ASM_convert( averaged_sm_f0_reorganized, averaged_sm_f0_char);
216 241 // 4) send the spectral matrix packets
217 send_averaged_spectral_matrix( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
242 ASM_send( &headerASM, averaged_sm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
218 243 }
219 244 }
220 245
221 246 //*****************************
222 247 // Spectral matrices processing
223 248
224 249 void matrix_reset(volatile float *averaged_spec_mat)
225 250 {
226 251 int i;
227 252 for(i=0; i<TOTAL_SIZE_SM; i++){
228 253 averaged_spec_mat[i] = 0;
229 254 }
230 255 }
231 256
232 void compress_averaged_spectral_matrix( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
257 void ASM_reorganize( float *averaged_spec_mat, float *averaged_spec_mat_reorganized )
258 {
259 int frequencyBin;
260 int asmComponent;
261
262 // copy the time information
263 averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ];
264 averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ];
265
266 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
267 {
268 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
269 {
270 averaged_spec_mat_reorganized[ frequencyBin * NB_VALUES_PER_SM + asmComponent + TIME_OFFSET ] =
271 averaged_spec_mat[ asmComponent * NB_BINS_PER_SM + frequencyBin + TIME_OFFSET];
272 }
273 }
274 }
275
276 void ASM_compress( float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat )
233 277 {
234 278 int frequencyBin;
235 279 int asmComponent;
236 280 int offsetASM;
237 int generalOffsetASM;
238 281 int offsetCompressed;
239 282 int k;
240 283
241 284 switch (fChannel){
242 285 case 0:
243 generalOffsetASM = ASM_F0_INDICE_START * NB_VALUES_PER_SM;
244 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
245 {
246 offsetCompressed = frequencyBin * NB_VALUES_PER_SM;
247 offsetASM = generalOffsetASM + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0 * NB_VALUES_PER_SM;
248 286 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
249 287 {
250 compressed_spec_mat[ offsetCompressed + asmComponent ] = 0;
288 for( frequencyBin = 0; frequencyBin < NB_BINS_COMPRESSED_SM_F0; frequencyBin++ )
289 {
290 offsetASM = asmComponent * NB_BINS_PER_SM
291 + ASM_F0_INDICE_START
292 + frequencyBin * NB_BINS_TO_AVERAGE_ASM_F0;
293 offsetCompressed = frequencyBin * NB_VALUES_PER_SM
294 + asmComponent;
295 compressed_spec_mat[ offsetCompressed ] = 0;
251 296 for ( k = 0; k < NB_BINS_TO_AVERAGE_ASM_F0; k++ )
252 297 {
253 compressed_spec_mat[ offsetCompressed + asmComponent ] =
254 compressed_spec_mat[ offsetCompressed + asmComponent ]
255 + averaged_spec_mat[ offsetASM + (k*NB_VALUES_PER_SM) + asmComponent ];
298 compressed_spec_mat[offsetCompressed ] =
299 compressed_spec_mat[ offsetCompressed ]
300 + averaged_spec_mat[ offsetASM + k ];
256 301 }
257 compressed_spec_mat[ offsetCompressed + asmComponent ] =
258 compressed_spec_mat[ offsetCompressed + asmComponent ] / NB_BINS_TO_AVERAGE_ASM_F0;
259 302 }
260 303 }
261 304 break;
262 305
263 306 case 1:
264 307 // case fChannel = f1 to be completed later
265 308 break;
266 309
267 310 case 2:
268 311 // case fChannel = f1 to be completed later
269 312 break;
270 313
271 314 default:
272 315 break;
273 316 }
274 317 }
275 318
276 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
319 void ASM_convert( volatile float *input_matrix, char *output_matrix)
277 320 {
278 321 unsigned int i;
279 unsigned int j;
322 unsigned int frequencyBin;
323 unsigned int asmComponent;
280 324 char * pt_char_input;
281 325 char * pt_char_output;
282 326
283 pt_char_input = NULL;
284 pt_char_output = NULL;
327 pt_char_input = (char*) &input_matrix;
328 pt_char_output = (char*) &output_matrix;
285 329
286 for( i=0; i<NB_BINS_PER_SM; i++)
330 // copy the time information
331 for (i=0; i<TIME_OFFSET_IN_BYTES; i++)
287 332 {
288 for ( j=0; j<NB_VALUES_PER_SM; j++)
333 pt_char_output[ i ] = pt_char_output[ i ];
334 }
335
336 // convert all other data
337 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
289 338 {
290 pt_char_input = (char*) &input_matrix [ (i*NB_VALUES_PER_SM) + j ];
291 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
339 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
340 {
341 pt_char_input = (char*) &input_matrix [ (frequencyBin*NB_VALUES_PER_SM) + asmComponent + TIME_OFFSET ];
342 pt_char_output = (char*) &output_matrix[ 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) + TIME_OFFSET_IN_BYTES ];
292 343 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
293 344 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
294 345 }
295 346 }
296 347 }
297 348
298 void send_averaged_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
349 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
299 350 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
300 351 {
301 352 unsigned int i;
302 353 unsigned int length = 0;
303 354 rtems_status_code status;
304 355
305 356 for (i=0; i<2; i++)
306 357 {
307 358 // (1) BUILD THE DATA
308 359 switch(sid)
309 360 {
310 361 case SID_NORM_ASM_F0:
311 362 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
312 spw_ioctl_send->data = &spectral_matrix[ ( (ASM_F0_INDICE_START+ (i*NB_BINS_PER_PKT_ASM_F0)) * NB_VALUES_PER_SM) * 2 ];
363 spw_ioctl_send->data = &spectral_matrix[
364 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
365 + TIME_OFFSET_IN_BYTES
366 ];
313 367 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
314 368 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
315 369 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
316 370 break;
317 371 case SID_NORM_ASM_F1:
318 372 break;
319 373 case SID_NORM_ASM_F2:
320 374 break;
321 375 default:
322 PRINTF1("ERR *** in send_averaged_spectral_matrix *** unexpected sid %d\n", sid)
376 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
323 377 break;
324 378 }
325 379 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
326 380 spw_ioctl_send->hdr = (char *) header;
327 381 spw_ioctl_send->options = 0;
328 382
329 383 // (2) BUILD THE HEADER
330 384 header->packetLength[0] = (unsigned char) (length>>8);
331 385 header->packetLength[1] = (unsigned char) (length);
332 386 header->sid = (unsigned char) sid; // SID
333 387 header->pa_lfr_pkt_cnt_asm = 2;
334 388 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
335 389
336 390 // (3) SET PACKET TIME
337 391 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
338 392 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
339 393 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
340 394 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
341 395 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
342 396 header->time[5] = (unsigned char) (time_management_regs->fine_time);
343 397 //
344 398 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
345 399 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
346 400 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
347 401 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
348 402 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
349 403 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
350 404
351 405 // (4) SEND PACKET
352 406 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
353 407 if (status != RTEMS_SUCCESSFUL) {
354 printf("in send_averaged_spectral_matrix *** ERR %d\n", (int) status);
408 printf("in ASM_send *** ERR %d\n", (int) status);
355 409 }
356 410 }
357 411 }
358 412
359 413 void BP1_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
360 414 int i;
361 415 int j;
362 416 unsigned char tmp_u_char;
363 417 unsigned char * pt_char = NULL;
364 418 float PSDB, PSDE;
365 419 float NVEC_V0;
366 420 float NVEC_V1;
367 421 float NVEC_V2;
368 422 //float significand;
369 423 //int exponent;
370 424 float aux;
371 425 float tr_SB_SB;
372 426 float tmp;
373 427 float sx_re;
374 428 float sx_im;
375 429 float nebx_re = 0;
376 430 float nebx_im = 0;
377 431 float ny = 0;
378 432 float nz = 0;
379 433 float bx_bx_star = 0;
380 434 for(i=0; i<nb_bins_compressed_spec_mat; i++){
381 435 //==============================================
382 436 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
383 437 PSDB = compressed_spec_mat[i*30] // S11
384 438 + compressed_spec_mat[(i*30) + 10] // S22
385 439 + compressed_spec_mat[(i*30) + 18]; // S33
386 440 //significand = frexp(PSDB, &exponent);
387 441 pt_char = (unsigned char*) &PSDB;
388 442 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
389 443 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
390 444 //==============================================
391 445 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
392 446 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
393 447 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
394 448 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
395 449 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
396 450 pt_char = (unsigned char*) &PSDE;
397 451 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
398 452 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
399 453 //==============================================================================
400 454 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
401 455 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
402 456 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
403 457 tmp = sqrt(
404 458 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
405 459 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
406 460 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
407 461 );
408 462 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
409 463 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
410 464 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
411 465 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
412 466 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
413 467 pt_char = (unsigned char*) &NVEC_V2;
414 468 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
415 469 //=======================================================
416 470 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
417 471 aux = 2*tmp / PSDB; // compute the ellipticity
418 472 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
419 473 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
420 474 //==============================================================
421 475 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
422 476 for(j = 0; j<NB_VALUES_PER_SM;j++){
423 477 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
424 478 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
425 479 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
426 480 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
427 481 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
428 482 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
429 483 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
430 484 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
431 485 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
432 486 }
433 487 aux = PSDB*PSDB;
434 488 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
435 489 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
436 490 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
437 491 //=======================================================================================
438 492 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
439 493 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
440 494 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
441 495 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
442 496 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
443 497 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
444 498 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
445 499 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
446 500 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
447 501 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
448 502 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
449 503 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
450 504 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
451 505 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
452 506 if ( abs(sx_re) > abs(sx_im) ) {
453 507 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
454 508 }
455 509 else {
456 510 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
457 511 }
458 512 //======================================================================
459 513 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
460 514 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
461 515 nz = NVEC_V0;
462 516 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
463 517 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
464 518 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
465 519 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
466 520 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
467 521 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
468 522 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
469 523 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
470 524 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
471 525 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
472 526 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
473 527 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
474 528 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
475 529 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
476 530 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
477 531 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
478 532 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
479 533 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
480 534 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
481 535 tmp = nebx_re / bx_bx_star;
482 536 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
483 537 if ( abs(nebx_re) > abs(nebx_im) ) {
484 538 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
485 539 }
486 540 else {
487 541 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
488 542 }
489 543 }
490 544
491 545 }
492 546
493 547 void BP2_set_old(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
494 548 // BP2 autocorrelation
495 549 int i;
496 550 int aux = 0;
497 551
498 552 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
499 553 // S12
500 554 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
501 555 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
502 556 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
503 557 // S13
504 558 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
505 559 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
506 560 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
507 561 // S23
508 562 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
509 563 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
510 564 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
511 565 // S45
512 566 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
513 567 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
514 568 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
515 569 // S14
516 570 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
517 571 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
518 572 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
519 573 // S15
520 574 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
521 575 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
522 576 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
523 577 // S24
524 578 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
525 579 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
526 580 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
527 581 // S25
528 582 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
529 583 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
530 584 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
531 585 // S34
532 586 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
533 587 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
534 588 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
535 589 // S35
536 590 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
537 591 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
538 592 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
539 593 }
540 594 }
541 595
542 596 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
543 597 {
544 598 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
545 599 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
546 600 header->reserved = 0x00;
547 601 header->userApplication = CCSDS_USER_APP;
548 602 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
549 603 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
550 604 header->packetSequenceControl[0] = 0xc0;
551 605 header->packetSequenceControl[1] = 0x00;
552 606 header->packetLength[0] = 0x00;
553 607 header->packetLength[1] = 0x00;
554 608 // DATA FIELD HEADER
555 609 header->spare1_pusVersion_spare2 = 0x10;
556 610 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
557 611 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
558 612 header->destinationID = TM_DESTINATION_ID_GROUND;
559 613 // AUXILIARY DATA HEADER
560 614 header->sid = 0x00;
561 615 header->biaStatusInfo = 0x00;
562 616 header->pa_lfr_pkt_cnt_asm = 0x00;
563 617 header->pa_lfr_pkt_nr_asm = 0x00;
564 618 header->time[0] = 0x00;
565 619 header->time[0] = 0x00;
566 620 header->time[0] = 0x00;
567 621 header->time[0] = 0x00;
568 622 header->time[0] = 0x00;
569 623 header->time[0] = 0x00;
570 624 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
571 625 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
572 626 }
573 627
574 628 void fill_averaged_spectral_matrix(void)
575 629 {
576 630 /** This function fills spectral matrices related buffers with arbitrary data.
577 631 *
578 632 * This function is for testing purpose only.
579 633 *
580 634 */
581 635
582 636 float offset;
583 637 float coeff;
584 638
585 639 offset = 10.;
586 640 coeff = 100000.;
587 641 averaged_sm_f0[ 0 + 25 * 0 ] = 0. + offset;
588 642 averaged_sm_f0[ 0 + 25 * 1 ] = 1. + offset;
589 643 averaged_sm_f0[ 0 + 25 * 2 ] = 2. + offset;
590 644 averaged_sm_f0[ 0 + 25 * 3 ] = 3. + offset;
591 645 averaged_sm_f0[ 0 + 25 * 4 ] = 4. + offset;
592 646 averaged_sm_f0[ 0 + 25 * 5 ] = 5. + offset;
593 647 averaged_sm_f0[ 0 + 25 * 6 ] = 6. + offset;
594 648 averaged_sm_f0[ 0 + 25 * 7 ] = 7. + offset;
595 649 averaged_sm_f0[ 0 + 25 * 8 ] = 8. + offset;
596 650 averaged_sm_f0[ 0 + 25 * 9 ] = 9. + offset;
597 651 averaged_sm_f0[ 0 + 25 * 10 ] = 10. + offset;
598 652 averaged_sm_f0[ 0 + 25 * 11 ] = 11. + offset;
599 653 averaged_sm_f0[ 0 + 25 * 12 ] = 12. + offset;
600 654 averaged_sm_f0[ 0 + 25 * 13 ] = 13. + offset;
601 655 averaged_sm_f0[ 0 + 25 * 14 ] = 14. + offset;
602 656 averaged_sm_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
603 657 averaged_sm_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
604 658 averaged_sm_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
605 659 averaged_sm_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
606 660 averaged_sm_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
607 661 averaged_sm_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
608 662 averaged_sm_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
609 663 averaged_sm_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
610 664 averaged_sm_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
611 665 averaged_sm_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
612 666 averaged_sm_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
613 667 averaged_sm_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
614 668 averaged_sm_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
615 669 averaged_sm_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
616 670 averaged_sm_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
617 671
618 672 offset = 10000000;
619 673 averaged_sm_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
620 674 averaged_sm_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
621 675 averaged_sm_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
622 676 averaged_sm_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
623 677 averaged_sm_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
624 678 averaged_sm_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
625 679 averaged_sm_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
626 680 averaged_sm_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
627 681 averaged_sm_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
628 682 averaged_sm_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
629 683 averaged_sm_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
630 684 averaged_sm_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
631 685 averaged_sm_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
632 686 averaged_sm_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
633 687 averaged_sm_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
634 688
635 689 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_sm_f0[ 0 ];
636 690 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_sm_f0[ 1 ];
637 691 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_sm_f0[ 2 ];
638 692 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_sm_f0[ 3 ];
639 693 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_sm_f0[ 4 ];
640 694 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_sm_f0[ 5 ];
641 695 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_sm_f0[ 6 ];
642 696 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_sm_f0[ 7 ];
643 697 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_sm_f0[ 8 ];
644 698 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_sm_f0[ 9 ];
645 699 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_sm_f0[ 10 ];
646 700 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_sm_f0[ 11 ];
647 701 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_sm_f0[ 12 ];
648 702 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_sm_f0[ 13 ];
649 703 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_sm_f0[ 14 ];
650 704 averaged_sm_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_sm_f0[ 15 ];
651 705 }
652 706
653 707 void reset_spectral_matrix_regs()
654 708 {
655 709 /** This function resets the spectral matrices module registers.
656 710 *
657 711 * The registers affected by this function are located at the following offset addresses:
658 712 *
659 713 * - 0x00 config
660 714 * - 0x04 status
661 715 * - 0x08 matrixF0_Address0
662 716 * - 0x10 matrixFO_Address1
663 717 * - 0x14 matrixF1_Address
664 718 * - 0x18 matrixF2_Address
665 719 *
666 720 */
667 721
722 spectral_matrix_regs->config = 0x00;
723 spectral_matrix_regs->status = 0x00;
724
668 725 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
669 726 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
670 727 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
671 728 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
672 729 }
673 730
674 731 //******************
675 732 // general functions
676 733
677 734
678 735
679 736
@@ -1,733 +1,757
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, time );
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, time );
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, time );
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, time );
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, time );
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, time );
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, time );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id, time );
106 106 close_action( &TC, result, queue_snd_id, time );
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, time );
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, time );
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, time );
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, time );
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, unsigned char *time)
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
164 164 requestedMode = TC->dataAndCRC[1];
165 165
166 166 if ( (requestedMode != LFR_MODE_STANDBY)
167 167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
168 168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
169 169 {
170 170 status = RTEMS_UNSATISFIED;
171 171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time );
172 172 }
173 173 else
174 174 {
175 175 printf("in action_enter_mode *** enter mode %d\n", requestedMode);
176 176
177 177 status = transition_validation(requestedMode);
178 178
179 179 if ( status == LFR_SUCCESSFUL ) {
180 180 if ( lfrCurrentMode != LFR_MODE_STANDBY)
181 181 {
182 182 status = stop_current_mode();
183 183 }
184 184 if (status != RTEMS_SUCCESSFUL)
185 185 {
186 186 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
187 187 }
188 188 status = enter_mode( requestedMode );
189 189 }
190 190 else
191 191 {
192 192 PRINTF("ERR *** in action_enter *** transition rejected\n")
193 193 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
194 194 }
195 195 }
196 196
197 197 return status;
198 198 }
199 199
200 200 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
201 201 {
202 202 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
203 203 *
204 204 * @param TC points to the TeleCommand packet that is being processed
205 205 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
206 206 *
207 207 * @return LFR directive status code:
208 208 * - LFR_DEFAULT
209 209 * - LFR_SUCCESSFUL
210 210 *
211 211 */
212 212
213 213 unsigned int val;
214 214 int result;
215 215
216 216 result = LFR_SUCCESSFUL;
217 217
218 218 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
219 219 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
220 220 val++;
221 221 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
222 222 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
223 223
224 224 return result;
225 225 }
226 226
227 227 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
228 228 {
229 229 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
230 230 *
231 231 * @param TC points to the TeleCommand packet that is being processed
232 232 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
233 233 *
234 234 */
235 235
236 236 int result;
237 237 unsigned char lfrMode;
238 238
239 239 result = LFR_DEFAULT;
240 240 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
241 241
242 242 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
243 243 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
244 244 result = LFR_DEFAULT;
245 245 }
246 246 else {
247 247 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
248 248 result = LFR_DEFAULT;
249 249 }
250 250 return result;
251 251 }
252 252
253 253 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
254 254 {
255 255 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
256 256 *
257 257 * @param TC points to the TeleCommand packet that is being processed
258 258 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
259 259 *
260 260 */
261 261
262 262 int result;
263 263 unsigned char lfrMode;
264 264
265 265 result = LFR_DEFAULT;
266 266 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
267 267
268 268 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
269 269 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
270 270 result = LFR_DEFAULT;
271 271 }
272 272 else {
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_update_time(ccsdsTelecommandPacket_t *TC)
280 280 {
281 281 /** This function executes specific actions when a TC_LFR_UPDATE_TIME 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 * @return LFR_SUCCESSFUL
287 287 *
288 288 */
289 289
290 290 unsigned int val;
291 291
292 292 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
293 293 + (TC->dataAndCRC[1] << 16)
294 294 + (TC->dataAndCRC[2] << 8)
295 295 + TC->dataAndCRC[3];
296 296 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
297 297 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
298 298 val++;
299 299 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
300 300 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
301 301 time_management_regs->ctrl = time_management_regs->ctrl | 1;
302 302
303 303 return LFR_SUCCESSFUL;
304 304 }
305 305
306 306 //*******************
307 307 // ENTERING THE MODES
308 308
309 309 int transition_validation(unsigned char requestedMode)
310 310 {
311 311 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
312 312 *
313 313 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
314 314 *
315 315 * @return LFR directive status codes:
316 316 * - LFR_SUCCESSFUL - the transition is authorized
317 317 * - LFR_DEFAULT - the transition is not authorized
318 318 *
319 319 */
320 320
321 321 int status;
322 322
323 323 switch (requestedMode)
324 324 {
325 325 case LFR_MODE_STANDBY:
326 326 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
327 327 status = LFR_DEFAULT;
328 328 }
329 329 else
330 330 {
331 331 status = LFR_SUCCESSFUL;
332 332 }
333 333 break;
334 334 case LFR_MODE_NORMAL:
335 335 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
336 336 status = LFR_DEFAULT;
337 337 }
338 338 else {
339 339 status = LFR_SUCCESSFUL;
340 340 }
341 341 break;
342 342 case LFR_MODE_BURST:
343 343 if ( lfrCurrentMode == LFR_MODE_BURST ) {
344 344 status = LFR_DEFAULT;
345 345 }
346 346 else {
347 347 status = LFR_SUCCESSFUL;
348 348 }
349 349 break;
350 350 case LFR_MODE_SBM1:
351 351 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
352 352 status = LFR_DEFAULT;
353 353 }
354 354 else {
355 355 status = LFR_SUCCESSFUL;
356 356 }
357 357 break;
358 358 case LFR_MODE_SBM2:
359 359 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
360 360 status = LFR_DEFAULT;
361 361 }
362 362 else {
363 363 status = LFR_SUCCESSFUL;
364 364 }
365 365 break;
366 366 default:
367 367 status = LFR_DEFAULT;
368 368 break;
369 369 }
370 370
371 371 return status;
372 372 }
373 373
374 374 int stop_current_mode(void)
375 375 {
376 376 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
377 377 *
378 378 * @return RTEMS directive status codes:
379 379 * - RTEMS_SUCCESSFUL - task restarted successfully
380 380 * - RTEMS_INVALID_ID - task id invalid
381 381 * - RTEMS_ALREADY_SUSPENDED - task already suspended
382 382 *
383 383 */
384 384
385 385 rtems_status_code status;
386 386
387 387 status = RTEMS_SUCCESSFUL;
388 388
389 389 // (1) mask interruptions
390 390 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
391 //LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
391 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
392 392
393 393 // (2) clear interruptions
394 394 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
395 //LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
395 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
396 396
397 397 // (3) reset registers
398 398 reset_wfp_burst_enable(); // reset burst and enable bits
399 399 reset_wfp_status(); // reset all the status bits
400 disable_irq_on_new_ready_matrix(); // stop the spectral matrices
400 401
401 402 // <Spectral Matrices simulator>
402 403 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
403 404 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
404 405 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
405 406 // </Spectral Matrices simulator>
406 407
407 408 // suspend several tasks
408 409 if (lfrCurrentMode != LFR_MODE_STANDBY) {
409 410 status = suspend_science_tasks();
410 411 }
411 412
412 413 if (status != RTEMS_SUCCESSFUL)
413 414 {
414 415 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
415 416 }
416 417
417 418 return status;
418 419 }
419 420
420 421 int enter_mode(unsigned char mode )
421 422 {
422 423 /** This function is launched after a mode transition validation.
423 424 *
424 425 * @param mode is the mode in which LFR will be put.
425 426 *
426 427 * @return RTEMS directive status codes:
427 428 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
428 429 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
429 430 *
430 431 */
431 432
432 433 rtems_status_code status;
433 434
434 435 status = RTEMS_UNSATISFIED;
435 436
436 437 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
437 438 updateLFRCurrentMode();
438 439
439 440 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
440 441 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
441 442 {
442 443 #ifdef PRINT_TASK_STATISTICS
443 444 rtems_cpu_usage_reset();
444 445 maxCount = 0;
445 446 #endif
446 447 status = restart_science_tasks();
447 448 launch_waveform_picker( mode );
448 //launch_spectral_matrix( mode );
449 launch_spectral_matrix( mode );
449 450 }
450 451 else if ( mode == LFR_MODE_STANDBY )
451 452 {
452 453 #ifdef PRINT_TASK_STATISTICS
453 454 rtems_cpu_usage_report();
454 455 #endif
455 456
456 457 #ifdef PRINT_STACK_REPORT
457 458 rtems_stack_checker_report_usage();
458 459 #endif
459 460 status = stop_current_mode();
460 461 PRINTF1("maxCount = %d\n", maxCount)
461 462 }
462 463 else
463 464 {
464 465 status = RTEMS_UNSATISFIED;
465 466 }
466 467
467 468 if (status != RTEMS_SUCCESSFUL)
468 469 {
469 470 PRINTF1("in enter_mode *** ERR = %d\n", status)
470 471 status = RTEMS_UNSATISFIED;
471 472 }
472 473
473 474 return status;
474 475 }
475 476
476 477 int restart_science_tasks()
477 478 {
478 479 /** This function is used to restart all science tasks.
479 480 *
480 481 * @return RTEMS directive status codes:
481 482 * - RTEMS_SUCCESSFUL - task restarted successfully
482 483 * - RTEMS_INVALID_ID - task id invalid
483 484 * - RTEMS_INCORRECT_STATE - task never started
484 485 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
485 486 *
486 487 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
487 488 *
488 489 */
489 490
490 491 rtems_status_code status[6];
491 492 rtems_status_code ret;
492 493
493 494 ret = RTEMS_SUCCESSFUL;
494 495
495 496 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
496 497 if (status[0] != RTEMS_SUCCESSFUL)
497 498 {
498 499 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
499 500 }
500 501
501 502 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
502 503 if (status[2] != RTEMS_SUCCESSFUL)
503 504 {
504 505 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
505 506 }
506 507
507 508 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
508 509 if (status[3] != RTEMS_SUCCESSFUL)
509 510 {
510 511 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
511 512 }
512 513
513 514 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
514 515 if (status[4] != RTEMS_SUCCESSFUL)
515 516 {
516 517 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
517 518 }
518 519
519 520 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
520 521 if (status[5] != RTEMS_SUCCESSFUL)
521 522 {
522 523 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
523 524 }
524 525
525 526 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
526 527 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
527 528 {
528 529 ret = RTEMS_UNSATISFIED;
529 530 }
530 531
531 532 return ret;
532 533 }
533 534
534 535 int suspend_science_tasks()
535 536 {
536 537 /** This function suspends the science tasks.
537 538 *
538 539 * @return RTEMS directive status codes:
539 540 * - RTEMS_SUCCESSFUL - task restarted successfully
540 541 * - RTEMS_INVALID_ID - task id invalid
541 542 * - RTEMS_ALREADY_SUSPENDED - task already suspended
542 543 *
543 544 */
544 545
545 546 rtems_status_code status;
546 547
547 548 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
548 549 if (status != RTEMS_SUCCESSFUL)
549 550 {
550 551 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
551 552 }
552 553
553 554 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
554 555 {
555 556 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
556 557 if (status != RTEMS_SUCCESSFUL)
557 558 {
558 559 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
559 560 }
560 561 }
561 562
562 563 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
563 564 {
564 565 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
565 566 if (status != RTEMS_SUCCESSFUL)
566 567 {
567 568 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
568 569 }
569 570 }
570 571
571 572 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
572 573 {
573 574 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
574 575 if (status != RTEMS_SUCCESSFUL)
575 576 {
576 577 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
577 578 }
578 579 }
579 580
580 581 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
581 582 {
582 583 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
583 584 if (status != RTEMS_SUCCESSFUL)
584 585 {
585 586 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
586 587 }
587 588 }
588 589
589 590 return status;
590 591 }
591 592
592 593 void launch_waveform_picker( unsigned char mode )
593 594 {
594 595 int startDate;
595 596
596 597 reset_current_ring_nodes();
597 598 reset_waveform_picker_regs();
598 599 set_wfp_burst_enable_register( mode );
599 600 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
600 601 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
601 602 startDate = time_management_regs->coarse_time + 2;
602 603 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
603 604 waveform_picker_regs->start_date = startDate;
604 605 }
605 606
606 607 void launch_spectral_matrix( unsigned char mode )
607 608 {
608 609 reset_nb_sm_f0();
609 610 reset_current_sm_ring_nodes();
610 611 reset_spectral_matrix_regs();
611 612
613 enable_irq_on_new_ready_matrix();
614
615 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
616 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
617 }
618
619 void enable_irq_on_new_ready_matrix( void )
620 {
621 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
622 }
623
624 void disable_irq_on_new_ready_matrix( void )
625 {
626 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
627 }
628
629
630 void launch_spectral_matrix_simu( unsigned char mode )
631 {
632 reset_nb_sm_f0();
633 reset_current_sm_ring_nodes();
634 reset_spectral_matrix_regs();
635
612 636 // Spectral Matrices simulator
613 637 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
614 638 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
615 639 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
616 640 set_local_nb_interrupt_f0_MAX();
617 641 }
618 642
619 643 //****************
620 644 // CLOSING ACTIONS
621 645 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time)
622 646 {
623 647 /** This function is used to update the HK packets statistics after a successful TC execution.
624 648 *
625 649 * @param TC points to the TC being processed
626 650 * @param time is the time used to date the TC execution
627 651 *
628 652 */
629 653
630 654 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
631 655 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
632 656 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
633 657 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
634 658 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
635 659 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
636 660 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
637 661 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
638 662 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
639 663 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
640 664 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
641 665 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
642 666 }
643 667
644 668 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time)
645 669 {
646 670 /** This function is used to update the HK packets statistics after a TC rejection.
647 671 *
648 672 * @param TC points to the TC being processed
649 673 * @param time is the time used to date the TC rejection
650 674 *
651 675 */
652 676
653 677 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
654 678 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
655 679 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
656 680 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
657 681 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
658 682 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
659 683 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
660 684 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
661 685 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
662 686 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
663 687 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
664 688 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
665 689 }
666 690
667 691 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time)
668 692 {
669 693 /** This function is the last step of the TC execution workflow.
670 694 *
671 695 * @param TC points to the TC being processed
672 696 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
673 697 * @param queue_id is the id of the RTEMS message queue used to send TM packets
674 698 * @param time is the time used to date the TC execution
675 699 *
676 700 */
677 701
678 702 unsigned int val = 0;
679 703
680 704 if (result == LFR_SUCCESSFUL)
681 705 {
682 706 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
683 707 &&
684 708 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
685 709 )
686 710 {
687 711 send_tm_lfr_tc_exe_success( TC, queue_id, time );
688 712 }
689 713 update_last_TC_exe( TC, time );
690 714 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
691 715 val++;
692 716 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
693 717 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
694 718 }
695 719 else
696 720 {
697 721 update_last_TC_rej( TC, time );
698 722 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
699 723 val++;
700 724 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
701 725 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
702 726 }
703 727 }
704 728
705 729 //***************************
706 730 // Interrupt Service Routines
707 731 rtems_isr commutation_isr1( rtems_vector_number vector )
708 732 {
709 733 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
710 734 printf("In commutation_isr1 *** Error sending event to DUMB\n");
711 735 }
712 736 }
713 737
714 738 rtems_isr commutation_isr2( rtems_vector_number vector )
715 739 {
716 740 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
717 741 printf("In commutation_isr2 *** Error sending event to DUMB\n");
718 742 }
719 743 }
720 744
721 745 //****************
722 746 // OTHER FUNCTIONS
723 747 void updateLFRCurrentMode()
724 748 {
725 749 /** This function updates the value of the global variable lfrCurrentMode.
726 750 *
727 751 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
728 752 *
729 753 */
730 754 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
731 755 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
732 756 }
733 757
General Comments 0
You need to be logged in to leave comments. Login now