1 |
kusanagi |
1.1 |
/**************************************************************************** |
2 |
|
|
/* F i l e D a t a |
3 |
|
|
/* |
4 |
|
|
/* Module : SRAMManager |
5 |
|
|
/* C.I. No. : |
6 |
|
|
/* $Revision: 1.55 $ |
7 |
|
|
/* $Date: 2005/03/20 18:30:38 $ |
8 |
|
|
/* Belonging to : |
9 |
|
|
/* : |
10 |
|
|
/* $RCSfile: SM_SRAMPageManager_op.c,v $ |
11 |
|
|
/* Program Type : |
12 |
|
|
/* Sub-modules : |
13 |
|
|
/* |
14 |
|
|
/**************************************************************************** |
15 |
|
|
/* S W D e v e l o p m e n t E n v i r o n m e n t |
16 |
|
|
/* |
17 |
|
|
/* Host system : |
18 |
|
|
/* SW Compiler : |
19 |
|
|
/* $Author: sebastiani $ |
20 |
|
|
/* : |
21 |
|
|
/**************************************************************************** |
22 |
|
|
/* U p d a t i n g |
23 |
|
|
/* |
24 |
|
|
/* $Log: SM_SRAMPageManager_op.c,v $ |
25 |
|
|
/* Revision 1.55 2005/03/20 18:30:38 sebastiani |
26 |
|
|
/* *** empty log message *** |
27 |
|
|
/* |
28 |
|
|
/* Revision 1.54 2005/02/21 08:58:29 sebastiani |
29 |
|
|
/* all log comments completed |
30 |
|
|
/* |
31 |
|
|
/* Revision 1.53 2005/02/19 10:20:16 sebastiani |
32 |
|
|
/* accept all MCMC in all mode |
33 |
|
|
/* |
34 |
|
|
/* Revision 1.52 2005/01/26 18:46:56 sebastiani |
35 |
|
|
/* new bug fixes for WS |
36 |
|
|
/* |
37 |
|
|
/* Revision 1.51 2005/01/07 15:42:53 sebastiani |
38 |
|
|
/* add exp 64 mode delay patch |
39 |
|
|
/* |
40 |
|
|
/* Revision 1.50 2004/11/19 15:14:55 sebastiani |
41 |
|
|
/* PRH_EXTERN_{VAR,ARR,TABLE} removed and put them on the autogenerated parameter heeader file |
42 |
|
|
/* |
43 |
|
|
/* Revision 1.49 2004/11/05 16:43:08 sebastiani |
44 |
|
|
/* *** empty log message *** |
45 |
|
|
/* |
46 |
|
|
/* Revision 1.48 2004/09/17 15:01:00 faber |
47 |
|
|
/* LU_INFN_LOG flags fixing |
48 |
|
|
/* |
49 |
|
|
/* Revision 1.47 2004/09/09 14:53:58 sebastiani |
50 |
|
|
/* fix prepare page to send cmd |
51 |
|
|
/* |
52 |
|
|
/* Revision 1.46 2004/08/26 16:54:41 sebastiani |
53 |
|
|
/* version work fine |
54 |
|
|
/* |
55 |
|
|
/* Revision 1.45 2004/08/13 14:42:22 sebastiani |
56 |
|
|
/* Add Neutron detector! |
57 |
|
|
/* need add file ND_READ_ACQ.dat on site ... |
58 |
|
|
/* |
59 |
|
|
/* Revision 1.44 2004/08/09 08:30:29 sebastiani |
60 |
|
|
/* fix calo alarm procedure |
61 |
|
|
/* |
62 |
|
|
/* Revision 1.43 2004/08/02 12:17:26 sebastiani |
63 |
|
|
/* fix little |
64 |
|
|
/* |
65 |
|
|
/* Revision 1.42 2004/07/27 17:30:17 faber |
66 |
|
|
/* OBT can be now in second or milliseconds, depending of the situazion. |
67 |
|
|
/* OBT_s is used for FM compatibility, OBT_ms basically for MM infos |
68 |
|
|
/* |
69 |
|
|
/* Revision 1.41 2004/07/27 13:27:18 sebastiani |
70 |
|
|
/* SM_EXPERIMENT cancelled |
71 |
|
|
/* |
72 |
|
|
/* Revision 1.40 2004/07/21 14:09:22 sebastiani |
73 |
|
|
/* Fix PacketCounter |
74 |
|
|
/* |
75 |
|
|
/* Revision 1.39 2004/07/16 16:13:05 sebastiani |
76 |
|
|
/* important fix |
77 |
|
|
/* |
78 |
|
|
/* Revision 1.38 2004/07/15 13:46:01 sebastiani |
79 |
|
|
/* fix some bugs |
80 |
|
|
/* |
81 |
|
|
/* Revision 1.37 2004/06/15 08:25:01 sebastiani |
82 |
|
|
/* *** empty log message *** |
83 |
|
|
/* |
84 |
|
|
/* Revision 1.36 2004/06/04 14:24:40 sebastiani |
85 |
|
|
/* clear some files |
86 |
|
|
/* |
87 |
|
|
/* Revision 1.35 2004/06/01 16:41:24 sebastiani |
88 |
|
|
/* EventReceive ANY |
89 |
|
|
/* |
90 |
|
|
/* Revision 1.34 2004/05/26 17:48:30 sebastiani |
91 |
|
|
/* *** empty log message *** |
92 |
|
|
/* |
93 |
|
|
/* Revision 1.33 2004/05/25 14:07:18 faber |
94 |
|
|
/* *** empty log message *** |
95 |
|
|
/* |
96 |
|
|
/* Revision 1.32 2004/05/24 10:25:28 faber |
97 |
|
|
/* OS_EVENT_UNCOMPLETED_CMDIF introduced |
98 |
|
|
/* |
99 |
|
|
/* Revision 1.31 2004/05/20 12:51:58 sebastiani |
100 |
|
|
/* nee |
101 |
|
|
/* |
102 |
|
|
/* Revision 1.30 2004/05/20 09:04:23 sebastiani |
103 |
|
|
/* ok |
104 |
|
|
/* |
105 |
|
|
/* Revision 1.29 2004/05/19 08:45:05 sebastiani |
106 |
|
|
/* fix bug |
107 |
|
|
/* |
108 |
|
|
/* Revision 1.28 2004/05/10 12:59:17 faber |
109 |
|
|
/* __FILEID__ right value fixed: many .c files had the wrong value! |
110 |
|
|
/* |
111 |
|
|
/* Revision 1.27 2004/04/29 16:13:59 alfarano |
112 |
|
|
/* update cal |
113 |
|
|
/* |
114 |
|
|
/* Revision 1.25 2004/02/13 10:11:30 alfarano |
115 |
|
|
/* calorimeter initialization func and more |
116 |
|
|
/* |
117 |
|
|
/* Revision 1.24 2004/02/05 15:38:50 sebastiani |
118 |
|
|
/* PM_WAIT_TRIGEVENT managed as a parametrized macro |
119 |
|
|
/* |
120 |
|
|
/* Revision 1.23 2004/02/05 14:45:13 sebastiani |
121 |
|
|
/* unlock acq in PageWasSaved DAQ_SETUP case |
122 |
|
|
/* |
123 |
|
|
/* Revision 1.22 2004/02/02 08:34:40 sebastiani |
124 |
|
|
/* change Macro to write packet header |
125 |
|
|
/* |
126 |
|
|
/* Revision 1.21 2004/01/22 08:58:54 sebastiani |
127 |
|
|
/* WAIT time introduced between DAQ and CMD/IF DMA programming |
128 |
|
|
/* |
129 |
|
|
/* Revision 1.20 2004/01/13 15:07:38 tassa |
130 |
|
|
/* add send forced idaq cmd! |
131 |
|
|
/* |
132 |
|
|
/* Revision 1.19 2003/12/30 14:22:44 sebastiani |
133 |
|
|
/* change crc function: 8 => 16 |
134 |
|
|
/* |
135 |
|
|
/* Revision 1.18 2003/11/18 09:01:15 alfarano |
136 |
|
|
/* laben patch fixes some problems |
137 |
|
|
/* |
138 |
|
|
/* Revision 1.17 2003/11/13 16:15:06 sebastiani |
139 |
|
|
/* PM_opUnLockAcquisition added to SM_DAQSETUP in PageWasSaved, as suggested in the new laben versione released in these days |
140 |
|
|
/* |
141 |
|
|
/* Revision 1.16 2003/11/10 12:13:25 sebastiani |
142 |
|
|
/* PM_pi_SetPktType and SM_PktType global variable introdused |
143 |
|
|
/* |
144 |
|
|
/* Revision 1.15 2003/10/31 17:21:29 sebastiani |
145 |
|
|
/* bug fix on read and write function in TM_TMTCManager: added busy flag control on each read & write |
146 |
|
|
/* CRC functions updated in the SRAMPageManager |
147 |
|
|
/* |
148 |
|
|
/* Revision 1.14 2003/10/30 15:34:04 faber |
149 |
|
|
/* CRC debug fixed 2 |
150 |
|
|
/* |
151 |
|
|
/* Revision 1.13 2003/10/30 14:55:52 faber |
152 |
|
|
/* CRC function debuggin (some fixes) |
153 |
|
|
/* |
154 |
|
|
/* Revision 1.12 2003/10/30 10:09:36 sebastiani |
155 |
|
|
/* *** empty log message *** |
156 |
|
|
/* |
157 |
|
|
/* Revision 1.11 2003/10/29 17:41:48 sebastiani |
158 |
|
|
/* *** empty log message *** |
159 |
|
|
/* |
160 |
|
|
/* Revision 1.10 2003/10/27 19:03:10 sebastiani |
161 |
|
|
/* PM_WRITE_* macros introduced: new header format/management. |
162 |
|
|
/* length,pktsize,crc |
163 |
|
|
/* |
164 |
|
|
/* Revision 1.9 2003/10/21 16:09:12 alfarano |
165 |
|
|
/* LU_LOG_INFN replacement for all remaining original log functions |
166 |
|
|
/* |
167 |
|
|
/* Revision 1.8 2003/10/17 09:16:43 sebastiani |
168 |
|
|
/* SKETCHBOARD_FREE event introduced |
169 |
|
|
/* |
170 |
|
|
/* Revision 1.7 2003/09/17 16:38:53 faber |
171 |
|
|
/* PM_pi_ExpPageAvail() introduced |
172 |
|
|
/* |
173 |
|
|
/* Revision 1.6 2003/09/10 13:44:52 laben |
174 |
|
|
/* delete reference to FILE2 ( new File System Model). |
175 |
|
|
/* |
176 |
|
|
/* Revision 1.5 2003/09/10 10:30:43 faber |
177 |
|
|
/* -introduced: |
178 |
|
|
/* void PM_pi_DisableStore_In_DataTimeOut(), |
179 |
|
|
/* void PM_pi_EnableStore_In_DataTimeOut(), |
180 |
|
|
/* UINT32 PM_pi_GetDataLength(SM_PAGEID page); |
181 |
|
|
/* - fixed: Bug in PreparePage, EXP64 mode "one page only use". |
182 |
|
|
/* the fixing consist of the subsitution |
183 |
|
|
/* of the istruction |
184 |
|
|
/* SM_SelectedPage <<= 2; |
185 |
|
|
/* with |
186 |
|
|
/* SM_SelectedPage += 4; |
187 |
|
|
/* |
188 |
|
|
/* Revision 1.4 2003/08/26 07:44:56 faber |
189 |
|
|
/* events introduced |
190 |
|
|
/* |
191 |
|
|
/* Revision 1.3 2003/08/08 11:02:20 sebastiani |
192 |
|
|
/* introduced SM_DIRECT mode |
193 |
|
|
/* |
194 |
|
|
/* Revision 1.2 2003/08/07 08:46:55 wizard |
195 |
|
|
/* SIMULATOR bugfix ifdef/ifndef |
196 |
|
|
/* SM_PktSize update bug fix in SM_op_PageHasData in order to fix the laben bug of SM_pi_GetPacket |
197 |
|
|
/* introduced the notification to a task from the PageHasData |
198 |
|
|
/* |
199 |
|
|
/* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani |
200 |
|
|
/* Imported sources laben rel. 19.06.2003 integrated with pam2 |
201 |
|
|
/* |
202 |
|
|
/* Revision 1.21 2003/06/13 09:04:15 aurora |
203 |
|
|
/* removed a debug comment |
204 |
|
|
/* |
205 |
|
|
/* Revision 1.20 2003/06/09 10:20:34 aurora |
206 |
|
|
/* improved the management of data acquisition. |
207 |
|
|
/* Fixed the dalay when copy the data in to ERC32 memory |
208 |
|
|
/* |
209 |
|
|
/* Revision 1.19 2003/05/12 16:05:20 aurora |
210 |
|
|
/* fixed the last modify |
211 |
|
|
/* |
212 |
|
|
/* Revision 1.18 2003/05/12 15:48:24 aurora |
213 |
|
|
/* Increase the lostpkt counter on ETO interrupt |
214 |
|
|
/* |
215 |
|
|
/* Revision 1.17 2003/04/29 13:31:34 aurora |
216 |
|
|
/* management of page overrun every 64 Kbyte |
217 |
|
|
/* |
218 |
|
|
/* Revision 1.16 2003/03/24 11:06:11 aurora |
219 |
|
|
/* management for interrupt on page overrun at 128KByte in DAQSetup mode |
220 |
|
|
/* |
221 |
|
|
/* Revision 1.15 2003/01/30 10:17:54 aurora |
222 |
|
|
/* correct the routine for share HBUS |
223 |
|
|
/* |
224 |
|
|
/* Revision 1.14 2003/01/22 14:03:52 aurora |
225 |
|
|
/* improved management of HBUS |
226 |
|
|
/* |
227 |
|
|
/* Revision 1.13 2002/11/14 09:55:02 zulia |
228 |
|
|
/* correct the size of data send through CMD I/F |
229 |
|
|
/* improved the management of ET ISR |
230 |
|
|
/* |
231 |
|
|
/* Revision 1.12 2002/10/17 10:08:21 zulia |
232 |
|
|
/* fixed PIFReset |
233 |
|
|
/* |
234 |
|
|
/* Revision 1.11 2002/10/17 08:38:57 zulia |
235 |
|
|
/* - added counters for distinguish the cause of lost packets |
236 |
|
|
/* - added a flag (SM_EnableStoreET) for enable or disable the |
237 |
|
|
/* storage of a packet when rises a ET |
238 |
|
|
/* - fixed the clear of page_overrun interrupt |
239 |
|
|
/* |
240 |
|
|
/* Revision 1.10 2002/09/02 12:55:18 zulia |
241 |
|
|
/* reset of PIF on boot |
242 |
|
|
/* |
243 |
|
|
/* Revision 1.9 2002/07/31 14:34:09 zulia |
244 |
|
|
/* send data to CMD I/F after Event Trigger |
245 |
|
|
/* set header to 12 Bytes |
246 |
|
|
/* packet counter to 32 bits |
247 |
|
|
/* provided interface for copy buffer from micro to PIF sram |
248 |
|
|
/* |
249 |
|
|
/* Revision 1.8 2002/06/25 09:17:03 zulia |
250 |
|
|
/* Disable reset of packet counter after change state mode |
251 |
|
|
/* |
252 |
|
|
/* Revision 1.7 2002/06/19 08:25:31 zulia |
253 |
|
|
/* added provided interface PM_pi_GetAndIncrPckCnt that |
254 |
|
|
/* get and increase the packet counter |
255 |
|
|
/* |
256 |
|
|
/* Revision 1.6 2002/05/09 08:16:35 zulia |
257 |
|
|
/* * acceptance release |
258 |
|
|
/* |
259 |
|
|
/* |
260 |
|
|
/*****************************************************************************/ |
261 |
|
|
|
262 |
|
|
|
263 |
|
|
/*============================= Include File ================================*/ |
264 |
|
|
|
265 |
|
|
#include <src/INFN/LU_SourceFileID_INFN.h> |
266 |
|
|
#define __FILEID__ _SM_SRAMPageManager_op__c |
267 |
|
|
#include <src/INFN/PRH_ParamHandler_INFN.h> |
268 |
|
|
#include <src/INFN/LU_LogUtility_INFN.h> |
269 |
|
|
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
270 |
|
|
LU_DECL_MASK(); |
271 |
|
|
|
272 |
|
|
|
273 |
|
|
#include <src/SRAMManager/SRAMPageManager/SM_SRAMPageManager_op.h> |
274 |
|
|
#include <src/SRAMManager/SRAMPageManager/SM_SRAMPageManager_int.h> |
275 |
|
|
#include <src/HKManager/HistoryArea/HA_HistoryArea_p.h> |
276 |
|
|
#include <src/SRAMManager/SRAMDriver/SD_SRAMDriver_p.h> |
277 |
|
|
#include <src/BasicSW/TimingInfo/TI_TimingInfo_p.h> |
278 |
|
|
#include <src/FileManager/MMSUManager/FT_MMSUManager_p.h> |
279 |
|
|
#include <src/INFN/CM_Common_INFN.h> |
280 |
|
|
#include <src/INFN/HB_HKBuffer_INFN.h> |
281 |
|
|
|
282 |
|
|
/*============================== local define ===============================*/ |
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
/*======================== Object Internal variables ========================*/ |
287 |
|
|
|
288 |
|
|
/*****************************************************************************/ |
289 |
|
|
/* @Variable: SM_AcqMode */ |
290 |
|
|
/* @Purpose : */ |
291 |
|
|
/* PIF Acquisition mode */ |
292 |
|
|
/* @@ */ |
293 |
|
|
/*****************************************************************************/ |
294 |
|
|
static SM_ACQMODE SM_AcqMode; |
295 |
|
|
|
296 |
|
|
/*****************************************************************************/ |
297 |
|
|
/* @Variable: SM_EmptyPage */ |
298 |
|
|
/* @Purpose : */ |
299 |
|
|
/* Flag to mark a SRAM "page empty" after an EVENT T.O. */ |
300 |
|
|
/* @@ */ |
301 |
|
|
/*****************************************************************************/ |
302 |
|
|
static BOOL SM_EmptyPage; |
303 |
|
|
|
304 |
|
|
/*****************************************************************************/ |
305 |
|
|
/* @Variable: SM_TrashFlag */ |
306 |
|
|
/* @Purpose : */ |
307 |
|
|
/* Flag to mark the use of the SRAM trash page */ |
308 |
|
|
/* @@ */ |
309 |
|
|
/*****************************************************************************/ |
310 |
|
|
//static BOOL SM_TrashFlag; |
311 |
|
|
|
312 |
|
|
/*****************************************************************************/ |
313 |
|
|
/* @Variable: SM_SavingSkatchboard */ |
314 |
|
|
/* @Purpose : */ |
315 |
|
|
/* Flag to mark that the sketchboard page storage is in progress */ |
316 |
|
|
/* @@ */ |
317 |
|
|
/*****************************************************************************/ |
318 |
|
|
static BOOL SM_SavingSkatchboard; |
319 |
|
|
|
320 |
|
|
/*****************************************************************************/ |
321 |
|
|
/* @Variable: SM_SelectedPage */ |
322 |
|
|
/* @Purpose : */ |
323 |
|
|
/* Current SRAM page used to hold incoming experiment packets */ |
324 |
|
|
/* @@ */ |
325 |
|
|
/*****************************************************************************/ |
326 |
|
|
static UINT32 SM_SelectedPage; |
327 |
|
|
|
328 |
|
|
/*****************************************************************************/ |
329 |
|
|
/* @Variable: SM_PacketCounter */ |
330 |
|
|
/* @Purpose : */ |
331 |
|
|
/* Header packet counter */ |
332 |
|
|
/* @@ */ |
333 |
|
|
/*****************************************************************************/ |
334 |
|
|
static UINT32 SM_PacketCounter; |
335 |
|
|
|
336 |
|
|
/*****************************************************************************/ |
337 |
|
|
/* @Variable: SM_LostPackets */ |
338 |
|
|
/* @Purpose : */ |
339 |
|
|
/* Lost packet counter */ |
340 |
|
|
/* @@ */ |
341 |
|
|
/*****************************************************************************/ |
342 |
|
|
static UINT32 SM_LostPackets; |
343 |
|
|
|
344 |
|
|
/*****************************************************************************/ |
345 |
|
|
/* @Variable: SM_ETOLostPackets */ |
346 |
|
|
/* @Purpose : */ |
347 |
|
|
/* Lost packet counter due to ETO */ |
348 |
|
|
/* @@ */ |
349 |
|
|
/*****************************************************************************/ |
350 |
|
|
static UINT32 SM_ETOLostPackets; |
351 |
|
|
|
352 |
|
|
/*****************************************************************************/ |
353 |
|
|
/* @Variable: SM_MMSULostPackets */ |
354 |
|
|
/* @Purpose : */ |
355 |
|
|
/* Lost packet counter */ |
356 |
|
|
/* @@ */ |
357 |
|
|
/*****************************************************************************/ |
358 |
|
|
static UINT32 SM_MMSULostPackets; |
359 |
|
|
|
360 |
|
|
/*****************************************************************************/ |
361 |
|
|
/* @Variable: SM_ERC32LostPackets */ |
362 |
|
|
/* @Purpose : */ |
363 |
|
|
/* Counter for packets lost during the transfer in ERC32 memory */ |
364 |
|
|
/* @@ */ |
365 |
|
|
/*****************************************************************************/ |
366 |
|
|
static UINT32 SM_ERC32LostPackets; |
367 |
|
|
|
368 |
|
|
/*****************************************************************************/ |
369 |
|
|
/* @Variable: SM_LostTriggers */ |
370 |
|
|
/* @Purpose : */ |
371 |
|
|
/* Lost Event Trigger counter */ |
372 |
|
|
/* @@ */ |
373 |
|
|
/*****************************************************************************/ |
374 |
|
|
static UINT32 SM_LostTriggers; |
375 |
|
|
|
376 |
|
|
/*****************************************************************************/ |
377 |
|
|
/* @Variable: SM_ExpPageCounter */ |
378 |
|
|
/* @Purpose : */ |
379 |
|
|
/* Counter of the free SRAM pages for the experiment pkts caching */ |
380 |
|
|
/* @@ */ |
381 |
|
|
/*****************************************************************************/ |
382 |
|
|
static UINT32 SM_ExpPageCounter; |
383 |
|
|
|
384 |
|
|
/*****************************************************************************/ |
385 |
|
|
/* @Variable: SM_PktRamCpyFlag */ |
386 |
|
|
/* @Purpose : */ |
387 |
|
|
/* Experiment pkt RAM copy flag */ |
388 |
|
|
/* @@ */ |
389 |
|
|
/*****************************************************************************/ |
390 |
|
|
static BOOL SM_PktRamCpyFlag; |
391 |
|
|
|
392 |
|
|
/*****************************************************************************/ |
393 |
|
|
/* @Variable: SM_PktSize */ |
394 |
|
|
/* @Purpose : */ |
395 |
|
|
/* Size of the last recieved packet */ |
396 |
|
|
/* @@ */ |
397 |
|
|
/*****************************************************************************/ |
398 |
|
|
static UINT32 SM_PktSize; |
399 |
|
|
|
400 |
|
|
/*****************************************************************************/ |
401 |
|
|
/* @Variable: SM_PktStatus */ |
402 |
|
|
/* @Purpose : */ |
403 |
|
|
/* Status of the last recieved packet */ |
404 |
|
|
/* @@ */ |
405 |
|
|
/*****************************************************************************/ |
406 |
|
|
static SM_PKTSTAT SM_PktStatus; |
407 |
|
|
|
408 |
|
|
/*****************************************************************************/ |
409 |
|
|
/* @Variable: SM_PktLock */ |
410 |
|
|
/* @Purpose : */ |
411 |
|
|
/* Flag used to avoid concurrency in R/W on PktBuf during exp. acquisition */ |
412 |
|
|
/* @@ */ |
413 |
|
|
/*****************************************************************************/ |
414 |
|
|
static BOOL SM_PktLock; |
415 |
|
|
|
416 |
|
|
/*****************************************************************************/ |
417 |
|
|
/* @Variable: SM_PIFTrOk */ |
418 |
|
|
/* @Purpose : */ |
419 |
|
|
/* PIF Tranfer status flag */ |
420 |
|
|
/* @@ */ |
421 |
|
|
/*****************************************************************************/ |
422 |
|
|
static SD_TRANSFERSTAT SM_PIFTrOk; |
423 |
|
|
|
424 |
|
|
/*****************************************************************************/ |
425 |
|
|
/* @Variable: SM_CalDataLenght[16] */ |
426 |
|
|
/* @Purpose : */ |
427 |
|
|
/* Number of data to write after ET for initialise intruments */ |
428 |
|
|
/* These values are significatives only for SM_CALEXPx pages */ |
429 |
|
|
/* @@ */ |
430 |
|
|
/*****************************************************************************/ |
431 |
|
|
static UINT32 SM_CalDataLenght[16]; |
432 |
|
|
|
433 |
|
|
/*****************************************************************************/ |
434 |
|
|
/* @Variable: SM_CalPageSelected */ |
435 |
|
|
/* @Purpose : */ |
436 |
|
|
/* page used for initialise instruments */ |
437 |
|
|
/* @@ */ |
438 |
|
|
/*****************************************************************************/ |
439 |
|
|
static SM_PAGEID SM_CalPageSelected; |
440 |
|
|
|
441 |
|
|
/*****************************************************************************/ |
442 |
|
|
/* @Variable: SM_PacketStoreIsOngoing */ |
443 |
|
|
/* @Purpose : */ |
444 |
|
|
/* Flag to mark that the store of scientific packet is ongoing */ |
445 |
|
|
/* @@ */ |
446 |
|
|
/*****************************************************************************/ |
447 |
|
|
static BOOL SM_PacketStoreIsOngoing; |
448 |
|
|
static BOOL SM_ERC32IsOngoing; |
449 |
|
|
|
450 |
|
|
/*****************************************************************************/ |
451 |
|
|
/* @Variable: SM_HBUSIsLocked */ |
452 |
|
|
/* @Purpose : */ |
453 |
|
|
/* Flag to mark that HBUS is in use from an other function */ |
454 |
|
|
/* @@ */ |
455 |
|
|
/*****************************************************************************/ |
456 |
|
|
static BOOL SM_HBUSIsLocked; |
457 |
|
|
|
458 |
|
|
/*****************************************************************************/ |
459 |
|
|
/* @Variable: SM_NotifyTask (INFN) */ |
460 |
|
|
/* @Purpose : */ |
461 |
|
|
/* Task to notify the Event to */ |
462 |
|
|
/* @@ */ |
463 |
|
|
/*****************************************************************************/ |
464 |
|
|
static UINT32 SM_NotifyTask_PKT_READY; |
465 |
|
|
static UINT32 SM_NotifyTask_SKETCHBOARD_FREE; |
466 |
|
|
|
467 |
|
|
|
468 |
|
|
/*****************************************************************************/ |
469 |
|
|
/* @Variable: SM_EnableStore */ |
470 |
|
|
/* @Purpose : */ |
471 |
|
|
/* Enable/Disable the storing of the packed in the File Sistem (FILE1) */ |
472 |
|
|
/* @@ */ |
473 |
|
|
/*****************************************************************************/ |
474 |
|
|
static BOOL SM_EnableStore; |
475 |
|
|
|
476 |
|
|
/*****************************************************************************/ |
477 |
|
|
/* @Variable: SM_PktType */ |
478 |
|
|
/* @Purpose : */ |
479 |
|
|
/* Enable/Disable the storing of the packed in the File Sistem (FILE1) */ |
480 |
|
|
/* @@ */ |
481 |
|
|
/*****************************************************************************/ |
482 |
|
|
static BOOL SM_PktType; |
483 |
|
|
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
static TI_TIME SM_exp64_t1=0; |
487 |
|
|
|
488 |
|
|
|
489 |
|
|
|
490 |
|
|
/*****************************************************************************/ |
491 |
|
|
/*===== S R A M P a g e M a n a g e r P R O V I D E D I N T E R F A C E ==*/ |
492 |
|
|
|
493 |
|
|
/*****************************************************************************/ |
494 |
|
|
/* @Function: SM_opSRAMPageManagerInit */ |
495 |
|
|
/* @Purpose : */ |
496 |
|
|
/* This function initializes the SRAM Page Manager object (its variables). */ |
497 |
|
|
/* */ |
498 |
|
|
/* @@ */ |
499 |
|
|
/* @Parameter Name @Mode @Description */ |
500 |
|
|
/* SM_EXITCODE OUT Return code */ |
501 |
|
|
/* RstPktCounter IN Flag used to enable the lost packets */ |
502 |
|
|
/* counter reset */ |
503 |
|
|
/* @@ */ |
504 |
|
|
/*****************************************************************************/ |
505 |
|
|
|
506 |
|
|
SM_EXITCODE PM_opSRAMPageManagerInit(BOOL RstPktCounter) |
507 |
|
|
{ |
508 |
|
|
SM_EXITCODE status = SM_SUCCESS; |
509 |
|
|
unsigned int intLevel; |
510 |
|
|
unsigned int i; |
511 |
|
|
|
512 |
|
|
/* Init the lost packet counter only at startup */ |
513 |
|
|
if(RstPktCounter) |
514 |
|
|
{ |
515 |
|
|
SD_piPIFReset(); |
516 |
|
|
SM_LostPackets = 0; |
517 |
|
|
SM_ETOLostPackets = 0; |
518 |
|
|
SM_MMSULostPackets = 0; |
519 |
|
|
SM_ERC32LostPackets = 0; |
520 |
|
|
SM_LostTriggers = 0; |
521 |
|
|
SM_PacketCounter = 0; |
522 |
|
|
/* Init the timeout timers */ |
523 |
|
|
SD_piSetEventTimeout(SM_ETO_TICS); |
524 |
|
|
SD_piSetDataTimeout(SM_DTO_TICS); |
525 |
|
|
/* Init the Header length registers */ |
526 |
|
|
SD_piSetDataHeaderLength(SM_PKTHEADER_LEN); |
527 |
|
|
SD_piSetCalibrationHeaderLength(SM_PKTHEADER_LEN); |
528 |
|
|
/* Init the length of data in all calibration pages */ |
529 |
|
|
for (i = 0; i < SM_MAXPAGE; SM_CalDataLenght[i++] = 0); |
530 |
|
|
/* select first page for initialise intruments */ |
531 |
|
|
SM_CalPageSelected = SM_CALEXP0; |
532 |
|
|
} |
533 |
|
|
|
534 |
|
|
/* Mask all interrupt related to PIF acquisition */ |
535 |
|
|
OS_piInterDisable(&intLevel); |
536 |
|
|
SD_piMaskInt(SD_EVT_TO | SD_DATA_TO | SD_PAGE_OVR); |
537 |
|
|
OS_piInterEnable(intLevel); |
538 |
|
|
ERC32_Mask_interrupt(ETIRQ); |
539 |
|
|
/* Set the acquisition mode to IDLE */ |
540 |
|
|
FT_piChangeAcqMode(SM_IDLE); |
541 |
|
|
SM_ExpPageCounter = DIRECTPAGES; |
542 |
|
|
// console_outbyte_polled( 0, 'J' ); |
543 |
|
|
// console_outbyte_polled( 0, '\n' ); |
544 |
|
|
SM_PktLock = FALSE; |
545 |
|
|
SM_PktRamCpyFlag = FALSE; |
546 |
|
|
SM_NotifyTask_PKT_READY = RM_INFN_TASK; |
547 |
|
|
SM_NotifyTask_SKETCHBOARD_FREE = RM_INFN_TASK; |
548 |
|
|
SM_PktType = 0; |
549 |
|
|
SM_PIFTrOk = SD_TRANSFERFAIL; |
550 |
|
|
|
551 |
|
|
// Skratchboard |
552 |
|
|
SM_SavingSkatchboard = FALSE; |
553 |
|
|
|
554 |
|
|
return (status); |
555 |
|
|
} |
556 |
|
|
|
557 |
|
|
/*****************************************************************************/ |
558 |
|
|
/* @MACRO: SM_WRITE_PACKET_HEADER */ |
559 |
|
|
/* @Purpose : */ |
560 |
|
|
/* Write in the PIF the header for an incaming event. Must be used only */ |
561 |
|
|
/* inside the PreparePage */ |
562 |
|
|
/* */ |
563 |
|
|
/* @@ */ |
564 |
|
|
/* @Parameter Name @Mode @Description */ |
565 |
|
|
/* @@ */ |
566 |
|
|
/*****************************************************************************/ |
567 |
|
|
|
568 |
|
|
|
569 |
|
|
static BYTE PM_WRITE_PKT_HEADER_Pkt_Header[SM_PKTHEADER_LEN]; |
570 |
|
|
static UINT32 PM_WRITE_PKT_HEADER_index; |
571 |
|
|
|
572 |
|
|
|
573 |
|
|
#define PM_WRITE_PKT_HEADER_BYTE(byte) do { \ |
574 |
|
|
PM_WRITE_PKT_HEADER_Pkt_Header[PM_WRITE_PKT_HEADER_index]=(BYTE)(byte); \ |
575 |
|
|
SD_piWriteSRAM(PM_WRITE_PKT_HEADER_Pkt_Header[PM_WRITE_PKT_HEADER_index]); \ |
576 |
|
|
PM_WRITE_PKT_HEADER_index++; \ |
577 |
|
|
} while(0) |
578 |
|
|
|
579 |
|
|
#define PM_INC_PKT_COUNTER() do { \ |
580 |
|
|
if(SM_EnableStore) \ |
581 |
|
|
SM_PacketCounter++; \ |
582 |
|
|
} while(0) |
583 |
|
|
|
584 |
|
|
#define PM_WRITE_PKT_HEADER(page,pkt_size,crc) do { \ |
585 |
|
|
/* Retrive OBT */ \ |
586 |
|
|
TI_TIME obt; \ |
587 |
|
|
TI_piGetTimeInfo_ms(&obt); \ |
588 |
|
|
/* Set the SRAM R/W register to the first byte of the Cal page */ \ |
589 |
|
|
PM_WRITE_PKT_HEADER_index=0; \ |
590 |
|
|
SD_piSetSRAMRWAddress((UINT32)(page) * SM_SRAMPAGESIZE); \ |
591 |
|
|
/* The HBUS is locked by PM_opPreparePage */ \ |
592 |
|
|
PM_WRITE_PKT_HEADER_BYTE(PM_HEADER_1); \ |
593 |
|
|
PM_WRITE_PKT_HEADER_BYTE(PM_HEADER_2); \ |
594 |
|
|
PM_WRITE_PKT_HEADER_BYTE(PM_HEADER_3); \ |
595 |
|
|
/* write packet type */ \ |
596 |
|
|
PM_WRITE_PKT_HEADER_BYTE(SM_PktType | ((SM_PktStatus == SM_PKT_BAD)<<7) ); \ |
597 |
|
|
PM_WRITE_PKT_HEADER_BYTE(SM_PktType | ((SM_PktStatus == SM_PKT_BAD)<<7) ); \ |
598 |
|
|
/* Write the packet counter */ \ |
599 |
|
|
PM_WRITE_PKT_HEADER_BYTE(((SM_PacketCounter>>16) & 0x000000FF)); \ |
600 |
|
|
PM_WRITE_PKT_HEADER_BYTE(((SM_PacketCounter>>8 ) & 0x000000FF)); \ |
601 |
|
|
PM_WRITE_PKT_HEADER_BYTE(( SM_PacketCounter & 0x000000FF)); \ |
602 |
|
|
/* Write the OBT */ \ |
603 |
|
|
PM_WRITE_PKT_HEADER_BYTE(((obt>>24) & 0x000000FF)); \ |
604 |
|
|
PM_WRITE_PKT_HEADER_BYTE(((obt>>16) & 0x000000FF)); \ |
605 |
|
|
PM_WRITE_PKT_HEADER_BYTE(((obt>>8 ) & 0x000000FF)); \ |
606 |
|
|
PM_WRITE_PKT_HEADER_BYTE(( obt & 0x000000FF)); \ |
607 |
|
|
/* Write the pkt lenght */ \ |
608 |
|
|
PM_WRITE_PKT_HEADER_BYTE((( (pkt_size)-SM_PKTHEADER_LEN)>>16) & 0x000000FF); \ |
609 |
|
|
PM_WRITE_PKT_HEADER_BYTE((( (pkt_size)-SM_PKTHEADER_LEN)>>8 ) & 0x000000FF); \ |
610 |
|
|
PM_WRITE_PKT_HEADER_BYTE( ( (pkt_size)-SM_PKTHEADER_LEN) & 0x000000FF); \ |
611 |
|
|
crc=CM_Compute_CRC16(0,&PM_WRITE_PKT_HEADER_Pkt_Header[0],PM_WRITE_PKT_HEADER_index); \ |
612 |
|
|
/*crc=CM_Compute_CRC8_8(0,&PM_WRITE_PKT_HEADER_Pkt_Header[0],PM_WRITE_PKT_HEADER_index); */\ |
613 |
|
|
PM_WRITE_PKT_HEADER_BYTE(crc & 0xff); \ |
614 |
|
|
PM_WRITE_PKT_HEADER_index=0; \ |
615 |
|
|
} while(0) |
616 |
|
|
|
617 |
|
|
|
618 |
|
|
|
619 |
|
|
/********************************************************g*********************/ |
620 |
|
|
/* @Function: SM_opPreparePage */ |
621 |
|
|
/* @Purpose : */ |
622 |
|
|
/* The function selects a new SRAM page to hold the new data coming from */ |
623 |
|
|
/* the DAQ I/F and write the page header. */ |
624 |
|
|
/* */ |
625 |
|
|
/* @@ */ |
626 |
|
|
/* @Parameter Name @Mode @Description */ |
627 |
|
|
/* @@ */ |
628 |
|
|
/*****************************************************************************/ |
629 |
|
|
|
630 |
|
|
status_code PM_opPreparePage(BOOL daq_dmain) |
631 |
|
|
{ |
632 |
|
|
#ifdef SIMULATOR |
633 |
|
|
return; |
634 |
|
|
#else |
635 |
|
|
unsigned int intLevel; |
636 |
|
|
status_code status=CM_RC_SUCCESSFUL; |
637 |
|
|
|
638 |
|
|
/* Mask any further Event Trigger */ |
639 |
|
|
ERC32_Mask_interrupt(ETIRQ); |
640 |
|
|
|
641 |
|
|
#if 0 |
642 |
|
|
{ |
643 |
|
|
static TI_TIME SM_exp64_t0=0; |
644 |
|
|
TI_TIME delay=0; |
645 |
|
|
TI_piGetTimeInfo_ms(&SM_exp64_t0); |
646 |
|
|
if(SM_exp64_t0>SM_exp64_t1){ |
647 |
|
|
if((SM_exp64_t0-SM_exp64_t1)<PRH_VAR_EXP64_MODE_DELAY) |
648 |
|
|
delay=SM_exp64_t1+PRH_VAR_EXP64_MODE_DELAY-SM_exp64_t0; |
649 |
|
|
} |
650 |
|
|
else |
651 |
|
|
/* Timing info is over 41 uptime ! days :) */ |
652 |
|
|
delay=PRH_VAR_EXP64_MODE_DELAY; |
653 |
|
|
if(delay) |
654 |
|
|
OS_piTaskSuspend(delay); |
655 |
|
|
SM_exp64_t1=SM_exp64_t0; |
656 |
|
|
} |
657 |
|
|
#endif |
658 |
|
|
|
659 |
|
|
if ((PM_opLockHBUS() == SM_SUCCESS)) |
660 |
|
|
{ |
661 |
|
|
OS_piInterDisable(&intLevel); |
662 |
|
|
switch(SM_AcqMode) |
663 |
|
|
{ |
664 |
|
|
case SM_DIRECT: |
665 |
|
|
case SM_DAQSETUP: { |
666 |
|
|
if(SM_ExpPageCounter > 0 || !daq_dmain) { |
667 |
|
|
|
668 |
|
|
if (SM_CalDataLenght[SM_CalPageSelected] > 0) |
669 |
|
|
{ |
670 |
|
|
/* Set the selected SRAM page where take data for */ |
671 |
|
|
/* initialise instrument */ |
672 |
|
|
SD_piSetCMDBUSReadPage(SM_CalPageSelected); |
673 |
|
|
/* Set end of data of selected page */ |
674 |
|
|
SD_piSetCMDBUSReadParams( |
675 |
|
|
(UINT32)(SM_CalPageSelected * SM_SRAMPAGESIZE + |
676 |
|
|
SM_CalDataLenght[SM_CalPageSelected]-1)); |
677 |
|
|
|
678 |
|
|
/* Start the acquisition and timeouts */ |
679 |
|
|
if (daq_dmain) |
680 |
|
|
{ |
681 |
|
|
SM_ExpPageCounter--; |
682 |
|
|
/* Set the fix SRAM page to hold the incoming pkt */ |
683 |
|
|
SD_piSetDAQWritePage(SM_CALPAGE); |
684 |
|
|
|
685 |
|
|
SD_piTrigCalibrationEvent(); |
686 |
|
|
} |
687 |
|
|
/* start transfer to CMD I/F*/ |
688 |
|
|
SD_piStartTransferToCMD(); |
689 |
|
|
//console_outbyte_polled( 0, 'X' ); |
690 |
|
|
//console_outbyte_polled( 0, '\n' ); |
691 |
|
|
} |
692 |
|
|
else{ |
693 |
|
|
status=CM_RC_CALPAGEEMPTY; |
694 |
|
|
} |
695 |
|
|
}else{ |
696 |
|
|
status=CM_RC_NOPAGEAVAILABLE; |
697 |
|
|
} |
698 |
|
|
} break; |
699 |
|
|
#if 0 |
700 |
|
|
/* /\* Actions performed after an ET in Experiment acq. mode *\/ */ |
701 |
|
|
/* case SM_EXPERIMENT: */ |
702 |
|
|
/* { */ |
703 |
|
|
/* /\* Check if a new SRAM cache page has to be selected: *\/ */ |
704 |
|
|
/* /\* - The last acquisition was good and need to be saved *\/ */ |
705 |
|
|
/* /\* - In the last acquisition the trash page was selected *\/ */ |
706 |
|
|
/* if((SM_PIFTrOk == TRUE && */ |
707 |
|
|
/* SM_EmptyPage == FALSE ) || */ |
708 |
|
|
/* SM_TrashFlag == TRUE) */ |
709 |
|
|
/* { */ |
710 |
|
|
/* /\* Check if there is any free SRAM page left *\/ */ |
711 |
|
|
/* if(SM_ExpPageCounter > 0) */ |
712 |
|
|
/* { */ |
713 |
|
|
/* SM_ExpPageCounter--; */ |
714 |
|
|
/* /\* Select the next SRAM page number in a circular buffer of *\/ */ |
715 |
|
|
/* /\* EXPPAGES pages *\/ */ |
716 |
|
|
/* SM_SelectedPage++; */ |
717 |
|
|
/* SM_SelectedPage &= 0x00000007; */ |
718 |
|
|
/* /\* Set the SRAM page to hold the incoming pkt *\/ */ |
719 |
|
|
/* SD_piSetDAQWritePage(SM_SelectedPage); */ |
720 |
|
|
/* /\* The selected page is not the trash one *\/ */ |
721 |
|
|
/* SM_TrashFlag = FALSE; */ |
722 |
|
|
/* } */ |
723 |
|
|
/* else */ |
724 |
|
|
/* { */ |
725 |
|
|
/* /\* No more free cache SRAM page left. The Trash one must be selected *\/ */ |
726 |
|
|
/* SD_piSetDAQWritePage(TRASHPAGE); */ |
727 |
|
|
/* SM_TrashFlag = TRUE; */ |
728 |
|
|
/* } */ |
729 |
|
|
/* } */ |
730 |
|
|
/* /\* If the last acquisition was not good then reselect the same SRAM page *\/ */ |
731 |
|
|
/* else */ |
732 |
|
|
/* SD_piSetDAQWritePage(SM_SelectedPage); */ |
733 |
|
|
|
734 |
|
|
/* if (SM_CalDataLenght[SM_CalPageSelected] > 0) */ |
735 |
|
|
/* { */ |
736 |
|
|
|
737 |
|
|
/* /\* Set the selected SRAM page where take data for *\/ */ |
738 |
|
|
/* /\* initialise instrument *\/ */ |
739 |
|
|
/* SD_piSetCMDBUSReadPage(SM_CalPageSelected); */ |
740 |
|
|
/* /\* Set end of data of selected page *\/ */ |
741 |
|
|
/* SD_piSetCMDBUSReadParams( */ |
742 |
|
|
/* (UINT32)(SM_CalPageSelected * SM_SRAMPAGESIZE + */ |
743 |
|
|
/* SM_CalDataLenght[SM_CalPageSelected]-1)); */ |
744 |
|
|
/* /\* Start the acquisition *\/ */ |
745 |
|
|
/* if (daq_dmain) */ |
746 |
|
|
/* { */ |
747 |
|
|
/* SD_piTrigDataEvent(); */ |
748 |
|
|
/* } */ |
749 |
|
|
/* /\* start transfer to CMD I/F *\/ */ |
750 |
|
|
/* SD_piStartTransferToCMD(); */ |
751 |
|
|
|
752 |
|
|
|
753 |
|
|
/* // PM_WRITE_PKT_HEADER_BEFORE(SM_SelectedPage); */ |
754 |
|
|
|
755 |
|
|
|
756 |
|
|
/* } */ |
757 |
|
|
/* } break; */ |
758 |
|
|
#endif |
759 |
|
|
/* Actions performed after an ET in Exp64 acq. mode */ |
760 |
|
|
case SM_EXP64: { |
761 |
|
|
if(SM_ExpPageCounter > 0) { |
762 |
|
|
SM_ExpPageCounter--; |
763 |
|
|
SM_SelectedPage += 4; |
764 |
|
|
SM_SelectedPage &= 0x00000007; |
765 |
|
|
/* Set the SRAM page to hold the incoming pkt */ |
766 |
|
|
SD_piSetDAQWritePage(SM_SelectedPage); |
767 |
|
|
if (SM_CalDataLenght[SM_CalPageSelected] > 0) |
768 |
|
|
{ |
769 |
|
|
/* Set the selected SRAM page where take data for */ |
770 |
|
|
/* initialise instrument */ |
771 |
|
|
SD_piSetCMDBUSReadPage(SM_CalPageSelected); |
772 |
|
|
/* Set end of data of selected page */ |
773 |
|
|
SD_piSetCMDBUSReadParams( |
774 |
|
|
(UINT32)(SM_CalPageSelected * SM_SRAMPAGESIZE + |
775 |
|
|
SM_CalDataLenght[SM_CalPageSelected]-1)); |
776 |
|
|
/* Start the acquisition */ |
777 |
|
|
SD_piTrigData64Event(); |
778 |
|
|
/* start transfer to CMD I/F */ |
779 |
|
|
SD_piStartTransferToCMD(); |
780 |
|
|
// PM_WRITE_PKT_HEADER_BEFORE(SM_SelectedPage); |
781 |
|
|
} |
782 |
|
|
else{ |
783 |
|
|
status=CM_RC_CALPAGEEMPTY; |
784 |
|
|
} |
785 |
|
|
} |
786 |
|
|
else{ |
787 |
|
|
status=CM_RC_NOPAGEAVAILABLE; |
788 |
|
|
} |
789 |
|
|
#if 0 |
790 |
|
|
/* /\* Check if a new SRAM cache page has to be selected: *\/ */ |
791 |
|
|
/* /\* - The last acquisition was good and need to be saved *\/ */ |
792 |
|
|
/* /\* - In the last acquisition the trash page was selected *\/ */ |
793 |
|
|
/* if((SM_PIFTrOk == TRUE && */ |
794 |
|
|
/* SM_EmptyPage == FALSE ) || */ |
795 |
|
|
/* SM_TrashFlag == TRUE) { */ |
796 |
|
|
/* /\* Check if there is any free SRAM page left *\/ */ |
797 |
|
|
/* if(SM_ExpPageCounter > 0) { */ |
798 |
|
|
/* SM_ExpPageCounter--; */ |
799 |
|
|
/* /\* Select the page 0 and the page 3 in a circulat buffer of *\/ */ |
800 |
|
|
/* /\* page 0 and page 3 *\/ */ |
801 |
|
|
/* SM_SelectedPage += 4; */ |
802 |
|
|
/* SM_SelectedPage &= 0x00000007; */ |
803 |
|
|
/* /\* Set the SRAM page to hold the incoming pkt *\/ */ |
804 |
|
|
/* SD_piSetDAQWritePage(SM_SelectedPage); */ |
805 |
|
|
/* /\* The selected page is not the trash one *\/ */ |
806 |
|
|
/* SM_TrashFlag = FALSE; */ |
807 |
|
|
/* } */ |
808 |
|
|
/* else { */ |
809 |
|
|
/* /\* No more free cache SRAM page left. The Trash one must be selected *\/ */ |
810 |
|
|
/* SD_piSetDAQWritePage(TRASHPAGE); */ |
811 |
|
|
/* SM_TrashFlag = TRUE; */ |
812 |
|
|
/* } */ |
813 |
|
|
/* } */ |
814 |
|
|
/* /\* If the last acquisition was not good then reselect the same SRAM page *\/ */ |
815 |
|
|
/* else */ |
816 |
|
|
/* SD_piSetDAQWritePage(SM_SelectedPage); */ |
817 |
|
|
|
818 |
|
|
/* if (SM_CalDataLenght[SM_CalPageSelected] > 0) */ |
819 |
|
|
/* { */ |
820 |
|
|
|
821 |
|
|
/* /\* Set the selected SRAM page where take data for *\/ */ |
822 |
|
|
/* /\* initialise instrument *\/ */ |
823 |
|
|
/* SD_piSetCMDBUSReadPage(SM_CalPageSelected); */ |
824 |
|
|
/* /\* Set end of data of selected page *\/ */ |
825 |
|
|
/* SD_piSetCMDBUSReadParams( */ |
826 |
|
|
/* (UINT32)(SM_CalPageSelected * SM_SRAMPAGESIZE + */ |
827 |
|
|
/* SM_CalDataLenght[SM_CalPageSelected]-1)); */ |
828 |
|
|
|
829 |
|
|
/* /\* Start the acquisition *\/ */ |
830 |
|
|
/* SD_piTrigData64Event(); */ |
831 |
|
|
/* /\* start transfer to CMD I/F *\/ */ |
832 |
|
|
/* SD_piStartTransferToCMD(); */ |
833 |
|
|
|
834 |
|
|
/* // PM_WRITE_PKT_HEADER_BEFORE(SM_SelectedPage); */ |
835 |
|
|
/* } */ |
836 |
|
|
#endif // 0 |
837 |
|
|
|
838 |
|
|
}break; |
839 |
|
|
} |
840 |
|
|
OS_piInterEnable(intLevel); |
841 |
|
|
} |
842 |
|
|
else |
843 |
|
|
{ |
844 |
|
|
/* HBUS is locked or an other storage is ongoing */ |
845 |
|
|
SM_LostTriggers++; |
846 |
|
|
status=CM_RC_BUSY; |
847 |
|
|
} |
848 |
|
|
/* Release the HBUS for an other transfer */ |
849 |
|
|
PM_opReleaseHBUS(); |
850 |
|
|
/* Clear ERC32 interrupt */ |
851 |
|
|
|
852 |
|
|
OS_piInterDisable(&intLevel); |
853 |
|
|
ERC32_Clear_interrupt(ETIRQ); |
854 |
|
|
ERC32_Unmask_interrupt(ETIRQ); |
855 |
|
|
OS_piInterEnable(intLevel); |
856 |
|
|
return status; |
857 |
|
|
#endif // SIMULATOR |
858 |
|
|
} |
859 |
|
|
|
860 |
|
|
void PM_opDisableStore_In_DataTimeOut() { |
861 |
|
|
SM_EnableStore = FALSE; |
862 |
|
|
} |
863 |
|
|
void PM_opEnableStore_In_DataTimeOut() { |
864 |
|
|
SM_EnableStore = TRUE; |
865 |
|
|
} |
866 |
|
|
|
867 |
|
|
BYTE PM_opSetPktType(BYTE pkttype) { |
868 |
|
|
BYTE old=SM_PktType; |
869 |
|
|
SM_PktType = pkttype; |
870 |
|
|
return old; |
871 |
|
|
} |
872 |
|
|
|
873 |
|
|
BYTE PM_opGetPktType() { |
874 |
|
|
return SM_PktType; |
875 |
|
|
} |
876 |
|
|
|
877 |
|
|
|
878 |
|
|
/*****************************************************************************/ |
879 |
|
|
/* @Function: PM_opPageHasData */ |
880 |
|
|
/* @Purpose : */ |
881 |
|
|
/* The function is used to tell the Page Manager that the last selected page*/ |
882 |
|
|
/* contains data written by the DAQ I/F. The Page Manager checks the data */ |
883 |
|
|
/* and send a "store" request to the MMSUManager. */ |
884 |
|
|
/* */ |
885 |
|
|
/* @@ */ |
886 |
|
|
/* @Parameter Name @Mode @Description */ |
887 |
|
|
/* @@ */ |
888 |
|
|
/*****************************************************************************/ |
889 |
|
|
|
890 |
|
|
static UINT32 counterleft=~0x00; |
891 |
|
|
void PM_opPageHasData(void) |
892 |
|
|
{ |
893 |
|
|
#ifdef SIMULATOR |
894 |
|
|
return; |
895 |
|
|
#else |
896 |
|
|
|
897 |
|
|
SD_DAQ_WRESULT pageInfo; |
898 |
|
|
unsigned int intLevel; |
899 |
|
|
static BYTE crc_pkt; |
900 |
|
|
unsigned int pkt_size; |
901 |
|
|
BOOL savepagecalled=FALSE; |
902 |
|
|
|
903 |
|
|
OS_piInterDisable(&intLevel); |
904 |
|
|
SD_piClearInt(SD_DATA_TO); |
905 |
|
|
OS_piInterEnable(intLevel); |
906 |
|
|
|
907 |
|
|
ERC32_Clear_interrupt(ERC32_INTERRUPT_EXTERNAL_2); |
908 |
|
|
|
909 |
|
|
counterleft=SD_piGetCMDCounterLeft(); |
910 |
|
|
|
911 |
|
|
switch(SM_AcqMode) { |
912 |
|
|
|
913 |
|
|
case SM_DIRECT: { |
914 |
|
|
/* Check if the packet buffer is not locked for read operation */ |
915 |
|
|
if(!SM_PktLock && |
916 |
|
|
!SD_piIsIntPending(SD_PAGE_OVR)) |
917 |
|
|
{ |
918 |
|
|
|
919 |
|
|
/* Evaluate the packet size in bytes */ |
920 |
|
|
SM_PktSize = pageInfo = SD_piGetDAQWriteResult(); |
921 |
|
|
SM_PktSize++; |
922 |
|
|
|
923 |
|
|
if (FT_piSavePage(SM_CALPAGE, SM_PktSize, FS_ERC32) != FT_SUCCESS) |
924 |
|
|
{ |
925 |
|
|
SM_ExpPageCounter=DIRECTPAGES; |
926 |
|
|
SM_ERC32LostPackets++; |
927 |
|
|
} |
928 |
|
|
else |
929 |
|
|
SM_ERC32IsOngoing=TRUE; |
930 |
|
|
/* Check if the packet is good */ |
931 |
|
|
if(SD_piIsDAQWriteOk() == SD_TRANSFEROK) |
932 |
|
|
SM_PktStatus = SM_PKT_GOOD; |
933 |
|
|
else |
934 |
|
|
{ |
935 |
|
|
SM_LostPackets++; |
936 |
|
|
SM_PktStatus = SM_PKT_BAD; |
937 |
|
|
} |
938 |
|
|
// TBD:Post to INFN: DAQPkt READY !!! |
939 |
|
|
/* Enable again the Event Trigger Interrupt*/ |
940 |
|
|
if(counterleft){ |
941 |
|
|
/*@LOG PageHasData: counterleft != 0 - counterleft*/ |
942 |
|
|
LU_INFN_LOG(LU_DEBUG_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,counterleft); |
943 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
944 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_UNCOMPLETED_CMDIF); |
945 |
|
|
}else |
946 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
947 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_PKT_READY); |
948 |
|
|
} |
949 |
|
|
else |
950 |
|
|
{ |
951 |
|
|
/* Clear the Page Overrun pending interrupt*/ |
952 |
|
|
if(SD_piIsIntPending(SD_PAGE_OVR)) |
953 |
|
|
{ |
954 |
|
|
SD_piClearInt(SD_PAGE_OVR); |
955 |
|
|
SM_EmptyPage = TRUE; |
956 |
|
|
} |
957 |
|
|
SM_PktStatus = SM_PKT_BAD; |
958 |
|
|
SM_ExpPageCounter=DIRECTPAGES; |
959 |
|
|
// console_outbyte_polled( 0, '@' ); |
960 |
|
|
// console_outbyte_polled( 0, '\n' ); |
961 |
|
|
} |
962 |
|
|
} break; |
963 |
|
|
|
964 |
|
|
/* Actions performed after an DTO in DAQSetup acq. mode */ |
965 |
|
|
case SM_DAQSETUP: { |
966 |
|
|
/* Check if the packet buffer is not locked for read operation */ |
967 |
|
|
if(!SM_PktLock && |
968 |
|
|
!SD_piIsIntPending(SD_PAGE_OVR)) |
969 |
|
|
{ |
970 |
|
|
/* Increase the packet counter */ |
971 |
|
|
|
972 |
|
|
/* Evaluate the packet size in bytes */ |
973 |
|
|
SM_PktSize = pageInfo = SD_piGetDAQWriteResult(); |
974 |
|
|
SM_PktSize++; |
975 |
|
|
|
976 |
|
|
/* Check if the packet is good */ |
977 |
|
|
if(SD_piIsDAQWriteOk() == SD_TRANSFEROK) |
978 |
|
|
SM_PktStatus = SM_PKT_GOOD; |
979 |
|
|
else |
980 |
|
|
{ |
981 |
|
|
SM_LostPackets++; |
982 |
|
|
SM_PktStatus = SM_PKT_BAD; |
983 |
|
|
} |
984 |
|
|
|
985 |
|
|
|
986 |
|
|
PM_WRITE_PKT_HEADER(SM_CALPAGE,SM_PktSize,crc_pkt); |
987 |
|
|
PM_INC_PKT_COUNTER(); |
988 |
|
|
|
989 |
|
|
savepagecalled=FALSE; |
990 |
|
|
/* Put a save request for the selected SRAM page in the save queue*/ |
991 |
|
|
if(SM_PktRamCpyFlag) |
992 |
|
|
if (FT_piSavePage(SM_CALPAGE, pageInfo, FS_ERC32) != FT_SUCCESS) |
993 |
|
|
SM_ERC32LostPackets++; |
994 |
|
|
else{ |
995 |
|
|
SM_ERC32IsOngoing=TRUE; |
996 |
|
|
savepagecalled=TRUE; |
997 |
|
|
} |
998 |
|
|
|
999 |
|
|
if(SM_EnableStore) |
1000 |
|
|
if (FT_piSavePage(SM_CALPAGE, pageInfo, FS_FILE1) != FT_SUCCESS) |
1001 |
|
|
SM_MMSULostPackets++; |
1002 |
|
|
else{ |
1003 |
|
|
SM_PacketStoreIsOngoing=TRUE; |
1004 |
|
|
savepagecalled=TRUE; |
1005 |
|
|
} |
1006 |
|
|
|
1007 |
|
|
if(!savepagecalled){ |
1008 |
|
|
SM_ExpPageCounter=DAQSETUPPAGES; |
1009 |
|
|
// console_outbyte_polled( 0, '@' ); |
1010 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1011 |
|
|
} |
1012 |
|
|
// console_outbyte_polled( 0, 'y' ); |
1013 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1014 |
|
|
|
1015 |
|
|
if(counterleft){ |
1016 |
|
|
/*@LOG PageHasData: counterleft != 0 - counterleft*/ |
1017 |
|
|
LU_INFN_LOG(LU_DEBUG_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,counterleft); |
1018 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
1019 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_UNCOMPLETED_CMDIF); |
1020 |
|
|
}else |
1021 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
1022 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_PKT_READY); |
1023 |
|
|
} |
1024 |
|
|
else |
1025 |
|
|
{ |
1026 |
|
|
/* Clear the Page Overrun pending interrupt*/ |
1027 |
|
|
if(SD_piIsIntPending(SD_PAGE_OVR)) |
1028 |
|
|
{ |
1029 |
|
|
SD_piClearInt(SD_PAGE_OVR); |
1030 |
|
|
SM_EmptyPage = TRUE; |
1031 |
|
|
} |
1032 |
|
|
SM_LostPackets++; |
1033 |
|
|
/* this counter is increased only because is reported in RTF */ |
1034 |
|
|
SM_LostTriggers++; |
1035 |
|
|
/* The transfer is complete then enalble an other acquisition */ |
1036 |
|
|
SM_ExpPageCounter=DAQSETUPPAGES; |
1037 |
|
|
// console_outbyte_polled( 0, '@' ); |
1038 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1039 |
|
|
} |
1040 |
|
|
} break; |
1041 |
|
|
|
1042 |
|
|
case SM_EXP64: |
1043 |
|
|
{ |
1044 |
|
|
// SM_exp64_t2=SM_exp64_t1; |
1045 |
|
|
/* Actions performed after an DTO in experiment acq. mode */ |
1046 |
|
|
SM_EmptyPage = FALSE; |
1047 |
|
|
/* Check if the packet is good */ |
1048 |
|
|
/* |
1049 |
|
|
SM_PIFTrOk = SD_piIsDAQWriteOk(); |
1050 |
|
|
if(SM_TrashFlag == FALSE && |
1051 |
|
|
SM_PIFTrOk == SD_TRANSFEROK && |
1052 |
|
|
!SD_piIsIntPending(SD_PAGE_OVR)) |
1053 |
|
|
*/ |
1054 |
|
|
if(!SD_piIsIntPending(SD_PAGE_OVR)) |
1055 |
|
|
{ |
1056 |
|
|
/* Get the paket end address in SRAM */ |
1057 |
|
|
SM_PktSize = pageInfo = SD_piGetDAQWriteResult() ; |
1058 |
|
|
SM_PktSize++; |
1059 |
|
|
SM_PktSize -= (SM_SelectedPage * SM_SRAMPAGESIZE); |
1060 |
|
|
/* Increase the packet counter */ |
1061 |
|
|
#if 0 |
1062 |
|
|
if(PRH_VAR_RM_IDAQONLYACQ_ADDON_SIZE) { |
1063 |
|
|
SM_PktSize += CM_RAND(PRH_VAR_RM_IDAQONLYACQ_ADDON_SIZE); |
1064 |
|
|
if(SM_PktSize > SM_SRAMPAGESIZE64) |
1065 |
|
|
SM_PktSize=SM_SRAMPAGESIZE64; |
1066 |
|
|
pageInfo = SM_PktSize + (SM_SelectedPage * SM_SRAMPAGESIZE) -1; |
1067 |
|
|
} |
1068 |
|
|
#endif |
1069 |
|
|
/* Check if the packet is good */ |
1070 |
|
|
if(SD_piIsDAQWriteOk() == SD_TRANSFEROK) |
1071 |
|
|
SM_PktStatus = SM_PKT_GOOD; |
1072 |
|
|
else |
1073 |
|
|
{ |
1074 |
|
|
SM_LostPackets++; |
1075 |
|
|
SM_PktStatus = SM_PKT_BAD; |
1076 |
|
|
} |
1077 |
|
|
|
1078 |
|
|
PM_WRITE_PKT_HEADER(SM_SelectedPage,SM_PktSize,crc_pkt); |
1079 |
|
|
PM_INC_PKT_COUNTER(); |
1080 |
|
|
|
1081 |
|
|
savepagecalled=FALSE; |
1082 |
|
|
|
1083 |
|
|
|
1084 |
|
|
/* Check if it's time to copy the packet into RAM */ |
1085 |
|
|
if(SM_PktRamCpyFlag) |
1086 |
|
|
{ |
1087 |
|
|
if(FT_piSavePage(SM_SelectedPage, pageInfo, FS_ERC32) != FT_SUCCESS) |
1088 |
|
|
SM_ERC32LostPackets++; |
1089 |
|
|
else |
1090 |
|
|
{ |
1091 |
|
|
SM_ERC32IsOngoing=TRUE; |
1092 |
|
|
savepagecalled=TRUE; |
1093 |
|
|
} |
1094 |
|
|
} |
1095 |
|
|
/* Put a save request for the selected SRAM page in the save queue*/ |
1096 |
|
|
if(SM_EnableStore) |
1097 |
|
|
if(FT_piSavePage(SM_SelectedPage, pageInfo, FS_FILE1) != FT_SUCCESS) |
1098 |
|
|
{ |
1099 |
|
|
/* The save request was refused so the current page can be immediatly */ |
1100 |
|
|
/* reused */ |
1101 |
|
|
SM_EmptyPage = TRUE; |
1102 |
|
|
/* A packet was lost */ |
1103 |
|
|
SM_MMSULostPackets++; |
1104 |
|
|
} |
1105 |
|
|
else |
1106 |
|
|
{ |
1107 |
|
|
savepagecalled=TRUE; |
1108 |
|
|
SM_PacketStoreIsOngoing=TRUE; |
1109 |
|
|
} |
1110 |
|
|
|
1111 |
|
|
if(!savepagecalled) |
1112 |
|
|
if(++SM_ExpPageCounter > EXP64PAGES) |
1113 |
|
|
{ |
1114 |
|
|
SM_ExpPageCounter = EXP64PAGES; |
1115 |
|
|
} |
1116 |
|
|
|
1117 |
|
|
|
1118 |
|
|
if(counterleft){ |
1119 |
|
|
/*@LOG PageHasData: counterleft != 0 - counterleft*/ |
1120 |
|
|
LU_INFN_LOG(LU_DEBUG_TRACE,LU_MASK(__FILEID__),__FILEID__,__LINE__,counterleft); |
1121 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
1122 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_UNCOMPLETED_CMDIF); |
1123 |
|
|
}else |
1124 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
1125 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_PKT_READY); |
1126 |
|
|
} |
1127 |
|
|
else |
1128 |
|
|
/* The packet is not good */ |
1129 |
|
|
{ |
1130 |
|
|
/* Clear the Page Overrun pending interrupt*/ |
1131 |
|
|
if(SD_piIsIntPending(SD_PAGE_OVR)) |
1132 |
|
|
{ |
1133 |
|
|
SD_piClearInt(SD_PAGE_OVR); |
1134 |
|
|
SM_EmptyPage = TRUE; |
1135 |
|
|
} |
1136 |
|
|
SM_LostPackets++; |
1137 |
|
|
SM_LostTriggers++; |
1138 |
|
|
if(++SM_ExpPageCounter > EXP64PAGES) |
1139 |
|
|
{ |
1140 |
|
|
SM_ExpPageCounter = EXP64PAGES; |
1141 |
|
|
} |
1142 |
|
|
} |
1143 |
|
|
} break; |
1144 |
|
|
default:{ |
1145 |
|
|
/*@LOG Unespected Data Timeout LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_SM,HA_E10_UNESPECTED_DTO,HA_E10_REP2_NULL); */ |
1146 |
|
|
LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,HA_E10_REP2_NULL); |
1147 |
|
|
} |
1148 |
|
|
} |
1149 |
|
|
#endif // SIMULATOR |
1150 |
|
|
} |
1151 |
|
|
|
1152 |
|
|
|
1153 |
|
|
|
1154 |
|
|
|
1155 |
|
|
|
1156 |
|
|
#ifdef DEBUG |
1157 |
|
|
status_code PM_opPreparePage_dummy() |
1158 |
|
|
{ |
1159 |
|
|
unsigned int intLevel; |
1160 |
|
|
status_code status=CM_RC_SUCCESSFUL; |
1161 |
|
|
OS_piInterDisable(&intLevel); |
1162 |
|
|
SD_piSetDAQWritePage(SM_CALPAGE); |
1163 |
|
|
if(SM_ExpPageCounter > 0) { |
1164 |
|
|
SM_ExpPageCounter--; |
1165 |
|
|
SM_SelectedPage =0; |
1166 |
|
|
} |
1167 |
|
|
else{ |
1168 |
|
|
status=CM_RC_NOPAGEAVAILABLE; |
1169 |
|
|
} |
1170 |
|
|
OS_piInterEnable(intLevel); |
1171 |
|
|
return status; |
1172 |
|
|
} |
1173 |
|
|
#endif // DEBUG |
1174 |
|
|
|
1175 |
|
|
|
1176 |
|
|
|
1177 |
|
|
|
1178 |
|
|
/*****************************************************************************/ |
1179 |
|
|
/* @Function: PM_opPageIsEmpty */ |
1180 |
|
|
/* @Purpose : */ |
1181 |
|
|
/* The function is used to tell the Page Manager that the last selected page*/ |
1182 |
|
|
/* was not written by the DAQ I/F. */ |
1183 |
|
|
/* selected */ |
1184 |
|
|
/* */ |
1185 |
|
|
/* @@ */ |
1186 |
|
|
/* @Parameter Name @Mode @Description */ |
1187 |
|
|
/* @@ */ |
1188 |
|
|
/*****************************************************************************/ |
1189 |
|
|
|
1190 |
|
|
void PM_opPageIsEmpty(void) |
1191 |
|
|
{ |
1192 |
|
|
unsigned int intLevel; |
1193 |
|
|
|
1194 |
|
|
/* The packet was lost*/ |
1195 |
|
|
SM_ETOLostPackets++; |
1196 |
|
|
SM_LostTriggers++; |
1197 |
|
|
|
1198 |
|
|
if(SM_NotifyTask_PKT_READY != NULL_TASK) |
1199 |
|
|
OS_piEventSend(SM_NotifyTask_PKT_READY,OS_EVENT_ETO); |
1200 |
|
|
|
1201 |
|
|
switch(SM_AcqMode) { |
1202 |
|
|
/* Actions performed after an ETO in DAQSetup acq. mode */ |
1203 |
|
|
case SM_DIRECT: |
1204 |
|
|
case SM_DAQSETUP: |
1205 |
|
|
SM_ExpPageCounter=DIRECTPAGES; |
1206 |
|
|
// console_outbyte_polled( 0, '@' ); |
1207 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1208 |
|
|
break; |
1209 |
|
|
case SM_EXP64: |
1210 |
|
|
if(++SM_ExpPageCounter > EXP64PAGES) |
1211 |
|
|
{ |
1212 |
|
|
SM_ExpPageCounter = EXP64PAGES; |
1213 |
|
|
} |
1214 |
|
|
break; |
1215 |
|
|
} |
1216 |
|
|
|
1217 |
|
|
/* Clear the Event Timeout interrupt */ |
1218 |
|
|
OS_piInterDisable(&intLevel); |
1219 |
|
|
SD_piClearInt(SD_EVT_TO); |
1220 |
|
|
OS_piInterEnable(intLevel); |
1221 |
|
|
} |
1222 |
|
|
|
1223 |
|
|
/*****************************************************************************/ |
1224 |
|
|
/* @Function: PM_opPageWasSaved */ |
1225 |
|
|
/* @Purpose : */ |
1226 |
|
|
/* The function tels the Page Manager that a SRAM page was saved in MMSU and*/ |
1227 |
|
|
/* can be reused */ |
1228 |
|
|
/* */ |
1229 |
|
|
/* @@ */ |
1230 |
|
|
/* @Parameter Name @Mode @Description */ |
1231 |
|
|
/* @@ */ |
1232 |
|
|
/*****************************************************************************/ |
1233 |
|
|
|
1234 |
|
|
void PM_opPageWasSaved(FS_FILEID FileId) |
1235 |
|
|
{ |
1236 |
|
|
unsigned int intLevel; |
1237 |
|
|
switch (FileId) |
1238 |
|
|
{ |
1239 |
|
|
case FS_FILE1: |
1240 |
|
|
{ |
1241 |
|
|
switch(SM_AcqMode) |
1242 |
|
|
{ |
1243 |
|
|
case SM_EXP64: |
1244 |
|
|
{ |
1245 |
|
|
OS_piInterDisable(&intLevel); |
1246 |
|
|
SM_PacketStoreIsOngoing=FALSE; |
1247 |
|
|
/* Increment the number free available SRAM page */ |
1248 |
|
|
if(SM_ERC32IsOngoing==FALSE){ |
1249 |
|
|
SM_ExpPageCounter++; |
1250 |
|
|
if(SM_ExpPageCounter > EXP64PAGES) |
1251 |
|
|
{ |
1252 |
|
|
SM_ExpPageCounter = EXP64PAGES; |
1253 |
|
|
} |
1254 |
|
|
} |
1255 |
|
|
OS_piInterEnable(intLevel); |
1256 |
|
|
} break; |
1257 |
|
|
case SM_DAQSETUP: |
1258 |
|
|
{ |
1259 |
|
|
OS_piInterDisable(&intLevel); |
1260 |
|
|
SM_PacketStoreIsOngoing=FALSE; |
1261 |
|
|
/* Increment the number free available SRAM page */ |
1262 |
|
|
if(SM_ERC32IsOngoing==FALSE){ |
1263 |
|
|
SM_ExpPageCounter=DAQSETUPPAGES; |
1264 |
|
|
// console_outbyte_polled( 0, 'Y' ); |
1265 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1266 |
|
|
} |
1267 |
|
|
OS_piInterEnable(intLevel); |
1268 |
|
|
} break; |
1269 |
|
|
case SM_DIRECT: |
1270 |
|
|
break; |
1271 |
|
|
default: |
1272 |
|
|
break; |
1273 |
|
|
} |
1274 |
|
|
} break; |
1275 |
|
|
case FS_HK: |
1276 |
|
|
{ |
1277 |
|
|
/* Unlock the schetchboard page as soon as it is saved*/ |
1278 |
|
|
SM_SavingSkatchboard = FALSE; |
1279 |
|
|
if(SM_NotifyTask_SKETCHBOARD_FREE != NULL_TASK) |
1280 |
|
|
OS_piEventSend(SM_NotifyTask_SKETCHBOARD_FREE,OS_EVENT_SKETCHBOARD_FREE); |
1281 |
|
|
} break; |
1282 |
|
|
case FS_ERC32: |
1283 |
|
|
{ |
1284 |
|
|
switch(SM_AcqMode) |
1285 |
|
|
{ |
1286 |
|
|
case SM_DIRECT: |
1287 |
|
|
case SM_DAQSETUP: |
1288 |
|
|
OS_piInterDisable(&intLevel); |
1289 |
|
|
SM_ERC32IsOngoing=FALSE; |
1290 |
|
|
if(SM_PacketStoreIsOngoing==FALSE){ |
1291 |
|
|
SM_ExpPageCounter=DIRECTPAGES; |
1292 |
|
|
// console_outbyte_polled( 0, 'Z' ); |
1293 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1294 |
|
|
} |
1295 |
|
|
OS_piInterEnable(intLevel); |
1296 |
|
|
break; |
1297 |
|
|
case SM_EXP64: |
1298 |
|
|
OS_piInterDisable(&intLevel); |
1299 |
|
|
SM_ERC32IsOngoing=FALSE; |
1300 |
|
|
if(SM_PacketStoreIsOngoing==FALSE){ |
1301 |
|
|
SM_ExpPageCounter++; |
1302 |
|
|
if(SM_ExpPageCounter > EXP64PAGES) |
1303 |
|
|
{ |
1304 |
|
|
SM_ExpPageCounter = EXP64PAGES; |
1305 |
|
|
} |
1306 |
|
|
} |
1307 |
|
|
OS_piInterEnable(intLevel); |
1308 |
|
|
break; |
1309 |
|
|
} |
1310 |
|
|
} break; |
1311 |
|
|
case FS_CMD: |
1312 |
|
|
break; |
1313 |
|
|
default: |
1314 |
|
|
break; |
1315 |
|
|
} |
1316 |
|
|
} |
1317 |
|
|
|
1318 |
|
|
/*****************************************************************************/ |
1319 |
|
|
/* @Function: PM_op_SetAcqMode */ |
1320 |
|
|
/* @Purpose : */ |
1321 |
|
|
/* The function selects the operational mode for the Page Manager: */ |
1322 |
|
|
/* science data or calibration. The transition is possible only if in the */ |
1323 |
|
|
/* curent mode there are no more SRAM page to store into MMSU */ |
1324 |
|
|
/* Due to the fact that the SRAM is a shared resource between the */ |
1325 |
|
|
/* acquisition and the mass memory store automas, this function highly */ |
1326 |
|
|
/* coupled with the MMSUManager Enable/Disable store functions. */ |
1327 |
|
|
/* */ |
1328 |
|
|
/* @@ */ |
1329 |
|
|
/* @Parameter Name @Mode @Description */ |
1330 |
|
|
/* SM_EXITCODE OUT Return code */ |
1331 |
|
|
/* @@ */ |
1332 |
|
|
/*****************************************************************************/ |
1333 |
|
|
|
1334 |
|
|
SM_EXITCODE PM_op_SetAcqMode(SM_ACQMODE mode) |
1335 |
|
|
{ |
1336 |
|
|
SM_EXITCODE status = SM_SUCCESS; |
1337 |
|
|
UINT32 idx; |
1338 |
|
|
unsigned int intLevel; |
1339 |
|
|
|
1340 |
|
|
/* Mask any interrupt related to acquisition activity */ |
1341 |
|
|
OS_piInterDisable(&intLevel); |
1342 |
|
|
SD_piMaskInt(SD_EVT_TO | SD_DATA_TO | SD_PAGE_OVR); |
1343 |
|
|
ERC32_Mask_interrupt(ETIRQ); |
1344 |
|
|
OS_piInterEnable(intLevel); |
1345 |
|
|
PM_opReleaseHBUS(); |
1346 |
|
|
SM_ERC32IsOngoing=FALSE; |
1347 |
|
|
SM_PacketStoreIsOngoing = FALSE; |
1348 |
|
|
|
1349 |
|
|
switch(mode) { |
1350 |
|
|
/* Enter the Direct Mode mode */ |
1351 |
|
|
case SM_DIRECT: |
1352 |
|
|
{ |
1353 |
|
|
SD_piSetCalibrationHeaderLength(0); |
1354 |
|
|
SM_AcqMode = SM_DIRECT; |
1355 |
|
|
/* Init the last recieved packet status to a */ |
1356 |
|
|
/* "to be acquired" condition */ |
1357 |
|
|
SM_PktStatus = SM_PKT_ACQ; |
1358 |
|
|
/* Enable the skatchboard usage */ |
1359 |
|
|
SM_SavingSkatchboard = FALSE; |
1360 |
|
|
/**/ |
1361 |
|
|
SM_ExpPageCounter = DIRECTPAGES; |
1362 |
|
|
if(SM_NotifyTask_SKETCHBOARD_FREE != NULL_TASK) |
1363 |
|
|
OS_piEventSend(SM_NotifyTask_SKETCHBOARD_FREE,OS_EVENT_SKETCHBOARD_FREE); |
1364 |
|
|
/* Clear and unmask all the acquisition related interrupts */ |
1365 |
|
|
ERC32_Clear_interrupt(ETIRQ); |
1366 |
|
|
OS_piInterDisable(&intLevel); |
1367 |
|
|
SD_piClearInt(SD_EVT_TO | SD_DATA_TO | SD_PAGE_OVR); |
1368 |
|
|
SD_piUnMaskInt(SD_EVT_TO | SD_DATA_TO); |
1369 |
|
|
OS_piInterEnable(intLevel); |
1370 |
|
|
ERC32_Unmask_interrupt(ETIRQ); |
1371 |
|
|
} break; |
1372 |
|
|
|
1373 |
|
|
/* Enter the DAQSetup mode */ |
1374 |
|
|
case SM_DAQSETUP: |
1375 |
|
|
{ |
1376 |
|
|
SD_piSetCalibrationHeaderLength(SM_PKTHEADER_LEN); |
1377 |
|
|
SM_AcqMode = SM_DAQSETUP; |
1378 |
|
|
/* Init the last recieved packet status to a */ |
1379 |
|
|
/* "to be acquired" condition */ |
1380 |
|
|
SM_PktStatus = SM_PKT_ACQ; |
1381 |
|
|
/* Enable the skatchboard usage */ |
1382 |
|
|
SM_SavingSkatchboard = FALSE; |
1383 |
|
|
SM_ExpPageCounter = DAQSETUPPAGES; |
1384 |
|
|
// console_outbyte_polled( 0, '9' ); |
1385 |
|
|
// console_outbyte_polled( 0, '\n' ); |
1386 |
|
|
if(SM_NotifyTask_SKETCHBOARD_FREE != NULL_TASK) |
1387 |
|
|
OS_piEventSend(SM_NotifyTask_SKETCHBOARD_FREE,OS_EVENT_SKETCHBOARD_FREE); |
1388 |
|
|
/* Clear and unmask all the acquisition related interrupts */ |
1389 |
|
|
ERC32_Clear_interrupt(ETIRQ); |
1390 |
|
|
OS_piInterDisable(&intLevel); |
1391 |
|
|
SD_piClearInt(SD_EVT_TO | SD_DATA_TO | SD_PAGE_OVR); |
1392 |
|
|
SD_piUnMaskInt(SD_EVT_TO | SD_DATA_TO); |
1393 |
|
|
OS_piInterEnable(intLevel); |
1394 |
|
|
ERC32_Unmask_interrupt(ETIRQ); |
1395 |
|
|
} break; |
1396 |
|
|
|
1397 |
|
|
#if 0 |
1398 |
|
|
/* Enter the Experiment mode */ |
1399 |
|
|
case SM_EXPERIMENT: |
1400 |
|
|
{ |
1401 |
|
|
SD_piSetCalibrationHeaderLength(SM_PKTHEADER_LEN); |
1402 |
|
|
SM_AcqMode = SM_EXPERIMENT; |
1403 |
|
|
/* Force the Caching automa to select a brand new SRAM page */ |
1404 |
|
|
SM_TrashFlag = TRUE; |
1405 |
|
|
SM_SelectedPage = 0; |
1406 |
|
|
SM_EmptyPage = TRUE; |
1407 |
|
|
SM_ExpPageCounter = EXPPAGES; |
1408 |
|
|
/* Init the last recieved packet status to a */ |
1409 |
|
|
/* "to be acquired" condition */ |
1410 |
|
|
SM_PktStatus = SM_PKT_ACQ; |
1411 |
|
|
/* Reset the SRAM to RAM triggrer counter */ |
1412 |
|
|
/* Enable the skatchboard usage */ |
1413 |
|
|
SM_SavingSkatchboard = FALSE; |
1414 |
|
|
if(SM_NotifyTask_SKETCHBOARD_FREE != NULL_TASK) |
1415 |
|
|
OS_piEventSend(SM_NotifyTask_SKETCHBOARD_FREE,OS_EVENT_SKETCHBOARD_FREE); |
1416 |
|
|
/* Clear and unmask all the acquisition related interrupts */ |
1417 |
|
|
OS_piInterDisable(&intLevel); |
1418 |
|
|
SD_piClearInt(SD_EVT_TO | SD_DATA_TO | SD_PAGE_OVR); |
1419 |
|
|
SD_piUnMaskInt(SD_EVT_TO | SD_DATA_TO); |
1420 |
|
|
OS_piInterEnable(intLevel); |
1421 |
|
|
ERC32_Clear_interrupt(ETIRQ); |
1422 |
|
|
ERC32_Unmask_interrupt(ETIRQ); |
1423 |
|
|
} break; |
1424 |
|
|
#endif |
1425 |
|
|
/* Enter the Experiment mode */ |
1426 |
|
|
case SM_EXP64: |
1427 |
|
|
{ |
1428 |
|
|
SD_piSetCalibrationHeaderLength(SM_PKTHEADER_LEN); |
1429 |
|
|
SM_AcqMode = SM_EXP64; |
1430 |
|
|
/* Force the Caching automa to select a brand new SRAM page */ |
1431 |
|
|
SM_SelectedPage = 0; |
1432 |
|
|
SM_EmptyPage = TRUE; |
1433 |
|
|
SM_ExpPageCounter = EXP64PAGES; |
1434 |
|
|
/* Init the last recieved packet status to a */ |
1435 |
|
|
/* "to be acquired" condition */ |
1436 |
|
|
SM_PktStatus = SM_PKT_ACQ; |
1437 |
|
|
/* Reset the SRAM to RAM triggrer counter */ |
1438 |
|
|
/* Enable the skatchboard usage */ |
1439 |
|
|
SM_SavingSkatchboard = FALSE; |
1440 |
|
|
if(SM_NotifyTask_SKETCHBOARD_FREE != NULL_TASK) |
1441 |
|
|
OS_piEventSend(SM_NotifyTask_SKETCHBOARD_FREE,OS_EVENT_SKETCHBOARD_FREE); |
1442 |
|
|
/* Clear and unmask all the acquisition related interrupts */ |
1443 |
|
|
OS_piInterDisable(&intLevel); |
1444 |
|
|
SD_piClearInt(SD_EVT_TO | SD_DATA_TO | SD_PAGE_OVR); |
1445 |
|
|
SD_piUnMaskInt(SD_EVT_TO | SD_DATA_TO); |
1446 |
|
|
OS_piInterEnable(intLevel); |
1447 |
|
|
ERC32_Clear_interrupt(ETIRQ); |
1448 |
|
|
ERC32_Unmask_interrupt(ETIRQ); |
1449 |
|
|
} break; |
1450 |
|
|
|
1451 |
|
|
/* Enter the Idle mode */ |
1452 |
|
|
case SM_IDLE: |
1453 |
|
|
{ |
1454 |
|
|
SM_AcqMode = SM_IDLE; |
1455 |
|
|
} break; |
1456 |
|
|
default:{ |
1457 |
|
|
status = SM_WRONGACQMODE; |
1458 |
|
|
} |
1459 |
|
|
} |
1460 |
|
|
return (status); |
1461 |
|
|
} |
1462 |
|
|
|
1463 |
|
|
/*****************************************************************************/ |
1464 |
|
|
/* @Function: PM_op_GetAcqMode */ |
1465 |
|
|
/* @Purpose : */ |
1466 |
|
|
/* The function return the current acquisition mode */ |
1467 |
|
|
/* */ |
1468 |
|
|
/* @@ */ |
1469 |
|
|
/* @Parameter Name @Mode @Description */ |
1470 |
|
|
/* SM_ACQMODE OUT acquisition mode */ |
1471 |
|
|
/* @@ */ |
1472 |
|
|
/*****************************************************************************/ |
1473 |
|
|
|
1474 |
|
|
SM_ACQMODE PM_op_GetAcqMode(void) |
1475 |
|
|
{ |
1476 |
|
|
/* Return the current acquisition mode */ |
1477 |
|
|
return (SM_AcqMode); |
1478 |
|
|
} |
1479 |
|
|
|
1480 |
|
|
/*****************************************************************************/ |
1481 |
|
|
/* @Function: PM_op_GetLostPktCounter */ |
1482 |
|
|
/* @Purpose : */ |
1483 |
|
|
/* The function return the lost Event Trigger counter */ |
1484 |
|
|
/* */ |
1485 |
|
|
/* @@ */ |
1486 |
|
|
/* @Parameter Name @Mode @Description */ |
1487 |
|
|
/* @@ */ |
1488 |
|
|
/*****************************************************************************/ |
1489 |
|
|
|
1490 |
|
|
void PM_op_GetLostPktCounter(UINT32* Counter) |
1491 |
|
|
{ |
1492 |
|
|
unsigned int intLevel; |
1493 |
|
|
|
1494 |
|
|
/* Return the lost packets counter */ |
1495 |
|
|
OS_piInterDisable(&intLevel); |
1496 |
|
|
*Counter = SM_LostTriggers; |
1497 |
|
|
OS_piInterEnable(intLevel); |
1498 |
|
|
} |
1499 |
|
|
|
1500 |
|
|
/*****************************************************************************/ |
1501 |
|
|
/* @Function: PM_op_GetPacket */ |
1502 |
|
|
/* @Purpose : */ |
1503 |
|
|
/* The function return a packet from PIF SRAM Memory */ |
1504 |
|
|
/* */ |
1505 |
|
|
/* @@ */ |
1506 |
|
|
/* @Parameter Name @Mode @Description */ |
1507 |
|
|
/* SM_PKTSTAT OUT acquisition result */ |
1508 |
|
|
/* PtrPkt OUT Pointer to the caller packet buffer */ |
1509 |
|
|
/* Size OUT Size of the packet copied into buffer */ |
1510 |
|
|
/* @@ */ |
1511 |
|
|
/*****************************************************************************/ |
1512 |
|
|
|
1513 |
|
|
SM_PKTSTAT PM_op_GetPacket(UINT32* Size, void* PtrPkt) |
1514 |
|
|
{ |
1515 |
|
|
SM_PKTSTAT pktStat; |
1516 |
|
|
unsigned int intLevel; |
1517 |
|
|
FS_FILE_DESCR fd; |
1518 |
|
|
|
1519 |
|
|
if (PM_opLockHBUS() == SM_SUCCESS) |
1520 |
|
|
{ |
1521 |
|
|
/* Lock the buffer in read mode */ |
1522 |
|
|
OS_piInterDisable(&intLevel); |
1523 |
|
|
SM_PktLock = TRUE; |
1524 |
|
|
OS_piInterEnable(intLevel); |
1525 |
|
|
/* return the packet status */ |
1526 |
|
|
pktStat = SM_PktStatus; |
1527 |
|
|
|
1528 |
|
|
FS_piGetFileInfo(FS_ERC32, &fd); |
1529 |
|
|
/* If the paket is good then copy it to the provided destination */ |
1530 |
|
|
if(SM_PktStatus == SM_PKT_GOOD) |
1531 |
|
|
{ |
1532 |
|
|
memcpy(PtrPkt, (void*)fd.WriteAddr, SM_PktSize); |
1533 |
|
|
*Size = SM_PktSize; |
1534 |
|
|
} |
1535 |
|
|
/* Unlock the buffer */ |
1536 |
|
|
OS_piInterDisable(&intLevel); |
1537 |
|
|
SM_PktLock = FALSE; |
1538 |
|
|
OS_piInterEnable(intLevel); |
1539 |
|
|
PM_opReleaseHBUS(); |
1540 |
|
|
} |
1541 |
|
|
else |
1542 |
|
|
pktStat = SM_PKT_ACQ; |
1543 |
|
|
return (pktStat); |
1544 |
|
|
} |
1545 |
|
|
|
1546 |
|
|
/*****************************************************************************/ |
1547 |
|
|
/* @Function: PM_op_StorePacket */ |
1548 |
|
|
/* @Purpose : */ |
1549 |
|
|
/* The function starts all the operations needed to store the given packet */ |
1550 |
|
|
/* in the selected file. If the result is good it means that the store */ |
1551 |
|
|
/* request was successfuly accepted. The store of the packet can still fail */ |
1552 |
|
|
/* */ |
1553 |
|
|
/* @@ */ |
1554 |
|
|
/* @Parameter Name @Mode @Description */ |
1555 |
|
|
/* SM_STRSTAT OUT Store request result */ |
1556 |
|
|
/* PtrPkt IN Pointer to the caller packet buffer */ |
1557 |
|
|
/* Size IN Size of the packet to be copied into FileId */ |
1558 |
|
|
/* in bytes */ |
1559 |
|
|
/* FileID IN Destination file */ |
1560 |
|
|
/* @@ */ |
1561 |
|
|
/*****************************************************************************/ |
1562 |
|
|
|
1563 |
|
|
SM_STRSTAT PM_op_StorePacket(UINT32 Size, void* PtrPkt, FS_FILEID FileId) |
1564 |
|
|
{ |
1565 |
|
|
SM_STRSTAT strStat = SM_STR_OK; |
1566 |
|
|
SD_DAQ_WRESULT pageInfo; |
1567 |
|
|
|
1568 |
|
|
/* Check the FileID */ |
1569 |
|
|
if(FileId == FS_REGFILES || FileId == FS_MAXID) |
1570 |
|
|
{ |
1571 |
|
|
strStat = SM_STR_WRONGFILE; |
1572 |
|
|
} |
1573 |
|
|
/* Check the packet size */ |
1574 |
|
|
if(Size == 0 || Size > SM_SKETCHSIZE) |
1575 |
|
|
{ |
1576 |
|
|
strStat = SM_STR_WRIONGSIZE; |
1577 |
|
|
} |
1578 |
|
|
/* Check if the skatchboard is in use */ |
1579 |
|
|
if(SM_SavingSkatchboard == TRUE) |
1580 |
|
|
{ |
1581 |
|
|
strStat = SM_STR_BUSY; |
1582 |
|
|
} |
1583 |
|
|
|
1584 |
|
|
if (strStat == SM_STR_OK) |
1585 |
|
|
{ |
1586 |
|
|
/* Copy the provided packet into SRAM skatchboard */ |
1587 |
|
|
if(PtrPkt != NULL) |
1588 |
|
|
SM_ifCopyToSRAM((UINT32)(SM_SKETCHBOARD * SM_SRAMPAGESIZE), |
1589 |
|
|
(void*)PtrPkt, Size); |
1590 |
|
|
|
1591 |
|
|
/* Put a save request for the skatchboard SRAM page in the save queue*/ |
1592 |
|
|
pageInfo = (UINT32)(SM_SKETCHBOARD * SM_SRAMPAGESIZE) + Size - 1; |
1593 |
|
|
/* The save request was accepted */ |
1594 |
|
|
/* so lock the skatchboard page: assume here that it will have success */ |
1595 |
|
|
SM_SavingSkatchboard = TRUE; |
1596 |
|
|
if(FT_piSavePage(SM_SKETCHBOARD, pageInfo, FileId) != FT_SUCCESS) |
1597 |
|
|
{ |
1598 |
|
|
/* The save request was refused */ |
1599 |
|
|
strStat = SM_STR_FAILED; |
1600 |
|
|
|
1601 |
|
|
SM_SavingSkatchboard = FALSE; |
1602 |
|
|
if(SM_NotifyTask_SKETCHBOARD_FREE != NULL_TASK) |
1603 |
|
|
OS_piEventSend(SM_NotifyTask_SKETCHBOARD_FREE,OS_EVENT_SKETCHBOARD_FREE); |
1604 |
|
|
|
1605 |
|
|
} |
1606 |
|
|
|
1607 |
|
|
} |
1608 |
|
|
|
1609 |
|
|
return (strStat); |
1610 |
|
|
} |
1611 |
|
|
|
1612 |
|
|
/*****************************************************************************/ |
1613 |
|
|
/* @Function: PM_op_SetExpPktCpyFlag */ |
1614 |
|
|
/* @Purpose : */ |
1615 |
|
|
/* This function sets the experiment pkt RAM copy flag */ |
1616 |
|
|
/* */ |
1617 |
|
|
/* @@ */ |
1618 |
|
|
/* @Parameter Name @Mode @Description */ |
1619 |
|
|
/* Flag IN Flag */ |
1620 |
|
|
/* @@ */ |
1621 |
|
|
/*****************************************************************************/ |
1622 |
|
|
|
1623 |
|
|
void PM_op_SetExpPktCpyFlag(BOOL Flag) |
1624 |
|
|
{ |
1625 |
|
|
/* Set the trigger counter for the experiment pkt RAM copy */ |
1626 |
|
|
SM_PktRamCpyFlag = Flag; |
1627 |
|
|
} |
1628 |
|
|
|
1629 |
|
|
/*****************************************************************************/ |
1630 |
|
|
/* @Function: PM_op_GetAndIncrPckCnt */ |
1631 |
|
|
/* @Purpose : */ |
1632 |
|
|
/* This function get and increase the packet counter */ |
1633 |
|
|
/* */ |
1634 |
|
|
/* @@ */ |
1635 |
|
|
/* @Parameter Name @Mode @Description */ |
1636 |
|
|
/* UINT32 OUT return the packet counter */ |
1637 |
|
|
/* @@ */ |
1638 |
|
|
/*****************************************************************************/ |
1639 |
|
|
UINT32 PM_op_GetAndIncrPckCnt (void) |
1640 |
|
|
{ |
1641 |
|
|
return (SM_PacketCounter++); |
1642 |
|
|
} |
1643 |
|
|
|
1644 |
|
|
/*****************************************************************************/ |
1645 |
|
|
/* @Function: PM_op_CopyToSRAM */ |
1646 |
|
|
/* @Purpose : */ |
1647 |
|
|
/* This function copy from RAMStartAddr "Size" bytes to Page selected in */ |
1648 |
|
|
/* in SRAM Memory. */ |
1649 |
|
|
/* this function update the value of SM_CalDataLenght for the page selected */ |
1650 |
|
|
/* with the "size" */ |
1651 |
|
|
/* */ |
1652 |
|
|
/* @@ */ |
1653 |
|
|
/* @Parameter Name @Mode @Description */ |
1654 |
|
|
/* SM_STRSTAT OUT Store request result */ |
1655 |
|
|
/* Page IN Page to store data buffer */ |
1656 |
|
|
/* RAMStartAddr IN Pointer to the caller data buffer */ |
1657 |
|
|
/* Size IN Size of the packet to be copied into FileId */ |
1658 |
|
|
/* in bytes */ |
1659 |
|
|
/* @@ */ |
1660 |
|
|
/*****************************************************************************/ |
1661 |
|
|
SM_STRSTAT PM_op_CopyToSRAM (SM_PAGEID Page, void* RAMStartAddr, UINT32 Size) |
1662 |
|
|
{ |
1663 |
|
|
SM_STRSTAT strStat = SM_STR_OK; |
1664 |
|
|
unsigned int intLevel; |
1665 |
|
|
|
1666 |
|
|
|
1667 |
|
|
/* Check the packet size */ |
1668 |
|
|
if(Size == 0 || Size > SM_SKETCHSIZE) |
1669 |
|
|
{ |
1670 |
|
|
strStat = SM_STR_WRIONGSIZE; |
1671 |
|
|
} |
1672 |
|
|
/* check that page selected is valid page */ |
1673 |
|
|
if ((Page < SM_CALEXP0) || (Page > SM_CALEXP3)) |
1674 |
|
|
{ |
1675 |
|
|
strStat = SM_STR_WRONGFILE; |
1676 |
|
|
} |
1677 |
|
|
|
1678 |
|
|
if (strStat == SM_STR_OK) |
1679 |
|
|
{ |
1680 |
|
|
if (PM_opLockHBUS() == SM_SUCCESS) |
1681 |
|
|
{ |
1682 |
|
|
/* Copy the provided data into SRAM Page Selected */ |
1683 |
|
|
|
1684 |
|
|
SM_ifCopyToSRAM((UINT32)(Page * SM_SRAMPAGESIZE), RAMStartAddr, Size); |
1685 |
|
|
SM_CalDataLenght[Page] = Size; |
1686 |
|
|
|
1687 |
|
|
PM_opReleaseHBUS(); |
1688 |
|
|
} |
1689 |
|
|
else |
1690 |
|
|
strStat = SM_STR_BUSY; |
1691 |
|
|
} |
1692 |
|
|
return strStat; |
1693 |
|
|
} |
1694 |
|
|
|
1695 |
|
|
/*****************************************************************************/ |
1696 |
|
|
/* @Function: PM_op_UseCalibrationPage */ |
1697 |
|
|
/* @Purpose : */ |
1698 |
|
|
/* This function select the page that must be used for next acquisition */ |
1699 |
|
|
/* */ |
1700 |
|
|
/* @@ */ |
1701 |
|
|
/* @Parameter Name @Mode @Description */ |
1702 |
|
|
/* Page IN Page to store data buffer */ |
1703 |
|
|
/* @@ */ |
1704 |
|
|
/*****************************************************************************/ |
1705 |
|
|
void PM_op_UseCalibrationPage (SM_PAGEID Page) |
1706 |
|
|
{ |
1707 |
|
|
SM_CalPageSelected = Page; |
1708 |
|
|
} |
1709 |
|
|
|
1710 |
|
|
/*****************************************************************************/ |
1711 |
|
|
/* @Function: PM_opLockHBUS */ |
1712 |
|
|
/* @Purpose : */ |
1713 |
|
|
/* This function lock the HW HBUS shared resource */ |
1714 |
|
|
/* */ |
1715 |
|
|
/* @@ */ |
1716 |
|
|
/* @Parameter Name @Mode @Description */ |
1717 |
|
|
/* SM_EXITCODE OUT Lock HBUS request result */ |
1718 |
|
|
/* @@ */ |
1719 |
|
|
/*****************************************************************************/ |
1720 |
|
|
SM_EXITCODE PM_opLockHBUS() |
1721 |
|
|
{ |
1722 |
|
|
SM_EXITCODE status = SM_SUCCESS; |
1723 |
|
|
unsigned int intLevel; |
1724 |
|
|
|
1725 |
|
|
OS_piInterDisable(&intLevel); |
1726 |
|
|
if (SM_HBUSIsLocked) |
1727 |
|
|
status = SM_FAIL; |
1728 |
|
|
else |
1729 |
|
|
SM_HBUSIsLocked = TRUE; |
1730 |
|
|
OS_piInterEnable(intLevel); |
1731 |
|
|
return status; |
1732 |
|
|
} |
1733 |
|
|
|
1734 |
|
|
/*****************************************************************************/ |
1735 |
|
|
/* @Function: PM_opReleaseHBUS */ |
1736 |
|
|
/* @Purpose : */ |
1737 |
|
|
/* This function release the HW HBUS shared resource */ |
1738 |
|
|
/* */ |
1739 |
|
|
/* @@ */ |
1740 |
|
|
/* @Parameter Name @Mode @Description */ |
1741 |
|
|
/* @@ */ |
1742 |
|
|
/*****************************************************************************/ |
1743 |
|
|
void PM_opReleaseHBUS() |
1744 |
|
|
{ |
1745 |
|
|
unsigned int intLevel; |
1746 |
|
|
|
1747 |
|
|
OS_piInterDisable(&intLevel); |
1748 |
|
|
SM_HBUSIsLocked = FALSE; |
1749 |
|
|
OS_piInterEnable(intLevel); |
1750 |
|
|
} |
1751 |
|
|
|
1752 |
|
|
/*****************************************************************************/ |
1753 |
|
|
/* @Function: PM_opGetDataLen */ |
1754 |
|
|
/* @Purpose : */ |
1755 |
|
|
/* Returns the length of a page */ |
1756 |
|
|
/* */ |
1757 |
|
|
/* @@ */ |
1758 |
|
|
/* @Parameter Name @Mode @Description */ |
1759 |
|
|
/* @@ */ |
1760 |
|
|
/*****************************************************************************/ |
1761 |
|
|
UINT32 SM_opGetDataLength(SM_PAGEID page) |
1762 |
|
|
{ |
1763 |
|
|
return SM_CalDataLenght[page]; |
1764 |
|
|
} |
1765 |
|
|
|
1766 |
|
|
/*****************************************************************************/ |
1767 |
|
|
/* @Function: PM_opFullExp */ |
1768 |
|
|
/* @Purpose : */ |
1769 |
|
|
/* Returns wheather or not the is at least one page available on the PIF */ |
1770 |
|
|
/* (exp page) */ |
1771 |
|
|
/* @@ */ |
1772 |
|
|
/* @Parameter Name @Mode @Description */ |
1773 |
|
|
/* @@ */ |
1774 |
|
|
/*****************************************************************************/ |
1775 |
|
|
BOOL SM_opExpPageAvail() |
1776 |
|
|
{ |
1777 |
|
|
BOOL ret = FALSE; |
1778 |
|
|
unsigned int intLevel; |
1779 |
|
|
OS_piInterDisable(&intLevel); |
1780 |
|
|
switch(SM_AcqMode) |
1781 |
|
|
{ |
1782 |
|
|
case SM_DIRECT: |
1783 |
|
|
case SM_DAQSETUP: |
1784 |
|
|
// ret = !SM_PacketStoreIsOngoing; |
1785 |
|
|
ret = SM_ExpPageCounter > 0; |
1786 |
|
|
break; |
1787 |
|
|
case SM_EXP64: |
1788 |
|
|
// case SM_EXPERIMENT: |
1789 |
|
|
ret = SM_ExpPageCounter > 0; |
1790 |
|
|
break; |
1791 |
|
|
} |
1792 |
|
|
OS_piInterEnable(intLevel); |
1793 |
|
|
return ret; |
1794 |
|
|
} |
1795 |
|
|
|
1796 |
|
|
|
1797 |
|
|
BOOL SM_opAllExpPageAvail() |
1798 |
|
|
{ |
1799 |
|
|
BOOL ret = FALSE; |
1800 |
|
|
unsigned int intLevel; |
1801 |
|
|
OS_piInterDisable(&intLevel); |
1802 |
|
|
switch(SM_AcqMode) |
1803 |
|
|
{ |
1804 |
|
|
case SM_DIRECT: |
1805 |
|
|
case SM_DAQSETUP: |
1806 |
|
|
ret = SM_ExpPageCounter == DAQSETUPPAGES; |
1807 |
|
|
break; |
1808 |
|
|
case SM_EXP64: |
1809 |
|
|
ret = SM_ExpPageCounter == EXP64PAGES; |
1810 |
|
|
break; |
1811 |
|
|
} |
1812 |
|
|
OS_piInterEnable(intLevel); |
1813 |
|
|
return ret; |
1814 |
|
|
} |
1815 |
|
|
|