/[PAMELA software]/quicklook/dataToXML/Data/compilationInfo/src/INFN/DAQ_IDAQ_INFN.c
ViewVC logotype

Contents of /quicklook/dataToXML/Data/compilationInfo/src/INFN/DAQ_IDAQ_INFN.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Apr 25 09:00:20 2006 UTC (19 years, 2 months ago) by kusanagi
Branch: MAIN
CVS Tags: dataToXML1_02/01, dataToXML1_02/00, dataToXML1_03/00, dataToXML1_03/01, dataToXML1_00/00, firstRelease, dataToXML1_01/00, dataToXML1_03_02, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
These program extract in an XML format the info contained into the ROOT files generated by YODA from the PAMELA data. To visualize the XML files in a more human readable format a collection of XSL files are given in the Data subfolder.

1 /****************************************************************************
2 * F i l e D a t a
3 * $Id: DAQ_IDAQ_INFN.c,v 1.69 2005/03/20 18:19:21 sebastiani Exp $
4 * $Revision: 1.69 $
5 * $Date: 2005/03/20 18:19:21 $
6 * $RCSfile: DAQ_IDAQ_INFN.c,v $
7 *
8 ****************************************************************************
9 * S W D e v e l o p m e n t E n v i r o n m e n t
10 *
11 * $Author: sebastiani $
12 * :
13 ****************************************************************************
14 * U p d a t i n g
15 *
16 * $Log: DAQ_IDAQ_INFN.c,v $
17 * Revision 1.69 2005/03/20 18:19:21 sebastiani
18 * CRC start valeu in DAQ_ module start from zero, like always
19 *
20 * Revision 1.68 2005/03/06 14:54:46 sebastiani
21 * version running on 06 03 2005
22 *
23 * Revision 1.67 2005/02/24 16:49:29 sebastiani
24 * DAQ_STORE_MM moved to be a macro , not a static var
25 *
26 * Revision 1.66 2005/02/21 08:58:29 sebastiani
27 * all log comments completed
28 *
29 * Revision 1.65 2005/01/26 18:46:48 sebastiani
30 * new bug fixes for WS
31 *
32 * Revision 1.64 2004/11/19 15:14:52 sebastiani
33 * PRH_EXTERN_{VAR,ARR,TABLE} removed and put them on the autogenerated parameter heeader file
34 *
35 * Revision 1.63 2004/11/05 16:43:07 sebastiani
36 * *** empty log message ***
37 *
38 * Revision 1.62 2004/10/01 08:48:10 sebastiani
39 * TRD alarma renamed TRD_S4 - S4 Alarm renamed S4_POWER
40 * Callback function into DAQ_SendCmd2PIFWaitDAQReply_internal
41 *
42 * Revision 1.61 2004/09/17 15:01:00 faber
43 * LU_INFN_LOG flags fixing
44 *
45 * Revision 1.60 2004/09/09 14:52:55 sebastiani
46 * using PreparePage to send cmd to idaq/FE
47 * added some test
48 * added trigger param
49 * added/tested Force Send KHB_to_FE
50 * added/tested Send Cmd to IDAQ/FE
51 *
52 * Revision 1.59 2004/08/31 09:08:35 sebastiani
53 * fix warning
54 *
55 * Revision 1.58 2004/08/26 16:54:34 sebastiani
56 * version work fine
57 *
58 * Revision 1.57 2004/08/13 14:42:19 sebastiani
59 * Add Neutron detector!
60 * need add file ND_READ_ACQ.dat on site ...
61 *
62 * Revision 1.56 2004/08/11 15:49:59 sebastiani
63 * delete unuseful line
64 *
65 * Revision 1.55 2004/08/02 15:49:47 alfarano
66 * alarm handling , scm & pm communication rewrite
67 *
68 * Revision 1.54 2004/08/02 14:26:38 sebastiani
69 * fix mm bug
70 *
71 * Revision 1.53 2004/08/02 12:16:24 sebastiani
72 * little fix
73 *
74 * Revision 1.52 2004/07/21 14:08:32 sebastiani
75 * Fix close RUN we wait a event to close the run
76 * PM send Sint and don't wait for SintOK
77 * Header'Trailer Initialization
78 * FixPacketCounter
79 *
80 * Revision 1.51 2004/07/20 14:36:26 sebastiani
81 * AC/CAL/TRK/TOF/TRG unmaksed all KHB alarms
82 * RM: Close Run before RunTrailer (send page 2)
83 *
84 * Revision 1.50 2004/07/15 13:45:58 sebastiani
85 * fix some bugs
86 *
87 * Revision 1.49 2004/07/12 09:19:33 sebastiani
88 * some fixing about alamrs
89 *
90 * Revision 1.48 2004/06/22 09:34:52 faber
91 * *** empty log message ***
92 *
93 * Revision 1.47 2004/06/22 08:57:01 sebastiani
94 * *** empty log message ***
95 *
96 * Revision 1.46 2004/06/16 09:35:13 faber
97 * *** empty log message ***
98 *
99 * Revision 1.45 2004/06/15 08:22:06 sebastiani
100 * adjust DAQ_DEFAULT_{DTO,ETO}_TICS
101 *
102 * Revision 1.44 2004/06/04 14:24:38 sebastiani
103 * clear some files
104 *
105 * Revision 1.43 2004/06/01 16:41:19 sebastiani
106 * EventReceive ANY
107 *
108 * Revision 1.42 2004/05/27 17:50:40 sebastiani
109 * *** empty log message ***
110 *
111 * Revision 1.41 2004/05/25 17:41:08 sebastiani
112 * fix alfarano's bugs
113 *
114 * Revision 1.40 2004/05/24 10:27:32 faber
115 * *** empty log message ***
116 *
117 * Revision 1.39 2004/05/20 16:51:02 sebastiani
118 * add append with offset and fix some bug
119 *
120 * Revision 1.38 2004/05/20 16:03:52 faber
121 * ACQ flow dev continuing
122 *
123 * Revision 1.37 2004/05/20 09:04:15 sebastiani
124 * ok
125 *
126 * Revision 1.36 2004/05/19 08:44:38 sebastiani
127 * fix trk init and calib
128 *
129 * Revision 1.35 2004/05/14 08:37:27 sebastiani
130 * same default param, some sebastiani's bugs
131 *
132 * Revision 1.34 2004/05/12 14:46:14 faber
133 * *** empty log message ***
134 *
135 * Revision 1.33 2004/05/12 08:10:11 faber
136 * *** empty log message ***
137 *
138 * Revision 1.32 2004/05/11 17:45:10 sebastiani
139 * x-1 offset
140 *
141 * Revision 1.31 2004/05/11 15:28:28 alfarano
142 * updates..
143 *
144 * Revision 1.30 2004/05/11 13:58:49 sebastiani
145 * ETO/ATO 4+4 bit instead of 5.3 in DAQ_IDAQ_INFN
146 *
147 * Revision 1.29 2004/05/06 08:52:24 faber
148 * development goes on..
149 *
150 * Revision 1.28 2004/05/03 14:45:13 sebastiani
151 * correct len
152 *
153 * Revision 1.27 2004/04/30 09:51:36 alfarano
154 * stupid error
155 *
156 * Revision 1.26 2004/04/29 16:13:59 alfarano
157 * update cal
158 *
159 * Revision 1.25 2004/04/29 15:22:42 sebastiani
160 * buffer->len+=SM_HEADER_LEN in WriteHeaderLen
161 *
162 * Revision 1.24 2004/04/29 15:17:24 sebastiani
163 * *** empty log message ***
164 *
165 * Revision 1.23 2004/04/29 08:30:59 sebastiani
166 * WriteHeader moved to DAQ_IDAQ_INFN.c
167 *
168 * Revision 1.22 2004/02/13 10:11:30 alfarano
169 * calorimeter initialization func and more
170 *
171 * Revision 1.21 2004/02/11 16:26:52 faber
172 * CM_TIME2REG introduced
173 *
174 * Revision 1.20 2004/02/10 16:48:28 faber
175 * *** empty log message ***
176 *
177 * Revision 1.19 2004/02/05 11:36:11 sebastiani
178 * DAQ_FE_DUMMY introduced and TEST_FE2LINK changed
179 *
180 * Revision 1.18 2004/01/29 18:10:01 sebastiani
181 * DAQ_Format_Daq2Ram_ReadData introduced; DAQ_FORMAT_OPCODE_CMD_TEMPLATE modifed to work better
182 *
183 * Revision 1.17 2004/01/22 10:10:25 faber
184 * *** empty log message ***
185 *
186 * Revision 1.16 2004/01/12 17:51:28 tassa
187 * manca solo la parte di invio e ricezione sulla/dalla IDAQ
188 *
189 * Revision 1.15 2003/11/04 11:57:45 sebastiani
190 * DAQ_Format_Cmd2Ram_ReadData added
191 *
192 * Revision 1.14 2003/10/27 18:52:58 sebastiani
193 * *** empty log message ***
194 *
195 * Revision 1.13 2003/10/21 13:16:01 sebastiani
196 * no logs on clear event any more
197 *
198 * Revision 1.12 2003/10/17 08:44:15 sebastiani
199 * new implementation of DAQ_SaveBuffer2MM
200 *
201 * Revision 1.11 2003/10/02 16:14:43 faber
202 * IDAQ deep ETO/ATO modifications
203 * All comments for functions
204 *
205 * Revision 1.10 2003/10/01 18:13:01 faber
206 * temp buf size bug fix
207 *
208 * Revision 1.9 2003/09/25 16:51:27 alfarano
209 * conflicts resolved
210 *
211 * Revision 1.8 2003/09/25 12:57:07 faber
212 * first version of cmdgenerator.c
213 *
214 * Revision 1.7 2003/09/22 14:05:38 alfarano
215 * functions moved from RM_RunManager to DAQ_IDAQ_INFN:StoreCmdQueue2PIF,SendCmdQueue2CMDIF; added DAQ_SendCmd2PIFWaitDAQReply
216 *
217 * Revision 1.6 2003/09/19 15:57:35 faber
218 * Large development update INFN software
219 *
220 * Revision 1.5 2003/09/10 16:15:52 faber
221 * PRH_EXTERN_VAR(XX_LOGMASK) removed (not needed any more)
222 *
223 * Revision 1.4 2003/09/10 11:55:07 faber
224 * LU_MASK introduced. Log mask for module is now an unique array (PRH_ARR_LOG_MASK) indexed by __FILEID__
225 *
226 * Revision 1.3 2003/08/22 07:57:08 sebastiani
227 * *** empty log message ***
228 *
229 * Revision 1.2 2003/08/08 11:00:42 sebastiani
230 * Primo test funzionante IDAQ (GuidoBoard)
231 * Import Test Russi 30.8
232 *
233 * Revision 1.1.1.1 2003/08/04 09:40:22 sebastiani
234 * Imported sources laben rel. 19.06.2003 integrated with pam2
235 *
236 * Revision 1.7 2003/07/28 09:12:01 sebastiani
237 * *** empty log message ***
238 *
239 * Revision 1.6 2003/07/25 15:32:57 sebastiani
240 * * Cmd2XX / ReadData cancelled (non valid!)
241 * * new way of declaration of buffers
242 *
243 * Revision 1.5 2003/07/18 13:35:10 sebastiani
244 * PRH_ParamHandler_INFN_int.c sobstitues PRH_ParamHandler_INFN_*.*
245 * introduced DAQTEST directive
246 *
247 * Revision 1.4 2003/07/17 11:15:52 sebastiani
248 * idaq manager
249 * new print for logging in minicom
250 *
251 * Revision 1.3 2003/07/11 09:39:23 sebastiani
252 * *** empty log message ***
253 *
254 * Revision 1.2 2003/07/10 15:56:27 sebastiani
255 * *** empty log message ***
256 *
257 * Revision 1.1 2003/07/10 07:05:14 sebastiani
258 * first IDAQ driver import
259 *
260 *
261 *****************************************************************************/
262
263
264 /*============================= Include File ================================*/
265
266
267 #include <src/INFN/LU_SourceFileID_INFN.h>
268 #define __FILEID__ _DAQ_IDAQ_INFN__c
269
270
271 #ifndef I386
272 #include <src/INFN/PRH_ParamHandler_INFN_auto.h>
273 #include <src/INFN/PRH_ParamHandler_INFN_autopri.h>
274 #include <src/INFN/PRH_ParamHandler_INFN.h>
275 #include <src/INFN/LU_LogUtility_INFN.h>
276 LU_DECL_MASK();
277 #endif // I386
278
279 #include <src/INFN/DAQ_IDAQ_INFN.h>
280 #include <src/INFN/CM_Common_INFN.h>
281
282
283 #ifndef I386
284 #include <src/INFN/KHB_Driver_INFN.h>
285 #include <src/INFN/HK_Manager_INFN.h>
286 #include <src/INFN/RM_RunManager_INFN.h>
287 #include <src/FileManager/MMSUManager/FT_MMSUManager_p.h>
288 #endif // I386
289
290 /*============================ Global define ================================*/
291
292 #define DAQ_SSBUF_SHORTCMD_LIMIT 124
293 #define DAQ_SSBUF_LONGCMD_LIMIT 126
294
295 //#define DAQ_SSBUF_SHORTCMD_LIMIT 5
296 //#define DAQ_SSBUF_LONGCMD_LIMIT 6
297
298 #define DAQ_LINK_SPARE 0xFF
299
300 #define DAQ_FLASH_N_SECTOR 0x12
301
302
303 #ifdef I386
304 typedef unsigned int PRH_VAR_TYPE;
305 #define SUCCESSFUL 0
306 #endif // I386
307
308
309 // #define ETOATO_EXTERN(name) PRH_EXTERN_VAR(DAQ_##name##_ETO); PRH_EXTERN_VAR(DAQ_##name##_ATO)
310 #define DEF_ETOATO(name,eto,ato) static BYTE DAQ_##name##_ETO=eto; static BYTE DAQ_##name##_ATO=ato;
311 #define ETOATO(name) DAQ_##name##_ETO,DAQ_##name##_ATO
312
313
314
315
316 #ifdef I386
317 #define TEMP_BUF_LEN (64*1024)
318 #else
319 #define TEMP_BUF_LEN (SM_SRAMPAGESIZE*2)
320 #endif // I386
321
322 /*============================== global types ==============================*/
323
324
325
326
327 /*****************************************************************************/
328 /*=========================== Structure define ==============================*/
329
330 /* this resurse is protected from the DAQ_BUF_INFN_RES */
331
332 static DAQ_CMD_BUF tempbuf;
333 static BYTE __tempbuf[TEMP_BUF_LEN];
334
335 static unsigned int DAQ_FLASH_SECTOR_DIM_KB[DAQ_FLASH_N_SECTOR] = {16,8,8,32,64,64,64,64,64,64,64,64,64,64,64,64,64,64};
336 static unsigned int DAQ_FLASH_SECTOR_LADDR[DAQ_FLASH_N_SECTOR];
337 static unsigned int DAQ_FLASH_SECTOR_UADDR[DAQ_FLASH_N_SECTOR];
338
339 /*****************************************************************************/
340 /*============================ Enumerate define =============================*/
341
342 /*****************************************************************************/
343
344 /*=== ZZZ I N T E R N A L ==*/
345
346 /*****************************************************************************/
347
348 /* Exec Time Out and Answer Time Out definitions . To be defined */
349
350
351
352
353 DEF_ETOATO(FLASH_SECTORERASE,0,0);
354 DEF_ETOATO(FLASH_SETADDRESS,0,0);
355 DEF_ETOATO(FLASH_WRITEDATA,0,0);
356 DEF_ETOATO(FLASH_ENDBLOCK,0,0);
357 DEF_ETOATO(FLASH_READDATA,0,0);
358
359 /* READDATA / WRITEDATA ETO depends on length of the stream. */
360
361 DEF_ETOATO(RAM_SETADDRESS,2,1);
362 DEF_ETOATO(RAM_WRITEDATA,2,1);
363 DEF_ETOATO(RAM_ENDBLOCK,2,1);
364 DEF_ETOATO(RAM_READDATA,2,1);
365
366 DEF_ETOATO(DSP_STARTPROGRAM,2,1);
367 DEF_ETOATO(DSP_SETADDRESS,2,1);
368 DEF_ETOATO(DSP_WRITEDATA,2,1);
369 DEF_ETOATO(DSP_READDATA,2,1);
370 DEF_ETOATO(DSP_RESET,2,1);
371 DEF_ETOATO(DSP_FLAGREAD,2,1);
372 DEF_ETOATO(DSP_CHECKMEMORY,2,1);
373
374
375
376 #ifndef I386
377 #define DAQ_FORMAT_OPCODE_CMD_TEMPLATE(function1,function2) status_code s1,s2; \
378 if( (s1=OS_piResourceObtain_INFN(DAQ_BUF_INFN_RES,RTEMS_WAIT,RTEMS_NO_TIMEOUT)) != SUCCESSFUL) \
379 return s1; \
380 s1=function1; \
381 if(s1 == DAQ_SC_SUCCESSFUL) \
382 s2 = function2; \
383 OS_piResourceRelease_INFN(DAQ_BUF_INFN_RES); \
384 if(s1 != DAQ_SC_SUCCESSFUL) \
385 return s1; \
386 return s2
387 #else
388 #define DAQ_FORMAT_OPCODE_CMD_TEMPLATE(function1,function2) status_code s1,s2; \
389 s1=function1; \
390 if(s1 == DAQ_SC_SUCCESSFUL) \
391 s2 = function2; \
392 if(s1 != DAQ_SC_SUCCESSFUL) \
393 return s1; \
394 return s2
395 #endif // I386
396
397 /* coocked commands: */
398
399 DAQ_DECLBUF(readdata,1);
400 DAQ_DECLBUF(nullbuf,1);
401
402 void DAQ_Init_CoockedCommands() {
403 DAQ_BUFFER_INIT(readdata);
404 DAQ_BUFFER_INIT(nullbuf);
405 }
406
407 status_code DAQ_Init() {
408 int i;
409 unsigned int prec=-1;
410 for(i=0;i<DAQ_FLASH_N_SECTOR;i++) {
411 DAQ_FLASH_SECTOR_LADDR[i]=prec+1;
412 prec=DAQ_FLASH_SECTOR_UADDR[i]=DAQ_FLASH_SECTOR_LADDR[i]+DAQ_FLASH_SECTOR_DIM_KB[i]*1024;
413 }
414 DAQ_Format_CMD_Init(&tempbuf,TEMP_BUF_LEN,0,__tempbuf);
415 DAQ_Init_CoockedCommands();
416 return DAQ_SC_SUCCESSFUL;
417 }
418
419
420 status_code DAQ_Format_CMD_Init(DAQ_CMD_BUF *cmdbuf,unsigned int size,unsigned int len,BYTE *buf) {
421 cmdbuf->size=size;
422 cmdbuf->len=len;
423 cmdbuf->buf=buf;
424 cmdbuf->eto = DAQ_ETO_UNSET;
425 cmdbuf->ato = DAQ_ATO_UNSET;
426 cmdbuf->crc16 = 0;
427 cmdbuf->crc8 = 0;
428 return DAQ_SC_SUCCESSFUL;
429 }
430
431 status_code DAQ_Format_CMD_Fill(DAQ_CMD_BUF *cmdbuf,unsigned int len,BYTE pattern) {
432 int i;
433 DAQ_CTRL_SET_LEN(cmdbuf,len);
434 for(i=0;i<len;i++)
435 cmdbuf->buf[i]=pattern;
436 return DAQ_SC_SUCCESSFUL;
437 }
438
439
440 #ifdef TEST_I
441 status_code DAQ_BufDump(DAQ_CMD_BUF *b) {
442 static char str[100];
443 int i;
444 sprintf(str,"BufDump: Len:%d ETO:%d ATO:%d",b->len,b->eto,b->ato);
445
446 #ifdef I386
447 // printf("%s\n",str);
448 #else
449 //TS_piWriteOnUART(str);
450 LU_WriteOnUART(str);
451 #endif // I386
452
453
454 for(i=0;i<b->len;i++) {
455 sprintf(str,"0x%x",b->buf[i]);
456
457 #ifdef I386
458 printf("%s\n",str);
459 #else
460 // TS_piWriteOnUART(str);
461 LU_WriteOnUART(str);
462 #endif // I386
463
464
465 }
466
467 #ifdef I386
468 //printf("BufDump END\n");
469 #else
470 // TS_piWriteOnUART("BufDump END");
471 LU_WriteOnUART("BufDump END");
472 #endif // I386
473 return SUCCESSFUL;
474 }
475 #endif
476
477 status_code DAQ_Format_AppendBuffer_offset(DAQ_CMD_BUF *target,DAQ_CMD_BUF *source,unsigned int offset) {
478 unsigned int l=target->len;
479 // TBD: what to do with ETO/ATO ?
480 if(offset >= source->len)
481 {
482 return CM_RC_INVALID_BUFFER_SIZE;
483 }
484 DAQ_CTRL_SET_LEN(target,target->len+source->len-offset);
485 memcpy(&target->buf[l],&source->buf[offset],source->len-offset);
486 return DAQ_SC_SUCCESSFUL;
487 }
488
489
490 status_code DAQ_Format_AppendBuffer(DAQ_CMD_BUF *target,DAQ_CMD_BUF *source) {
491 unsigned int l=target->len;
492 // TBD: what to do with ETO/ATO ?
493 DAQ_CTRL_SET_LEN(target,target->len+source->len);
494 memcpy(&target->buf[l],source->buf,source->len);
495 return DAQ_SC_SUCCESSFUL;
496 }
497
498 status_code DAQ_Format_CopyBuffer(DAQ_CMD_BUF *target,DAQ_CMD_BUF *source) {
499 // emtpy the buffer:
500 if( target->size < source->len)
501 return DAQ_SC_DAQ_BUF_NO_SPACE_LEFT;
502 target->len=source->len;
503 target->eto=source->eto;
504 target->ato=source->ato;
505 memcpy(&target->buf[0],source->buf,source->len);
506 return DAQ_SC_SUCCESSFUL;
507 }
508
509
510 status_code DAQ_Compute_CRC16(DAQ_CMD_BUF *b) {
511 b->crc16=CM_Compute_CRC16 (0,b->buf,b->len);
512 return CM_RC_SUCCESSFUL;
513 }
514
515
516 status_code DAQ_Compute_CRC8 (DAQ_CMD_BUF *b) {
517 b->crc8 =CM_Compute_CRC8_8 (0,b->buf,b->len);
518 return CM_RC_SUCCESSFUL;
519 }
520
521
522
523 status_code DAQ_Format_CMD(BOOL append,DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF *devcmd,
524 DAQ_OPCODE opcode,DAQ_FE fe,BYTE esectimeout,BYTE anstimeout) {
525 BYTE *tbuf=idaqcmd->buf;
526 BYTE *ssbuf=devcmd->buf;
527 BYTE npk,rem,i;
528 BYTE islong=devcmd->len > DAQ_SSBUF_SHORTCMD_LIMIT;
529 status_code s;
530 unsigned int flen,idaqcmd_len;
531
532 if(islong) {
533 npk=(devcmd->len-DAQ_SSBUF_SHORTCMD_LIMIT) / DAQ_SSBUF_LONGCMD_LIMIT;
534 rem=(devcmd->len-DAQ_SSBUF_SHORTCMD_LIMIT) % DAQ_SSBUF_LONGCMD_LIMIT;
535 flen=devcmd->len+4+npk+(rem?1:0);
536 }else{
537 flen=devcmd->len+4;
538 }
539
540 if(append==DAQ_APPEND) {
541 idaqcmd_len = idaqcmd->len + flen;
542 tbuf=&idaqcmd->buf[idaqcmd->len];
543 }else{
544 idaqcmd_len = flen;
545 }
546
547 if(idaqcmd_len > idaqcmd->size)
548 return DAQ_SC_DAQ_BUF_NO_SPACE_LEFT;
549
550 idaqcmd->len = idaqcmd_len;
551
552
553 // 0 (1) | cmd length (7)
554 *tbuf++ =islong ? 0x7F : 0x7F & devcmd->len+3;
555 // Opcode (4) | #link (4):
556 *tbuf++ =(opcode << 4) | ( ((BYTE)fe) & 0x0F);
557 // Esec timeout (4) | ans timeout (4):
558 *tbuf++ =(esectimeout << 4) | (anstimeout & 0x0F);
559 if(islong) {
560 memcpy(tbuf,ssbuf,DAQ_SSBUF_SHORTCMD_LIMIT);
561 ssbuf+=DAQ_SSBUF_SHORTCMD_LIMIT;
562 tbuf+=DAQ_SSBUF_SHORTCMD_LIMIT;
563 for(i=0;i<npk;i++) {
564 *tbuf++=0x7F;
565 memcpy(tbuf,ssbuf,DAQ_SSBUF_LONGCMD_LIMIT);
566 ssbuf+=DAQ_SSBUF_LONGCMD_LIMIT;
567 tbuf+=DAQ_SSBUF_LONGCMD_LIMIT;
568 }
569 if(rem) {
570 *tbuf++=rem+1;
571 memcpy(tbuf,ssbuf,rem);
572 tbuf+=rem;
573 }
574 }else{
575 memcpy(tbuf,ssbuf,devcmd->len);
576 tbuf+=devcmd->len;
577 }
578 *tbuf++=0xAA;
579 return DAQ_SC_SUCCESSFUL;
580 }
581
582
583 status_code DAQ_Format_OneByteCmd(DAQ_CMD_BUF* cmdbuffer,BYTE cmd) {
584 DAQ_CTRL_SET_LEN(cmdbuffer,1);
585 cmdbuffer->buf[0]=cmd;
586 return DAQ_SC_SUCCESSFUL;
587 }
588
589
590 status_code DAQ_Format_Flash_SectorErase(DAQ_CMD_BUF* cmdbuffer,BYTE sector) {
591 DAQ_CTRL_SET_LEN(cmdbuffer,2);
592 cmdbuffer->buf[0]=0x1E;
593 if(sector > 0x11) {
594 #ifndef I386
595 LU_INFN_LOG(LU_INTERNAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,sector);
596 #endif // I386
597 return DAQ_SC_BAD_FLASH_SECTOR;
598 }
599 cmdbuffer->buf[1]=sector;
600 cmdbuffer->eto = DAQ_FLASH_SECTORERASE_ETO;
601 cmdbuffer->ato = DAQ_FLASH_SECTORERASE_ATO;
602 return DAQ_SC_SUCCESSFUL;
603 }
604
605
606 status_code DAQ_Format_Flash_SetAddress(DAQ_CMD_BUF* cmdbuffer,unsigned int addr) {
607 DAQ_CTRL_SET_LEN(cmdbuffer,4);
608 cmdbuffer->buf[0]=0x2D;
609 cmdbuffer->buf[1]=(BYTE) (addr & 0x000000ff);
610 cmdbuffer->buf[2]=(BYTE) ((addr & 0x0000ff00) >> 8);
611 cmdbuffer->buf[3]=(BYTE) ((addr & 0x00ff0000) >> 16);
612 cmdbuffer->eto = DAQ_FLASH_SETADDRESS_ETO;
613 cmdbuffer->ato = DAQ_FLASH_SETADDRESS_ATO;
614 return DAQ_SC_SUCCESSFUL;
615 }
616
617 status_code DAQ_Format_Flash_WriteData(DAQ_CMD_BUF* cmdbuffer,DAQ_CMD_BUF *data) {
618 DAQ_CTRL_SET_LEN(cmdbuffer,1);
619 cmdbuffer->buf[0]=0x33;
620 DAQ_Format_AppendBuffer(cmdbuffer,data);
621
622 cmdbuffer->eto = DAQ_FLASH_WRITEDATA_ETO;
623 cmdbuffer->ato = DAQ_FLASH_WRITEDATA_ATO;
624
625 return DAQ_SC_SUCCESSFUL;
626 }
627
628 status_code DAQ_Format_Flash_EndBlock(DAQ_CMD_BUF* cmdbuffer) {
629 cmdbuffer->eto = DAQ_FLASH_ENDBLOCK_ETO;
630 cmdbuffer->ato = DAQ_FLASH_ENDBLOCK_ATO;
631 return DAQ_Format_OneByteCmd(cmdbuffer,0x55);
632 }
633
634 status_code DAQ_Format_Flash_ReadData(DAQ_CMD_BUF* cmdbuffer) {
635 cmdbuffer->eto = DAQ_FLASH_READDATA_ATO;
636 cmdbuffer->ato = DAQ_FLASH_READDATA_ATO;
637 return DAQ_Format_OneByteCmd(cmdbuffer,0x4B);
638 }
639
640
641 status_code DAQ_Format_Ram_SetAddress(DAQ_CMD_BUF* cmdbuffer,unsigned int addr) {
642 DAQ_CTRL_SET_LEN(cmdbuffer,4);
643 cmdbuffer->buf[0]=0x2D;
644 cmdbuffer->buf[1]=(BYTE) (addr & 0x000000ff);
645 cmdbuffer->buf[2]=(BYTE) ((addr & 0x0000ff00) >> 8);
646 cmdbuffer->buf[3]=(BYTE) ((addr & 0x00ff0000) >> 16);
647 cmdbuffer->eto = DAQ_RAM_SETADDRESS_ETO;
648 cmdbuffer->ato = DAQ_RAM_SETADDRESS_ATO;
649 return DAQ_SC_SUCCESSFUL;
650 }
651
652
653 status_code DAQ_Format_Ram_WriteData(DAQ_CMD_BUF* cmdbuffer,DAQ_CMD_BUF *data) {
654 DAQ_CTRL_SET_LEN(cmdbuffer,1);
655 cmdbuffer->buf[0]=0x33;
656 DAQ_Format_AppendBuffer(cmdbuffer,data);
657
658 cmdbuffer->eto = DAQ_RAM_WRITEDATA_ETO;
659 cmdbuffer->ato = DAQ_RAM_WRITEDATA_ATO;
660
661 return DAQ_SC_SUCCESSFUL;
662 }
663
664 status_code DAQ_Format_Ram_EndBlock(DAQ_CMD_BUF* cmdbuffer) {
665 cmdbuffer->eto = DAQ_RAM_ENDBLOCK_ETO;
666 cmdbuffer->ato = DAQ_RAM_ENDBLOCK_ATO;
667 return DAQ_Format_OneByteCmd(cmdbuffer,0x55);
668 }
669
670 status_code DAQ_Format_Ram_ReadData(DAQ_CMD_BUF* cmdbuffer) {
671
672
673 cmdbuffer->eto = DAQ_RAM_READDATA_ETO;
674 cmdbuffer->ato = DAQ_RAM_READDATA_ATO;
675
676 return DAQ_Format_OneByteCmd(cmdbuffer,0x4b);
677 }
678
679
680 status_code DAQ_Format_Dsp_StartProgram(DAQ_CMD_BUF* cmdbuffer) {
681 cmdbuffer->eto = DAQ_DSP_STARTPROGRAM_ETO;
682 cmdbuffer->ato = DAQ_DSP_STARTPROGRAM_ATO;
683 return DAQ_Format_OneByteCmd(cmdbuffer,0x1E);
684 }
685
686 status_code DAQ_Format_Dsp_SetAddress(DAQ_CMD_BUF* cmdbuffer,BOOL PMDM,unsigned int addr) {
687 DAQ_CTRL_SET_LEN(cmdbuffer,3);
688 cmdbuffer->buf[0]=0x2d;
689 cmdbuffer->buf[1]= (BYTE) ( ((PMDM ? 1 : 0) << 7) | ( (addr & 0x00007F00) >> 8 ) );
690 cmdbuffer->buf[2]= (BYTE) ( addr & 0x000000FF );
691 cmdbuffer->eto = DAQ_DSP_SETADDRESS_ETO;
692 cmdbuffer->ato = DAQ_DSP_SETADDRESS_ATO;
693 return DAQ_SC_SUCCESSFUL;
694 }
695
696 status_code DAQ_Format_Dsp_SetAddressPM(DAQ_CMD_BUF* cmdbuffer,unsigned int addr) {
697 return DAQ_Format_Dsp_SetAddress(cmdbuffer,0,addr);
698 }
699
700 status_code DAQ_Format_Dsp_SetAddressDM(DAQ_CMD_BUF* cmdbuffer,unsigned int addr) {
701 return DAQ_Format_Dsp_SetAddress(cmdbuffer,1,addr);
702 }
703
704 status_code DAQ_Format_Dsp_WriteData(DAQ_CMD_BUF* cmdbuffer,DAQ_CMD_BUF *data) {
705 DAQ_CTRL_SET_LEN(cmdbuffer,2);
706 cmdbuffer->buf[0]=0x33;
707 cmdbuffer->buf[1]=(BYTE) data->len;
708
709 cmdbuffer->eto = DAQ_DSP_WRITEDATA_ETO;
710 cmdbuffer->ato = DAQ_DSP_WRITEDATA_ATO;
711
712 return DAQ_Format_AppendBuffer(cmdbuffer,data);
713 }
714
715 status_code DAQ_Format_Dsp_ReadData(DAQ_CMD_BUF* cmdbuffer) {
716
717 cmdbuffer->eto = DAQ_DSP_READDATA_ETO;
718 cmdbuffer->ato = DAQ_DSP_READDATA_ATO;
719
720 return DAQ_Format_OneByteCmd(cmdbuffer,0x4b);
721 }
722
723 status_code DAQ_Format_Dsp_CheckMemory(DAQ_CMD_BUF* cmdbuffer) {
724 cmdbuffer->eto = DAQ_DSP_CHECKMEMORY_ETO;
725 cmdbuffer->ato = DAQ_DSP_CHECKMEMORY_ATO;
726 return DAQ_Format_OneByteCmd(cmdbuffer,0x55);
727 }
728
729 status_code DAQ_Format_Dsp_ResetDSP(DAQ_CMD_BUF* cmdbuffer) {
730 cmdbuffer->eto = DAQ_DSP_RESET_ETO;
731 cmdbuffer->ato = DAQ_DSP_RESET_ATO;
732 return DAQ_Format_OneByteCmd(cmdbuffer,0x66);
733 }
734
735
736
737 status_code DAQ_Format_Dsp_FlagRead(DAQ_CMD_BUF* cmdbuffer) {
738 cmdbuffer->eto = DAQ_DSP_FLAGREAD_ETO;
739 cmdbuffer->ato = DAQ_DSP_FLAGREAD_ATO;
740 return DAQ_Format_OneByteCmd(cmdbuffer,0x78);
741 }
742
743
744
745 // ----------------------- Functions to format "IDAQ" Commands -------------------------
746
747 /*
748 * DAQ_Format_Fe2Daq
749 *
750 * Appends into the buffer 'idaqbuf' the "Fe2Daq" IDAQ command.
751 *
752 * Input:
753 * cmdbuffer: the buffer containing the command for the FE
754 * link : the link to send the command to
755 * ETO/ATO information is transfered from cmdbuffer
756 * Output:
757 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
758 * end of this buffer.
759 * Return:
760 * see DAQ_STATUS_CODE
761 *
762 */
763
764 status_code DAQ_Format_Fe2Daq(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer,DAQ_FE link) {
765 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_FE2DAQ,link,
766 cmdbuffer->eto,cmdbuffer->ato);
767 }
768
769
770 /*
771 * DAQ_Format_Fe2Ram
772 *
773 * Appends into the buffer 'idaqbuf' the "Fe2Ram" IDAQ command.
774 *
775 * Input:
776 * cmdbuffer: the buffer containing the command for the FE
777 * link : the link to send the command to
778 * ETO/ATO information is transfered from cmdbuffer
779 * Output:
780 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
781 * end of this buffer.
782 * Return:
783 * see DAQ_STATUS_CODE
784 *
785 */
786
787 status_code DAQ_Format_Fe2Ram(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer,DAQ_FE link) {
788 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_FE2RAM,link,
789 cmdbuffer->eto,cmdbuffer->ato);
790 }
791
792 /*
793 * DAQ_Format_Fe2Dsp
794 *
795 * Appends into the buffer 'idaqbuf' the "Fe2Dsp" IDAQ command.
796 *
797 * Input:
798 * cmdbuffer: the buffer containing the command for the FE
799 * link : the link to send the command to.
800 * ETO/ATO information is transfered from cmdbuffer
801 * Output:
802 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
803 * end of this buffer.
804 * Return:
805 * see DAQ_STATUS_CODE
806 *
807 */
808
809 status_code DAQ_Format_Fe2Dsp(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer,DAQ_FE link) {
810 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_FE2DSP,link,
811 cmdbuffer->eto,cmdbuffer->ato);
812 }
813
814 /*
815 * DAQ_Format_Dsp2Daq
816 *
817 * Appends into the buffer 'idaqbuf' the "Dsp2Daq" IDAQ command.
818 *
819 * Input:
820 * cmdbuffer: the buffer containing the command for the DSP.
821 * ETO/ATO information is transfered from cmdbuffer
822 *
823 * Output:
824 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
825 * end of this buffer.
826 * Return:
827 * see DAQ_STATUS_CODE
828 *
829 */
830
831 status_code DAQ_Format_Dsp2Daq(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
832 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_DSP2DAQ,DAQ_FE_SPARE,
833 cmdbuffer->eto,cmdbuffer->ato);
834 }
835
836 /*
837 * DAQ_Format_Dsp2Ram
838 *
839 * Appends into the buffer 'idaqbuf' the "Dsp2Ram" IDAQ command.
840 *
841 * Input:
842 * cmdbuffer: the buffer containing the command for the DSP
843 * ETO/ATO information is transfered from cmdbuffer
844 * Output:
845 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
846 * end of this buffer.
847 * Return:
848 * see DAQ_STATUS_CODE
849 *
850 */
851
852 status_code DAQ_Format_Dsp2Ram(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
853 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_DSP2RAM,DAQ_FE_SPARE,
854 cmdbuffer->eto,cmdbuffer->ato);
855 }
856 /*
857 * DAQ_Format_Flash2Dsp
858 *
859 * Appends into the buffer 'idaqbuf' the "Flash2Dsp" IDAQ command.
860 *
861 * Input:
862 * cmdbuffer: the buffer containing the command for the DSP
863 * ETO/ATO information is transfered from cmdbuffer to idaqbuf
864 * Output:
865 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
866 * end of this buffer.
867 * Return:
868 * see DAQ_STATUS_CODE
869 *
870 */
871
872 status_code DAQ_Format_Flash2Dsp(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
873 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_FLASH2DSP,DAQ_FE_SPARE,
874 cmdbuffer->eto,cmdbuffer->ato);
875 }
876
877 /*
878 * DAQ_Format_Flash2Dsp
879 *
880 * Appends into the buffer 'idaqbuf' the "Flash2Fe" IDAQ command.
881 *
882 * Input:
883 * cmdbuffer: the buffer containing the command for the Flash
884 * ETO/ATO information is transfered from cmdbuffer
885 * link : the link to send the command to.
886 * Output:
887 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
888 * end of this buffer.
889 * Return:
890 * see DAQ_STATUS_CODE
891 *
892 */
893
894 status_code DAQ_Format_Flash2Fe(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer,DAQ_FE link) {
895 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_FLASH2FE,link,
896 cmdbuffer->eto,cmdbuffer->ato);
897 }
898
899 /*
900 * DAQ_Format_Ram2Daq
901 *
902 * Appends into the buffer 'idaqbuf' the "Ram2Daq" IDAQ command.
903 *
904 * Input:
905 * cmdbuffer: the buffer containing the command for the IDAQ RAM
906 * ETO/ATO information is transfered from cmdbuffer
907 * Output:
908 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
909 * end of this buffer.
910 * Return:
911 * see DAQ_STATUS_CODE
912 *
913 */
914
915
916 status_code DAQ_Format_Ram2Daq(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
917 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_RAM2DAQ,DAQ_FE_SPARE,cmdbuffer->eto,cmdbuffer->ato);
918 }
919
920 /*
921 * DAQ_Format_Ram2Dsp
922 *
923 * Appends into the buffer 'idaqbuf' the "Ram2Dsp" IDAQ command.
924 *
925 * Input:
926 * cmdbuffer: the buffer containing the command for the IDAQ DSP
927 * ETO/ATO information is transfered from cmdbuffer
928 * Output:
929 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
930 * end of this buffer.
931 * Return:
932 * see DAQ_STATUS_CODE
933 *
934 */
935
936
937 status_code DAQ_Format_Ram2Dsp(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
938 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_RAM2DSP,DAQ_FE_SPARE,
939 cmdbuffer->eto,cmdbuffer->ato);
940 }
941
942
943 /*
944 * DAQ_Format_ReleaseBusy
945 *
946 * Appends into the buffer 'idaqbuf' the "ReleaseBusy" IDAQ command.
947 *
948 * Output:
949 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
950 * end of this buffer.
951 * Return:
952 * see DAQ_STATUS_CODE
953 *
954 */
955
956 status_code DAQ_Format_ReleaseBusy(DAQ_CMD_BUF* idaqcmd) {
957 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,&nullbuf,DAQ_OP_RELEASEBUSY,DAQ_FE_SPARE,
958 DAQ_RELEASEBUSY_ETO,DAQ_RELEASEBUSY_ATO);
959 }
960
961
962
963 status_code DAQ_Format_Spare(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
964 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_SPARE,DAQ_FE_SPARE,
965 cmdbuffer->eto,cmdbuffer->ato);
966 }
967
968
969 /*
970 * DAQ_Format_Cmd2Fe
971 *
972 * Appends into the buffer 'idaqbuf' the "Cmd2Fe" IDAQ command.
973 *
974 * Input:
975 * cmdbuffer: the buffer to send to the FE
976 * ETO/ATO information is transfered from cmdbuffer
977 * link : the link ID of the FE
978 * Output:
979 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
980 * end of this buffer.
981 * Return:
982 * see DAQ_STATUS_CODE
983 *
984 */
985 status_code DAQ_Format_Cmd2Fe(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer,DAQ_FE link) {
986 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_CMD2FE,link,
987 cmdbuffer->eto,cmdbuffer->ato);
988 }
989
990
991 /*
992 * DAQ_Format_Cmd2Flash
993 *
994 * Appends into the buffer 'idaqbuf' the "Cmd2Flash" IDAQ command.
995 *
996 * Input:
997 * cmdbuffer: the buffer containing the command for the IDAQ Flash
998 * ETO/ATO information is transfered from cmdbuffer
999 * Output:
1000 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1001 * end of this buffer.
1002 * Return:
1003 * see DAQ_STATUS_CODE
1004 *
1005 */
1006 status_code DAQ_Format_Cmd2Flash(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
1007 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_CMD2FLASH,DAQ_FE_SPARE,
1008 cmdbuffer->eto,cmdbuffer->ato);
1009 }
1010
1011 /*
1012 * DAQ_Format_Cmd2Dsp
1013 *
1014 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command.
1015 *
1016 * Input:
1017 * cmdbuffer: the buffer containing the command for the IDAQ DSP
1018 * ETO/ATO information is transfered from cmdbuffer
1019 * Output:
1020 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1021 * end of this buffer.
1022 * Return:
1023 * see DAQ_STATUS_CODE
1024 *
1025 */
1026 status_code DAQ_Format_Cmd2Dsp(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
1027 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_CMD2DSP,DAQ_FE_SPARE,
1028 cmdbuffer->eto,cmdbuffer->ato);
1029 }
1030
1031 /*
1032 * DAQ_Format_Cmd2Flash
1033 *
1034 * Appends into the buffer 'idaqbuf' the "Cmd2Ram" IDAQ command.
1035 *
1036 * Input:
1037 * cmdbuffer: the buffer containing the command for the IDAQ RAM
1038 * ETO/ATO information is transfered from cmdbuffer
1039 * Output:
1040 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1041 * end of this buffer.
1042 * Return:
1043 * see DAQ_STATUS_CODE
1044 *
1045 */
1046 status_code DAQ_Format_Cmd2Ram(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer) {
1047 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_CMD2RAM,DAQ_FE_SPARE,
1048 cmdbuffer->eto,cmdbuffer->ato
1049 );
1050 }
1051
1052
1053 /*
1054 * DAQ_Format_Ram2Fe
1055 *
1056 * Appends into the buffer 'idaqbuf' the "Ram2Fe" IDAQ command.
1057 *
1058 * Input:
1059 * cmdbuffer: the buffer containing the command for the IDAQ RAM
1060 * ETO/ATO information is transfered from cmdbuffer
1061 * Output:
1062 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1063 * end of this buffer.
1064 * Return:
1065 * see DAQ_STATUS_CODE
1066 *
1067 */
1068 status_code DAQ_Format_Ram2Fe(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* cmdbuffer,DAQ_FE link) {
1069 return DAQ_Format_CMD(DAQ_APPEND,idaqcmd,cmdbuffer,DAQ_OP_RAM2FE,link,
1070 cmdbuffer->eto,cmdbuffer->ato);
1071 }
1072
1073 /*
1074 * DAQ_Format_Cmd2Ram_SetAddress
1075 *
1076 * Appends into the buffer 'idaqbuf' the "Cmd2Ram" IDAQ command that set the address for the RAM.
1077 *
1078 * Input:
1079 * cmdbuffer: the buffer to send to the FE
1080 * addr : the IDAQ RAM address to set to.
1081 * Output:
1082 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1083 * end of this buffer.
1084 *
1085 * Return:
1086 * see DAQ_STATUS_CODE
1087 *
1088 */
1089
1090 status_code DAQ_Format_Cmd2Ram_SetAddress(DAQ_CMD_BUF* idaqcmd,unsigned int addr) {
1091 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1092 DAQ_Format_Ram_SetAddress(&tempbuf,addr),
1093 DAQ_Format_Cmd2Ram(idaqcmd,&tempbuf)
1094 );
1095 }
1096
1097 /*
1098 * DAQ_Format_Cmd2Ram_WriteData
1099 *
1100 * Appends into the buffer 'idaqbuf' the "Cmd2Ram" IDAQ command that Write the data into the IDAQ RAM.
1101 *
1102 * Input:
1103 * data : the buffer containing the data to write.
1104 *
1105 * Output:
1106 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1107 * end of this buffer.
1108 *
1109 * Return:
1110 * see DAQ_STATUS_CODE
1111 *
1112 */
1113
1114 status_code DAQ_Format_Cmd2Ram_WriteData (DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF* data) {
1115 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1116 DAQ_Format_Ram_WriteData(&tempbuf,data),
1117 DAQ_Format_Cmd2Ram(idaqcmd,&tempbuf)
1118 );
1119 }
1120
1121
1122
1123
1124 /*
1125 * DAQ_Format_Cmd2Ram_ReadData
1126 *
1127 * Appends into the buffer 'idaqbuf' the "Cmd2Ram" IDAQ command that Read data from the IDAQ RAM.
1128 *
1129 * Input:
1130 *
1131 *
1132 * Output:
1133 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1134 * end of this buffer.
1135 *
1136 * Return:
1137 * see DAQ_STATUS_CODE
1138 *
1139 */
1140
1141 status_code DAQ_Format_Cmd2Ram_ReadData (DAQ_CMD_BUF* idaqcmd) {
1142 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1143 DAQ_Format_Ram_ReadData(&tempbuf),
1144 DAQ_Format_Cmd2Ram(idaqcmd,&tempbuf)
1145 );
1146 }
1147
1148
1149
1150 /*
1151 * DAQ_Format_Cmd2Ram_EndBlock
1152 *
1153 * Appends into the buffer 'idaqbuf' the "Cmd2Ram" IDAQ command containg the "end block" command for the
1154 * IDAQ RAM.
1155 *
1156 * Output:
1157 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1158 * end of this buffer.
1159 *
1160 * Return:
1161 * see DAQ_STATUS_CODE
1162 *
1163 */
1164
1165
1166 status_code DAQ_Format_Cmd2Ram_EndBlock (DAQ_CMD_BUF* idaqcmd) {
1167 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1168 DAQ_Format_Ram_EndBlock(&tempbuf),
1169 DAQ_Format_Cmd2Ram(idaqcmd,&tempbuf)
1170 );
1171 }
1172
1173 /*
1174 * DAQ_Format_Cmd2Dsp_StartProgram
1175 *
1176 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that send the "start program" command
1177 * to the IDAQ DSP
1178 *
1179 * Input:
1180 *
1181 * Output:
1182 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1183 * end of this buffer.
1184 *
1185 * Return:
1186 * see DAQ_STATUS_CODE
1187 *
1188 */
1189
1190 status_code DAQ_Format_Cmd2Dsp_StartProgram(DAQ_CMD_BUF* idaqcmd) {
1191 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1192 DAQ_Format_Dsp_StartProgram(&tempbuf),
1193 DAQ_Format_Cmd2Dsp(idaqcmd,&tempbuf);
1194 );
1195 }
1196
1197 /*
1198 * DAQ_Format_Cmd2Dsp_SetAddressPM
1199 *
1200 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that set the address for program memory
1201 * of the IDAQ DSP
1202 *
1203 * Input:
1204 * addr : the DSP program memory address to set to.
1205 *
1206 * Output:
1207 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1208 * end of this buffer.
1209 *
1210 * Return:
1211 * see DAQ_STATUS_CODE
1212 *
1213 */
1214
1215
1216 status_code DAQ_Format_Cmd2Dsp_SetAddressPM(DAQ_CMD_BUF* idaqcmd,unsigned int addr) {
1217 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1218 DAQ_Format_Dsp_SetAddressPM(&tempbuf,addr),
1219 DAQ_Format_Cmd2Dsp(idaqcmd,&tempbuf)
1220 );
1221 }
1222
1223
1224 /*
1225 * DAQ_Format_Cmd2Dsp_SetAddressDM
1226 *
1227 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that set the address for data memory
1228 * of the IDAQ DSP
1229 *
1230 * Input:
1231 * addr : the DSP data memory address to set to.
1232 *
1233 * Output:
1234 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1235 * end of this buffer.
1236 *
1237 * Return:
1238 * see DAQ_STATUS_CODE
1239 *
1240 */
1241
1242
1243 status_code DAQ_Format_Cmd2Dsp_SetAddressDM(DAQ_CMD_BUF* idaqcmd,unsigned int addr) {
1244 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1245 DAQ_Format_Dsp_SetAddressDM(&tempbuf,addr),
1246 DAQ_Format_Cmd2Dsp(idaqcmd,&tempbuf)
1247 );
1248 }
1249
1250 /*
1251 * DAQ_Format_Cmd2Dsp_WriteData
1252 *
1253 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that write the data into the IDAQ DSP
1254 *
1255 * Input:
1256 * data : the buffer containing the data to write into the DSP.
1257 *
1258 * Output:
1259 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1260 * end of this buffer.
1261 *
1262 * Return:
1263 * see DAQ_STATUS_CODE
1264 *
1265 */
1266
1267
1268 status_code DAQ_Format_Cmd2Dsp_WriteData(DAQ_CMD_BUF* idaqcmd,DAQ_CMD_BUF *data) {
1269 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1270 DAQ_Format_Dsp_WriteData(&tempbuf,data),
1271 DAQ_Format_Cmd2Dsp(idaqcmd,&tempbuf)
1272 );
1273 }
1274
1275 /*
1276 * DAQ_Format_Cmd2Dsp_CheckMemory
1277 *
1278 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that is "check memory" for the IDAQ DSP
1279 *
1280 * Input:
1281 *
1282 * Output:
1283 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1284 * end of this buffer.
1285 *
1286 * Return:
1287 * see DAQ_STATUS_CODE
1288 *
1289 */
1290
1291
1292 status_code DAQ_Format_Cmd2Dsp_CheckMemory(DAQ_CMD_BUF* cmdbuffer) {
1293 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1294 DAQ_Format_Dsp_CheckMemory(&tempbuf),
1295 DAQ_Format_Cmd2Dsp(cmdbuffer,&tempbuf)
1296 );
1297 }
1298
1299 /*
1300 * DAQ_Format_Cmd2Dsp_CheckMemory
1301 *
1302 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that is "reset DSP" for the IDAQ DSP
1303 *
1304 * Input:
1305 *
1306 * Output:
1307 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1308 * end of this buffer.
1309 *
1310 * Return:
1311 * see DAQ_STATUS_CODE
1312 *
1313 */
1314
1315
1316 status_code DAQ_Format_Cmd2Dsp_ResetDSP(DAQ_CMD_BUF* cmdbuffer) {
1317 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1318 DAQ_Format_Dsp_ResetDSP(&tempbuf),
1319 DAQ_Format_Cmd2Dsp(cmdbuffer,&tempbuf)
1320 );
1321 }
1322
1323 /*
1324 * DAQ_Format_Cmd2Dsp_FlagRea
1325 *
1326 * Appends into the buffer 'idaqbuf' the "Cmd2Dsp" IDAQ command that is "flag READ" for the IDAQ DSP
1327 *
1328 * Input:
1329 *
1330 * Output:
1331 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1332 * end of this buffer.
1333 *
1334 * Return:
1335 * see DAQ_STATUS_CODE
1336 *
1337 */
1338
1339 status_code DAQ_Format_Cmd2Dsp_FlagRead(DAQ_CMD_BUF* cmdbuffer) {
1340 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1341 DAQ_Format_Dsp_FlagRead(&tempbuf),
1342 DAQ_Format_Cmd2Dsp(cmdbuffer,&tempbuf)
1343 );
1344 }
1345
1346 /*
1347 * DAQ_Format_Cmd2Flash_SectorErase
1348 *
1349 * Appends into the buffer 'idaqbuf' the "Cmd2Flash" IDAQ command to Erase a flash sector
1350 *
1351 * Input:
1352 * sector : the IDAQ flash sector to erase.
1353 *
1354 * Output:
1355 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1356 * end of this buffer.
1357 *
1358 * Return:
1359 * see DAQ_STATUS_CODE
1360 *
1361 */
1362
1363 status_code DAQ_Format_Cmd2Flash_SectorErase(DAQ_CMD_BUF* cmdbuffer,BYTE sector) {
1364 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1365 DAQ_Format_Flash_SectorErase(&tempbuf,sector),
1366 DAQ_Format_Cmd2Flash(cmdbuffer,&tempbuf)
1367 );
1368 }
1369
1370
1371 /*
1372 * DAQ_Format_Cmd2Flash_SetAddress
1373 *
1374 * Appends into the buffer 'idaqbuf' the "Cmd2Flash" IDAQ command to set the address for the Flash.
1375 *
1376 * Input:
1377 * addr : the IDAQ flash address to set to
1378 *
1379 * Output:
1380 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1381 * end of this buffer.
1382 *
1383 * Return:
1384 * see DAQ_STATUS_CODE
1385 *
1386 */
1387
1388
1389 status_code DAQ_Format_Cmd2Flash_SetAddress(DAQ_CMD_BUF* cmdbuffer,unsigned int addr) {
1390 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1391 DAQ_Format_Flash_SetAddress(&tempbuf,addr),
1392 DAQ_Format_Cmd2Flash(cmdbuffer,&tempbuf)
1393 );
1394 }
1395
1396 /*
1397 * DAQ_Format_Cmd2Flash_SetAddress
1398 *
1399 * Appends into the buffer 'idaqbuf' the "Cmd2Flash" IDAQ command to Write data into
1400 * the IDAQ Flash
1401 *
1402 * Input:
1403 * data : the Buffer containing the data to write into the Flash
1404 *
1405 * Output:
1406 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1407 * end of this buffer.
1408 *
1409 * Return:
1410 * see DAQ_STATUS_CODE
1411 *
1412 */
1413
1414 status_code DAQ_Format_Cmd2Flash_WriteData(DAQ_CMD_BUF* cmdbuffer,DAQ_CMD_BUF *data) {
1415 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1416 DAQ_Format_Flash_WriteData(&tempbuf,data),
1417 DAQ_Format_Cmd2Flash(cmdbuffer,&tempbuf)
1418 );
1419 }
1420 /*
1421 * DAQ_Format_Cmd2Flash_EndBlock
1422 *
1423 * Appends into the buffer 'idaqbuf' the "Cmd2Flash" IDAQ command that is 'end block'
1424 *
1425 * Input:
1426 *
1427 * Output:
1428 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1429 * end of this buffer.
1430 *
1431 * Return:
1432 * see DAQ_STATUS_CODE
1433 *
1434 */
1435
1436 status_code DAQ_Format_Cmd2Flash_EndBlock(DAQ_CMD_BUF* cmdbuffer) {
1437 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1438 DAQ_Format_Flash_EndBlock(&tempbuf),
1439 DAQ_Format_Cmd2Flash(cmdbuffer,&tempbuf)
1440 );
1441 }
1442
1443
1444
1445 /*
1446 * DAQ_Format_Ram2Daq_ReadData
1447 *
1448 * Appends into the buffer 'idaqbuf' the "Ram2Daq" IDAQ command that is 'read data'
1449 *
1450 * Input:
1451 *
1452 * Output:
1453 * idaqbuf : the new command queue for the IDAQ. New command formatted is appended into the
1454 * end of this buffer.
1455 *
1456 * Return:
1457 * see DAQ_STATUS_CODE
1458 *
1459 */
1460
1461 status_code DAQ_Format_Ram2Daq_ReadData(DAQ_CMD_BUF* cmdbuffer) {
1462 DAQ_FORMAT_OPCODE_CMD_TEMPLATE(
1463 DAQ_Format_Ram_ReadData(&tempbuf),
1464 DAQ_Format_Ram2Daq(cmdbuffer,&tempbuf)
1465 );
1466 }
1467
1468
1469
1470
1471 #ifndef I386
1472
1473 status_code DAQ_ReadStatusWord(UINT16 *statusword) {
1474 UINT16 combuf=0xAA;
1475 status_code s;
1476 s=HK_KHB_Cmd2FE(KHB_IDAQ,1,1,&combuf,statusword,10);
1477 if(s==CM_RC_SUCCESSFUL)
1478 /*@LOG Read IDAQ status word - idaq_st_word */
1479 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,*statusword);
1480 else
1481 /*@LOG Error reading IDAQ status word - status */
1482 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,s);
1483 return s;
1484 }
1485
1486 status_code DAQ_WriteHeader2Buffer(DAQ_CMD_BUF *buffer,UINT32 counter,
1487 BYTE pkt_type,UINT32 len,TI_TIME obt) {
1488 BYTE *start;
1489 if(buffer->size - buffer->len < SM_PKTHEADER_LEN)
1490 return CM_RC_NO_SPACE_LEFT;
1491 start=(&(buffer->buf[buffer->len]));
1492
1493 start[0]=PM_HEADER_1;
1494 start[1]=PM_HEADER_2;
1495 start[2]=PM_HEADER_3;
1496
1497 start[3]=pkt_type;
1498 start[4]=pkt_type;
1499
1500 start[5]=(counter>>16) & 0xff;
1501 start[6]=(counter>>8) & 0xff;
1502 start[7]=(counter & 0xff);
1503
1504 start[8] =(obt>>24) & 0xFF;
1505 start[9] =(obt>>16) & 0xFF;
1506 start[10]=(obt>> 8) & 0xFF;
1507 start[11]=(obt ) & 0xFF;
1508
1509
1510 start[12]=(len>>16) & 0xff;
1511 start[13]=(len>>8 ) & 0xff;
1512 start[14]=(len ) & 0xff;
1513
1514 start[15]=CM_Compute_CRC16(0,start,15) & 0xff;
1515 buffer->len+=SM_PKTHEADER_LEN;
1516
1517 return CM_RC_SUCCESSFUL;
1518 }
1519
1520 status_code DAQ_WaitFreeCMDIF() {
1521 UINT32 counter;
1522 UINT16 n=0;
1523 OS_piTaskSuspend(1);
1524 while( (counter=SD_piGetCMDCounterLeft()) > 0 && (n++ < PRH_VAR_DAQ_WAITFREECMDIF_N)) {
1525 OS_piTaskSuspend(2);
1526 }
1527 if(counter > 0)
1528 return CM_RC_CMDIF_BUSY;
1529 return CM_RC_SUCCESSFUL;
1530
1531 }
1532
1533 status_code DAQ_WaitAllExpPageAvail() {
1534 UINT32 counter=0;
1535 while( !PM_pi_AllExpPageAvail() && counter++ < PRH_VAR_ALLPAGEAVAIL_ATTEMPT)
1536 OS_piTaskSuspend(2);
1537 if(counter > PRH_VAR_ALLPAGEAVAIL_ATTEMPT)
1538 return CM_RC_CMDIF_BUSY;
1539 return CM_RC_SUCCESSFUL;
1540 }
1541
1542
1543 status_code DAQ_ResetPIF(UINT32 eto,UINT32 dto,SM_ACQMODE mode,BYTE pkttype) {
1544 status_code status;
1545
1546 if ((status = DAQ_WaitFreeCMDIF()) == CM_RC_CMDIF_BUSY)
1547 {
1548 SD_piPIFReset();
1549 /*@LOG DAQ_ResetPIF: queue busy - status */
1550 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
1551 }
1552
1553 if(status = DAQ_WaitAllExpPageAvail())
1554 /*@LOG Page not available in DAQ_ResetPIF */
1555 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
1556
1557 SD_piSetEventTimeout(eto);
1558 SD_piSetDataTimeout(dto);
1559 PM_pi_SetAcqMode(mode);
1560 PM_pi_SetPktType(pkttype);
1561 return CM_RC_SUCCESSFUL;
1562 }
1563
1564 BOOL DAQ_WaitFreePif() {
1565 UINT32 ppCounter=0;
1566 BOOL fullPIF;
1567 while( ( fullPIF = !PM_pi_ExpPageAvail() ) && ppCounter < PRH_VAR_RM_N_TRIES_PREPARE_PAGE) {
1568 ppCounter++;
1569 if(PRH_VAR_RM_TRIES_PREPARE_PAGE_SLEEP)
1570 OS_piTaskSuspend(PRH_VAR_RM_TRIES_PREPARE_PAGE_SLEEP);
1571 }
1572 return !fullPIF;
1573 }
1574
1575
1576 static status_code DAQ_SendCmd2PIFWaitDAQReply_internal(BOOL catch_sint,
1577 SM_PAGEID page,
1578 BOOL storemm,
1579 DAQ_CMD_BUF *reply,
1580 BOOL storeram,
1581 status_code (*callback)())
1582 {
1583
1584 status_code status = CM_RC_SUCCESSFUL;
1585 status_code callback_status = CM_RC_SUCCESSFUL;
1586 rtems_event_set evout;
1587 unsigned int intLevel;
1588 unsigned int ppCounter;
1589 BOOL fullPIF;
1590
1591 if(page < SM_CALEXP0 || page > SM_CALEXP3)
1592 return CM_RC_BADPAGE;
1593
1594 if (storemm) {
1595 PM_pi_EnableStore_In_DataTimeOut();
1596 } else {
1597 PM_pi_DisableStore_In_DataTimeOut();
1598 }
1599
1600 /* clear all events */
1601 OS_piEventClear(OS_EVENT_PKT_READY |
1602 // OS_EVENT_SINT |
1603 OS_EVENT_ETO |
1604 OS_EVENT_FLUSH_HB |
1605 OS_EVENT_UNCOMPLETED_CMDIF);
1606
1607 PM_pi_UseCalibrationPage(page);
1608
1609 OS_piInterDisable(&intLevel);
1610 SD_piClearInt(SD_DATA_TO | SD_PAGE_OVR | SD_EVT_TO);
1611 SD_piUnMaskInt(SD_DATA_TO | SD_PAGE_OVR | SD_EVT_TO);
1612 OS_piInterEnable(intLevel);
1613 // OS_piInterDisable(&intLevel);
1614
1615 fullPIF=!DAQ_WaitFreePif();
1616 //OS_piInterEnable(intLevel);
1617
1618 if(fullPIF) {
1619 /* TBD: Some alarm here ? */
1620 /* Reset the pif: */
1621 // SD_piPIFReset();
1622 /*@LOG fullPIFF in DAQ_SendCmd2PIFWaitDAQReply_internal - status */
1623 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
1624 status=UNSATISFIED;
1625 }else{ //ca
1626 PM_pi_SetExpPktCpyFlag(storeram);
1627 status = PM_piPreparePage(TRUE);
1628 if(status!=CM_RC_SUCCESSFUL){
1629 /*@LOG PreparePage failed in DAQ_SendCmd2PIFWaitDAQReply_internal - status */
1630 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
1631 PM_pi_SetExpPktCpyFlag(FALSE);
1632 return status;
1633 }
1634
1635 if(callback != NULL)
1636 callback_status=callback();
1637
1638 status=OS_piEventReceive(OS_EVENT_PKT_READY |
1639 (catch_sint ? OS_EVENT_SINT : 0) |
1640 OS_EVENT_ETO |
1641 OS_EVENT_FLUSH_HB |
1642 OS_EVENT_UNCOMPLETED_CMDIF,
1643 RTEMS_WAIT | RTEMS_EVENT_ANY ,
1644 PRH_VAR_DAQ_EVENT_RECEIVE_TIMEOUT,&evout);
1645
1646 OS_piInterDisable(&intLevel);
1647 SD_piMaskInt(SD_DATA_TO | SD_PAGE_OVR | SD_EVT_TO);
1648 OS_piInterEnable(intLevel);
1649
1650 if(callback_status != CM_RC_SUCCESSFUL)
1651 return callback_status;
1652
1653 PM_pi_SetExpPktCpyFlag(FALSE);
1654 switch (status) {
1655 case SUCCESSFUL:
1656 if(evout & OS_EVENT_SINT) {
1657 PM_pi_DisableStore_In_DataTimeOut();
1658 status = CM_RC_SINT;
1659 }else if(evout & OS_EVENT_FLUSH_HB) {
1660 RM_WriteHBInfos(FALSE);
1661 }else if(evout & OS_EVENT_PKT_READY) {
1662 if (storeram && reply && reply->buf)
1663 {
1664 if (PM_pi_GetPacket(&(reply->len),reply->buf) == SM_STR_OK)
1665 status = CM_RC_SUCCESSFUL;
1666 else
1667 status = CM_RC_STOREERROR;
1668 }
1669 }else if(evout & OS_EVENT_ETO) {
1670 /* TBD: some alarm */
1671 status = CM_RC_RUNTIMEOUT;
1672 }else if(evout & OS_EVENT_UNCOMPLETED_CMDIF) {
1673 status = CM_RC_UNCOMPLETED_CMDIF;
1674 }
1675 break;
1676 case RTEMS_TIMEOUT:
1677 status = CM_RC_TIMEOUT;
1678 /*@LOG Timeout in DAQ_SendCmd2PIFWaitDAQReply_internal - status */
1679 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
1680 break;
1681 default:
1682 status=UNSATISFIED;
1683 /*@LOG UNSATISFIED in DAQ_SendCmd2PIFWaitDAQReply_internal - status */
1684 LU_INFN_LOG(LU_CRITICAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status);
1685 break;
1686 }
1687 }
1688
1689 return status;
1690 }
1691
1692 status_code DAQ_SendCmd2PIFWaitDAQReply(SM_PAGEID page,BOOL storemm, DAQ_CMD_BUF *reply,BOOL storeram) {
1693 return DAQ_SendCmd2PIFWaitDAQReply_internal(DAQ_CATCH_SINT, page, storemm, reply, storeram,NULL);
1694 }
1695
1696 status_code DAQ_SendCmd2PIFWaitDAQReply_NoSINT(SM_PAGEID page,BOOL storemm, DAQ_CMD_BUF *reply,BOOL storeram) {
1697 return DAQ_SendCmd2PIFWaitDAQReply_internal(DAQ_NO_CATCH_SINT, page, storemm, reply, storeram,NULL);
1698 }
1699
1700 status_code DAQ_SendCmd2PIFWaitDAQReply_CallBack(SM_PAGEID page,BOOL storemm,
1701 DAQ_CMD_BUF *reply,
1702 BOOL storeram,
1703 status_code (*callback)()) {
1704 return DAQ_SendCmd2PIFWaitDAQReply_internal(DAQ_CATCH_SINT, page, storemm, reply, storeram,callback);
1705 }
1706
1707
1708 status_code DAQ_StoreCmdQueue2PIF(SM_PAGEID page,DAQ_CMD_BUF *buf) {
1709 status_code status=CM_RC_SUCCESSFUL;
1710 SM_STRSTAT s;
1711 if(buf) {
1712 s=PM_pi_CopyToSRAM(page , buf->buf , buf->len);
1713 if(s==SM_STR_OK)
1714 status=CM_RC_SUCCESSFUL;
1715 else
1716 status=CM_RC_STOREERROR;
1717 }else
1718 status=CM_RC_EMPTY_BUFFER;
1719 return status;
1720 }
1721
1722 status_code DAQ_SendCmdQueue2CMDIF(SM_PAGEID page){
1723 UINT32 size;
1724 status_code status=CM_RC_SUCCESSFUL;
1725 SM_STRSTAT s;
1726
1727 if(page < SM_CALEXP0 || page > SM_CALEXP3)
1728 status=CM_RC_BADPAGE;
1729
1730 if(status==CM_RC_SUCCESSFUL){
1731 PM_pi_UseCalibrationPage(page);
1732 status = PM_piPreparePage(FALSE);
1733 if( status == CM_RC_SUCCESSFUL ) {
1734 if(status=DAQ_WaitFreeCMDIF())
1735 status =CM_RC_UNCOMPLETED_CMDIF;
1736 }
1737 /*
1738 size=PM_pi_GetDataLength(page);
1739 if(size == 0)
1740 status=CM_RC_EMPTY_BUFFER;
1741
1742 if (status==CM_RC_SUCCESSFUL && FT_piSavePage(page,(page*SM_SRAMPAGESIZE) + size - 1, FS_CMD) != FT_SUCCESS)
1743 status=CM_RC_STOREERROR;
1744 else
1745 if(status=DAQ_WaitFreeCMDIF())
1746 status =CM_RC_UNCOMPLETED_CMDIF;
1747 */
1748 }
1749 return status;
1750 }
1751
1752 status_code DAQ_SaveBuffer2MM(DAQ_CMD_BUF *buffer, FS_FILEID id,UINT32 timeout)
1753 {
1754 SM_STRSTAT strstat;
1755 status_code s=CM_RC_SUCCESSFUL;
1756 rtems_event_set out;
1757 if(buffer->len == 0)
1758 return CM_RC_EMPTY_BUFFER;
1759 if(id == FS_HK && timeout > 0) {
1760 /* wait for the OS_EVENT_SKETCHBOARD_FREE */
1761 s=OS_piEventReceive(OS_EVENT_SKETCHBOARD_FREE,RTEMS_WAIT,timeout,&out);
1762 if(s == RTEMS_TIMEOUT)
1763 s=CM_RC_TIMEOUT;
1764 }
1765 if ((s != CM_RC_TIMEOUT) &&
1766 (strstat = PM_pi_StorePacket(buffer->len,buffer->buf,id)) != SM_STR_OK) {
1767 s = CM_RC_STOREERROR;
1768 }
1769 //TDB
1770
1771 return(s);
1772 }
1773
1774
1775
1776
1777
1778 #endif // I386
1779
1780
1781

  ViewVC Help
Powered by ViewVC 1.1.23