1 |
kusanagi |
1.1 |
/**************************************************************************** |
2 |
|
|
/* F i l e D a t a |
3 |
|
|
/* |
4 |
|
|
/* Module : SRAMManager |
5 |
|
|
/* C.I. No. : |
6 |
|
|
/* $Revision: 1.12 $ |
7 |
|
|
/* $Date: 2005/01/26 18:46:56 $ |
8 |
|
|
/* Belonging to : |
9 |
|
|
/* : |
10 |
|
|
/* $RCSfile: SM_SRAMPageManager_p.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_p.c,v $ |
25 |
|
|
/* Revision 1.12 2005/01/26 18:46:56 sebastiani |
26 |
|
|
/* new bug fixes for WS |
27 |
|
|
/* |
28 |
|
|
/* Revision 1.11 2004/11/05 16:43:08 sebastiani |
29 |
|
|
/* *** empty log message *** |
30 |
|
|
/* |
31 |
|
|
/* Revision 1.10 2004/08/09 08:30:29 sebastiani |
32 |
|
|
/* fix calo alarm procedure |
33 |
|
|
/* |
34 |
|
|
/* Revision 1.9 2004/06/01 16:41:24 sebastiani |
35 |
|
|
/* EventReceive ANY |
36 |
|
|
/* |
37 |
|
|
/* Revision 1.8 2004/05/25 14:07:18 faber |
38 |
|
|
/* *** empty log message *** |
39 |
|
|
/* |
40 |
|
|
/* Revision 1.7 2004/05/20 09:04:23 sebastiani |
41 |
|
|
/* ok |
42 |
|
|
/* |
43 |
|
|
/* Revision 1.6 2004/02/13 10:11:30 alfarano |
44 |
|
|
/* calorimeter initialization func and more |
45 |
|
|
/* |
46 |
|
|
/* Revision 1.5 2003/11/10 12:13:25 sebastiani |
47 |
|
|
/* PM_pi_SetPktType and SM_PktType global variable introdused |
48 |
|
|
/* |
49 |
|
|
/* Revision 1.4 2003/10/17 09:16:43 sebastiani |
50 |
|
|
/* SKETCHBOARD_FREE event introduced |
51 |
|
|
/* |
52 |
|
|
/* Revision 1.3 2003/09/17 16:38:53 faber |
53 |
|
|
/* PM_pi_ExpPageAvail() introduced |
54 |
|
|
/* |
55 |
|
|
/* Revision 1.2 2003/09/10 10:30:43 faber |
56 |
|
|
/* -introduced: |
57 |
|
|
/* void PM_pi_DisableStore_In_DataTimeOut(), |
58 |
|
|
/* void PM_pi_EnableStore_In_DataTimeOut(), |
59 |
|
|
/* UINT32 PM_pi_GetDataLength(SM_PAGEID page); |
60 |
|
|
/* - fixed: Bug in PreparePage, EXP64 mode "one page only use". |
61 |
|
|
/* the fixing consist of the subsitution |
62 |
|
|
/* of the istruction |
63 |
|
|
/* SM_SelectedPage <<= 2; |
64 |
|
|
/* with |
65 |
|
|
/* SM_SelectedPage += 4; |
66 |
|
|
/* |
67 |
|
|
/* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani |
68 |
|
|
/* Imported sources laben rel. 19.06.2003 integrated with pam2 |
69 |
|
|
/* |
70 |
|
|
/* Revision 1.6 2003/06/09 10:20:34 aurora |
71 |
|
|
/* improved the management of data acquisition. |
72 |
|
|
/* Fixed the dalay when copy the data in to ERC32 memory |
73 |
|
|
/* |
74 |
|
|
/* Revision 1.5 2002/07/31 14:34:09 zulia |
75 |
|
|
/* send data to CMD I/F after Event Trigger |
76 |
|
|
/* set header to 12 Bytes |
77 |
|
|
/* packet counter to 32 bits |
78 |
|
|
/* provided interface for copy buffer from micro to PIF sram |
79 |
|
|
/* |
80 |
|
|
/* Revision 1.4 2002/06/19 08:25:31 zulia |
81 |
|
|
/* added provided interface PM_pi_GetAndIncrPckCnt that |
82 |
|
|
/* get and increase the packet counter |
83 |
|
|
/* |
84 |
|
|
/* Revision 1.3 2002/05/09 08:16:35 zulia |
85 |
|
|
/* * acceptance release |
86 |
|
|
/* |
87 |
|
|
/* |
88 |
|
|
/*****************************************************************************/ |
89 |
|
|
|
90 |
|
|
|
91 |
|
|
/*============================= Include File ================================*/ |
92 |
|
|
|
93 |
|
|
#include <src/SRAMManager/SRAMPageManager/SM_SRAMPageManager_p.h> |
94 |
|
|
#include <src/SRAMManager/SRAMPageManager/SM_SRAMPageManager_op.h> |
95 |
|
|
|
96 |
|
|
/*****************************************************************************/ |
97 |
|
|
/*===== 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 ==*/ |
98 |
|
|
|
99 |
|
|
/*****************************************************************************/ |
100 |
|
|
/* @Function: SM_piSRAMPageManagerInit */ |
101 |
|
|
/* @Purpose : */ |
102 |
|
|
/* This function initializes the SRAM Page Manager object (its variables). */ |
103 |
|
|
/* */ |
104 |
|
|
/* @@ */ |
105 |
|
|
/* @Parameter Name @Mode @Description */ |
106 |
|
|
/* SM_EXITCODE OUT Return code */ |
107 |
|
|
/* RstPktCounter IN Flag used to enable the lost packets */ |
108 |
|
|
/* counter reset */ |
109 |
|
|
/* @@ */ |
110 |
|
|
/*****************************************************************************/ |
111 |
|
|
|
112 |
|
|
SM_EXITCODE PM_piSRAMPageManagerInit(BOOL RstPktCounter) |
113 |
|
|
{ |
114 |
|
|
SM_EXITCODE status; |
115 |
|
|
|
116 |
|
|
status = PM_opSRAMPageManagerInit(RstPktCounter); |
117 |
|
|
return (status); |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
/*****************************************************************************/ |
121 |
|
|
/* @Function: SM_piPreparePage */ |
122 |
|
|
/* @Purpose : */ |
123 |
|
|
/* The function selects a new SRAM page to hold the new data coming from */ |
124 |
|
|
/* the DAQ I/F. */ |
125 |
|
|
/* */ |
126 |
|
|
/* @@ */ |
127 |
|
|
/* @Parameter Name @Mode @Description */ |
128 |
|
|
/* @@ */ |
129 |
|
|
/*****************************************************************************/ |
130 |
|
|
|
131 |
|
|
status_code PM_piPreparePage (BOOL daq_dmain) { |
132 |
|
|
return PM_opPreparePage(daq_dmain); |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
|
136 |
|
|
/*****************************************************************************/ |
137 |
|
|
/* @Function: PM_piPageHasData */ |
138 |
|
|
/* @Purpose : */ |
139 |
|
|
/* The function is used to tell the Page Manager that the last selected page*/ |
140 |
|
|
/* contains data written by the DAQ I/F. The Page Manager checks the data, */ |
141 |
|
|
/* write the page header and send a "store" request to the MMSUManager. */ |
142 |
|
|
/* */ |
143 |
|
|
/* @@ */ |
144 |
|
|
/* @Parameter Name @Mode @Description */ |
145 |
|
|
/* @@ */ |
146 |
|
|
/*****************************************************************************/ |
147 |
|
|
|
148 |
|
|
void PM_piPageHasData(void) |
149 |
|
|
{ |
150 |
|
|
PM_opPageHasData(); |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
/*****************************************************************************/ |
154 |
|
|
/* @Function: PM_piPageIsEmpty */ |
155 |
|
|
/* @Purpose : */ |
156 |
|
|
/* The function is used to tell the Page Manager that the last selected page*/ |
157 |
|
|
/* was not written by the DAQ I/F. */ |
158 |
|
|
/* */ |
159 |
|
|
/* @@ */ |
160 |
|
|
/* @Parameter Name @Mode @Description */ |
161 |
|
|
/* @@ */ |
162 |
|
|
/*****************************************************************************/ |
163 |
|
|
|
164 |
|
|
void PM_piPageIsEmpty(void) |
165 |
|
|
{ |
166 |
|
|
PM_opPageIsEmpty(); |
167 |
|
|
} |
168 |
|
|
|
169 |
|
|
/*****************************************************************************/ |
170 |
|
|
/* @Function: PM_piPageWasSaved */ |
171 |
|
|
/* @Purpose : */ |
172 |
|
|
/* The function tels the Page Manager that a SRAM page was stored in MMSU */ |
173 |
|
|
/* or CMD I/F and can be reused */ |
174 |
|
|
/* */ |
175 |
|
|
/* @@ */ |
176 |
|
|
/* @Parameter Name @Mode @Description */ |
177 |
|
|
/* @@ */ |
178 |
|
|
/*****************************************************************************/ |
179 |
|
|
SM_EXITCODE PM_piPageWasSaved(FS_FILEID FileId) |
180 |
|
|
{ |
181 |
|
|
SM_EXITCODE status = SM_SUCCESS; |
182 |
|
|
|
183 |
|
|
PM_opPageWasSaved(FileId); |
184 |
|
|
return (status); |
185 |
|
|
} |
186 |
|
|
|
187 |
|
|
/*****************************************************************************/ |
188 |
|
|
/* @Function: PM_pi_SetAcqMode */ |
189 |
|
|
/* @Purpose : */ |
190 |
|
|
/* The function selects the DAQ acquisition mode for the Page Manager: */ |
191 |
|
|
/* science data or DAQ setup. All the cached pages are lost and the */ |
192 |
|
|
/* MMSUManager must be tod not to call the PageWasSaved function for the */ |
193 |
|
|
/* deleted SRAM pages. By now this means a reset of the MMSUManager save */ |
194 |
|
|
/* queue */ |
195 |
|
|
/* */ |
196 |
|
|
/* @@ */ |
197 |
|
|
/* @Parameter Name @Mode @Description */ |
198 |
|
|
/* SM_EXITCODE OUT Return code */ |
199 |
|
|
/* @@ */ |
200 |
|
|
/*****************************************************************************/ |
201 |
|
|
|
202 |
|
|
SM_EXITCODE PM_pi_SetAcqMode(SM_ACQMODE mode) |
203 |
|
|
{ |
204 |
|
|
SM_EXITCODE code; |
205 |
|
|
|
206 |
|
|
code = PM_op_SetAcqMode(mode); |
207 |
|
|
return (code); |
208 |
|
|
} |
209 |
|
|
|
210 |
|
|
/*****************************************************************************/ |
211 |
|
|
/* @Function: PM_pi_GetAcqMode */ |
212 |
|
|
/* @Purpose : */ |
213 |
|
|
/* The function return the current acquisition mode */ |
214 |
|
|
/* */ |
215 |
|
|
/* @@ */ |
216 |
|
|
/* @Parameter Name @Mode @Description */ |
217 |
|
|
/* SM_ACQMODE OUT acquisition mode */ |
218 |
|
|
/* @@ */ |
219 |
|
|
/*****************************************************************************/ |
220 |
|
|
|
221 |
|
|
SM_ACQMODE PM_pi_GetAcqMode(void) |
222 |
|
|
{ |
223 |
|
|
SM_ACQMODE mode; |
224 |
|
|
|
225 |
|
|
mode = PM_op_GetAcqMode(); |
226 |
|
|
return (mode); |
227 |
|
|
} |
228 |
|
|
|
229 |
|
|
/*****************************************************************************/ |
230 |
|
|
/* @Function: PM_pi_GetLostPktCounter */ |
231 |
|
|
/* @Purpose : */ |
232 |
|
|
/* The function return the lost packets counter */ |
233 |
|
|
/* */ |
234 |
|
|
/* @@ */ |
235 |
|
|
/* @Parameter Name @Mode @Description */ |
236 |
|
|
/* SM_EXITCODE OUT Exit code */ |
237 |
|
|
/* @@ */ |
238 |
|
|
/*****************************************************************************/ |
239 |
|
|
|
240 |
|
|
SM_EXITCODE PM_pi_GetLostPktCounter(UINT32* Counter) |
241 |
|
|
{ |
242 |
|
|
SM_EXITCODE code = SM_SUCCESS; |
243 |
|
|
|
244 |
|
|
PM_op_GetLostPktCounter(Counter); |
245 |
|
|
return (code); |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
/*****************************************************************************/ |
249 |
|
|
/* @Function: PM_pi_GetPacket */ |
250 |
|
|
/* @Purpose : */ |
251 |
|
|
/* The function return the last acquired packet */ |
252 |
|
|
/* */ |
253 |
|
|
/* @@ */ |
254 |
|
|
/* @Parameter Name @Mode @Description */ |
255 |
|
|
/* SM_PKTSTAT OUT Acquisition result */ |
256 |
|
|
/* PtrPkt OUT Pointer to the caller packet buffer */ |
257 |
|
|
/* Size OUT Size of the packet copied into buffer */ |
258 |
|
|
/* @@ */ |
259 |
|
|
/*****************************************************************************/ |
260 |
|
|
|
261 |
|
|
SM_PKTSTAT PM_pi_GetPacket(UINT32* Size, void* PtrPkt) |
262 |
|
|
{ |
263 |
|
|
SM_PKTSTAT PktStat; |
264 |
|
|
|
265 |
|
|
PktStat = PM_op_GetPacket(Size, PtrPkt); |
266 |
|
|
return (PktStat); |
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
/*****************************************************************************/ |
270 |
|
|
/* @Function: PM_pi_SetExpPktCpyFreq */ |
271 |
|
|
/* @Purpose : */ |
272 |
|
|
/* This functin sets the experiment pkt RAM copy frequency */ |
273 |
|
|
/* */ |
274 |
|
|
/* @@ */ |
275 |
|
|
/* @Parameter Name @Mode @Description */ |
276 |
|
|
/* Freq IN Frequency */ |
277 |
|
|
/* @@ */ |
278 |
|
|
/*****************************************************************************/ |
279 |
|
|
|
280 |
|
|
SM_EXITCODE PM_pi_SetExpPktCpyFlag(BOOL Flag) |
281 |
|
|
{ |
282 |
|
|
SM_EXITCODE code = SM_SUCCESS; |
283 |
|
|
PM_op_SetExpPktCpyFlag(Flag); |
284 |
|
|
return (code); |
285 |
|
|
} |
286 |
|
|
|
287 |
|
|
/*****************************************************************************/ |
288 |
|
|
/* @Function: PM_pi_StorePacket */ |
289 |
|
|
/* @Purpose : */ |
290 |
|
|
/* The function starts all the operations needed to store the given packet */ |
291 |
|
|
/* in the selected file. If the result is good it only means that the store */ |
292 |
|
|
/* request was successfuly accepted. The store of the packet can still fail.*/ |
293 |
|
|
/* */ |
294 |
|
|
/* @@ */ |
295 |
|
|
/* @Parameter Name @Mode @Description */ |
296 |
|
|
/* SM_STRSTAT OUT Store request result result */ |
297 |
|
|
/* PtrPkt IN Pointer to the caller packet buffer */ |
298 |
|
|
/* Size IN Size of the packet to be copied into FileId */ |
299 |
|
|
/* in bytes */ |
300 |
|
|
/* FileID IN Destination file */ |
301 |
|
|
/* @@ */ |
302 |
|
|
/*****************************************************************************/ |
303 |
|
|
|
304 |
|
|
SM_STRSTAT PM_pi_StorePacket(UINT32 Size, void* PtrPkt, FS_FILEID FileId) |
305 |
|
|
{ |
306 |
|
|
SM_STRSTAT PktStat; |
307 |
|
|
|
308 |
|
|
PktStat = PM_op_StorePacket(Size, PtrPkt, FileId); |
309 |
|
|
return (PktStat); |
310 |
|
|
} |
311 |
|
|
|
312 |
|
|
/*****************************************************************************/ |
313 |
|
|
/* @Function: PM_pi_GetAndIncrPckCnt */ |
314 |
|
|
/* @Purpose : */ |
315 |
|
|
/* This function get and increase the packet counter */ |
316 |
|
|
/* */ |
317 |
|
|
/* @@ */ |
318 |
|
|
/* @Parameter Name @Mode @Description */ |
319 |
|
|
/* UINT32 OUT return the packet counter */ |
320 |
|
|
/* @@ */ |
321 |
|
|
/*****************************************************************************/ |
322 |
|
|
UINT32 PM_pi_GetAndIncrPckCnt (void) |
323 |
|
|
{ |
324 |
|
|
return (PM_op_GetAndIncrPckCnt()); |
325 |
|
|
} |
326 |
|
|
|
327 |
|
|
/*****************************************************************************/ |
328 |
|
|
/* @Function: PM_pi_CopyToSRAM */ |
329 |
|
|
/* @Purpose : */ |
330 |
|
|
/* This function copy from RAMStartAddr "Size" bytes to Page selected in */ |
331 |
|
|
/* in SRAM Memory */ |
332 |
|
|
/* this function update the value of SM_CalDataLenght for the page selected */ |
333 |
|
|
/* with the "size" */ |
334 |
|
|
/* */ |
335 |
|
|
/* @@ */ |
336 |
|
|
/* @Parameter Name @Mode @Description */ |
337 |
|
|
/* SM_STRSTAT OUT Store request result */ |
338 |
|
|
/* Page IN Page to store data buffer */ |
339 |
|
|
/* RAMStartAddr IN Pointer to the caller data buffer */ |
340 |
|
|
/* Size IN Size of the packet to be copied into FileId */ |
341 |
|
|
/* in bytes */ |
342 |
|
|
/* @@ */ |
343 |
|
|
/*****************************************************************************/ |
344 |
|
|
SM_STRSTAT PM_pi_CopyToSRAM (SM_PAGEID Page, void* RAMStartAddr, UINT32 Size) |
345 |
|
|
{ |
346 |
|
|
return PM_op_CopyToSRAM (Page, RAMStartAddr, Size); |
347 |
|
|
} |
348 |
|
|
|
349 |
|
|
/*****************************************************************************/ |
350 |
|
|
/* @Function: PM_pi_UseCalibrationPage */ |
351 |
|
|
/* @Purpose : */ |
352 |
|
|
/* This function select the page that must be used for next acquisition */ |
353 |
|
|
/* */ |
354 |
|
|
/* @@ */ |
355 |
|
|
/* @Parameter Name @Mode @Description */ |
356 |
|
|
/* Page IN Page to store data buffer */ |
357 |
|
|
/* @@ */ |
358 |
|
|
/*****************************************************************************/ |
359 |
|
|
void PM_pi_UseCalibrationPage (SM_PAGEID Page) |
360 |
|
|
{ |
361 |
|
|
PM_op_UseCalibrationPage (Page); |
362 |
|
|
} |
363 |
|
|
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
void PM_pi_DisableStore_In_DataTimeOut() { |
367 |
|
|
PM_opDisableStore_In_DataTimeOut(); |
368 |
|
|
} |
369 |
|
|
|
370 |
|
|
void PM_pi_EnableStore_In_DataTimeOut() { |
371 |
|
|
PM_opEnableStore_In_DataTimeOut(); |
372 |
|
|
} |
373 |
|
|
|
374 |
|
|
UINT32 PM_pi_GetDataLength(SM_PAGEID page) |
375 |
|
|
{ |
376 |
|
|
return SM_opGetDataLength(page); |
377 |
|
|
} |
378 |
|
|
|
379 |
|
|
BOOL PM_pi_ExpPageAvail() |
380 |
|
|
{ |
381 |
|
|
return SM_opExpPageAvail(); |
382 |
|
|
} |
383 |
|
|
|
384 |
|
|
BOOL PM_pi_AllExpPageAvail() |
385 |
|
|
{ |
386 |
|
|
return SM_opAllExpPageAvail(); |
387 |
|
|
} |
388 |
|
|
|
389 |
|
|
BYTE PM_pi_SetPktType(BYTE pkttype) { |
390 |
|
|
return PM_opSetPktType(pkttype); |
391 |
|
|
} |
392 |
|
|
|
393 |
|
|
BYTE PM_pi_GetPktType() { |
394 |
|
|
return PM_opGetPktType(); |
395 |
|
|
} |