/[PAMELA software]/quicklook/dataToXML/Data/compilationInfo/src/BasicSW/Bus1553B/BI_Bus1553B_op.c
ViewVC logotype

Contents of /quicklook/dataToXML/Data/compilationInfo/src/BasicSW/Bus1553B/BI_Bus1553B_op.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 /*
4 /* Module : BasicSW
5 /* C.I. No. :
6 /* $Revision: 1.1.1.1 $
7 /* $Date: 2003/08/04 09:40:21 $
8 /* Belonging to :
9 /* :
10 /* $RCSfile: BI_Bus1553B_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: BI_Bus1553B_op.c,v $
25 /* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani
26 /* Imported sources laben rel. 19.06.2003 integrated with pam2
27 /*
28 /* Revision 1.11 2003/06/09 07:17:02 aurora
29 /* fixed 1553 mcmd ack word
30 /*
31 /* Revision 1.10 2003/05/06 15:39:19 aurora
32 /* correct the downlink size of RT
33 /*
34 /* Revision 1.9 2003/04/29 13:18:56 aurora
35 /* removed mcmd counter in RT (bug)
36 /*
37 /* Revision 1.8 2002/11/14 09:40:45 zulia
38 /* Removed unused "status" variable
39 /*
40 /* Revision 1.7 2002/11/06 15:48:00 zulia
41 /* Correct 1553 ack bug
42 /*
43 /* Revision 1.6 2002/05/15 13:13:09 aurora
44 /* Modified to return MCMD ID and
45 /* Source Sequence Counter in case of MCMD validation error
46 /*
47 /* Revision 1.5 2002/05/09 08:16:33 zulia
48 /* * acceptance release
49 /*
50 /*
51 /*****************************************************************************/
52
53 /*============================= Include File ================================*/
54
55 #include <src/BasicSW/Bus1553B/BI_Bus1553B_op.h>
56 #include <src/BasicSW/Bus1553B/BI_Bus1553B_int.h>
57 #include <src/HKManager/HistoryArea/HA_HistoryArea_p.h>
58 #include <src/HKManager/ReportGenerator/RG_ReportGenerator_p.h>
59 #include <src/BasicSW/PatchDumpManager/PD_PatchDumpManager_p.h>
60 #include <src/BasicSW/TimingInfo/TI_TimingInfo_p.h>
61 #include <src/ModeManager/ModeCoordinator/MC_ModeCoordinator_p.h>
62
63 /*****************************************************************************/
64 /*============================== Local Variables ============================*/
65
66 /*****************************************************************************/
67 /* @Variable: BI_1553MCMDBuffer */
68 /* @Purpose : */
69 /* Array of unsigned short int. */
70 /* Array whose contents is the MCMD data */
71 /* @@ */
72 /*****************************************************************************/
73 static unsigned short int BI_1553MCMDBuffer[768];
74
75 /*****************************************************************************/
76 /* @Variable: BI_1553CCABuffer */
77 /* @Purpose : */
78 /* Array of unsigned short int. */
79 /* Array whose contents is the Communication Control Word */
80 /* @@ */
81 /*****************************************************************************/
82 static unsigned short int BI_1553CCABuffer[BI_MAX_CCA_VORDS];
83
84 /*****************************************************************************/
85 /* @Variable: BI_1553MCMDACKWord */
86 /* @Purpose : */
87 /* Array of unsigned short int. */
88 /* Array whose contents is the Acknowledge word */
89 /* @@ */
90 /*****************************************************************************/
91 static unsigned short int BI_1553MCMDACKWord[2];
92
93 /*****************************************************************************/
94 /* @Variable: HandshakeExecAck */
95 /* @Purpose : */
96 /* Unsigned int */
97 /* Variable to perform the handshake high level protocol */
98 /* @@ */
99 /*****************************************************************************/
100 static unsigned int HandshakeExecAck;
101
102 /*****************************************************************************/
103 /* @Variable: subAddBlkIDs */
104 /* @Purpose : */
105 /* Array of unsigned int. */
106 /* Array whose contents are the subaddress identifiers (0..255) */
107 /* @@ */
108 /*****************************************************************************/
109 static unsigned int subAddBlkIDs[MAX_1553SUBAD];
110
111 /*****************************************************************************/
112 /* @Variable: SubAddress */
113 /* @Purpose : */
114 /* Array of pointer to unsigned int. */
115 /* Array whose contents are the memory addresses of the subaddress */
116 /* @@ */
117 /*****************************************************************************/
118 static unsigned int* SubAddress[MAX_1553SUBAD];
119
120 /*****************************************************************************/
121 /* @Variable: Descriptor */
122 /* @Purpose : */
123 /* Array of DESC_BLK */
124 /* Array whose contents are the descriptor blocks of the subaddress */
125 /* @@ */
126 /*****************************************************************************/
127 static const DESC_BLK Descriptor[] =
128 {//ControlWord, TA, CA, MIB, Length
129 {BI_CTRLW_RSA01, 0x3630, 0x3630, 0x3D00}, // 32=0x20
130 {BI_CTRLW_RSA20, 0x0140, 0x0140, 0x0440}, // 768=0x300
131 {BI_CTRLW_RSA21, 0x0610, 0x0610, 0x0612}, // 2
132 {BI_CTRLW_RSA22, 0x0614, 0x0614, 0x0616}, // 2
133 {BI_CTRLW_TSA01, 0x3630, 0x3630, 0x3D00}, // 32=0x20
134 {BI_CTRLW_TSA02, 0x0620, 0x0620, 0x3D00}, // 2
135 {BI_CTRLW_TSA03, 0x0622, 0x0622, 0x3D00}, // 2
136 {BI_CTRLW_TSA04, 0x0624, 0x0624, 0x3D00}, // 12
137 {BI_CTRLW_TSA05, 0x0630, 0x0630, 0x3D00}, // 4096=0x1000
138 {BI_CTRLW_TSA06, 0x1630, 0x1630, 0x3D00}, // 4096=0x1000
139 {BI_CTRLW_TSA07, 0x2630, 0x2630, 0x3D00}, // 4096=0x1000
140 {BI_CTRLW_TMC02, 0x3630, 0x3630, 0x3D00}, // 2
141 {BI_CTRLW_TMC04, 0x3630, 0x3630, 0x3D00}, // 2
142 {BI_CTRLW_TMC05, 0x3630, 0x3630, 0x3D00} // 2
143 };
144
145
146 /*****************************************************************************/
147 /* @Variable: BI_1553McmdCounter */
148 /* @Purpose : */
149 /* This variable counts the number of received macrocommands */
150 /* @@ */
151 /*****************************************************************************/
152 static unsigned int BI_1553McmdCounter = 0;
153
154 /*****************************************************************************/
155
156 /*======= B u s 1 5 5 3 B O P E R A T I O N A L F U N C T I O N S =======*/
157
158 /*****************************************************************************/
159 /* @Function: BI_opInitBus1553B */
160 /* @Purpose : */
161 /* The function prepares the state of init for the module of 1553 */
162 /* setting the SuMMIT as a remote terminal and opening (legalize) all */
163 /* the subaddreesses to be used */
164 /* */
165 /* @@ */
166 /* @Parameter Name @Mode @Description */
167 /* status_code OUT Return code */
168 /* @@ */
169 /*****************************************************************************/
170
171 status_code BI_opInitBus1553B( void ) {
172 #ifndef SIMULATOR
173 status_1553 ret_val = BI_OK;
174 BI_TYPE_1553SUBAD j;
175 unsigned int* pexg;
176
177 for( pexg = (unsigned int*)EXG_MEM_ADRS_AREA0; pexg < (unsigned int*)(EXG_MEM_ADRS_AREA0+0x10000); pexg++ )
178 {
179 *pexg = 0;
180 }
181 #endif
182
183 HandshakeExecAck = FALSE;
184
185 #ifndef SIMULATOR
186 /* setting the SuMMIT Remote Terminal Address */
187 ret_val = BI_ifSuMMITRTDrv(BI_SUM_REMOTE_TERMINAL_IDENTIFIER);
188
189 /* legalize all the used subaddress */
190 subAddBlkIDs[BI_RSA01] = BI_ifSuMMITRTDbLegalize( BI_RX_BLK, BI_SUM_DB_ID_RSA01 );
191 subAddBlkIDs[BI_RSA20] = BI_ifSuMMITRTDbLegalize( BI_RX_BLK, BI_SUM_DB_ID_RSA20 );
192 subAddBlkIDs[BI_RSA21] = BI_ifSuMMITRTDbLegalize( BI_RX_BLK, BI_SUM_DB_ID_RSA21 );
193 subAddBlkIDs[BI_RSA22] = BI_ifSuMMITRTDbLegalize( BI_RX_BLK, BI_SUM_DB_ID_RSA22 );
194 subAddBlkIDs[BI_TSA01] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA01 );
195 subAddBlkIDs[BI_TSA02] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA02 );
196 subAddBlkIDs[BI_TSA03] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA03 );
197 subAddBlkIDs[BI_TSA04] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA04 );
198 subAddBlkIDs[BI_TSA05] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA05 );
199 subAddBlkIDs[BI_TSA06] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA06 );
200 subAddBlkIDs[BI_TSA07] = BI_ifSuMMITRTDbLegalize( BI_TX_BLK, BI_SUM_DB_ID_TSA07 );
201 subAddBlkIDs[BI_TMC02] = BI_ifSuMMITRTDbLegalize( BI_MC_BLK, BI_SUM_DB_ID_TMC02 );
202 subAddBlkIDs[BI_TMC04] = BI_ifSuMMITRTDbLegalize( BI_MC_BLK, BI_SUM_DB_ID_TMC04 );
203 subAddBlkIDs[BI_TMC05] = BI_ifSuMMITRTDbLegalize( BI_MC_BLK, BI_SUM_DB_ID_TMC05 );
204
205
206 /* setting SuMMIT Descriptor Blocks at starup */
207 for( j = BI_RSA01; j < MAX_1553SUBAD; j++ )
208 {
209 if ( subAddBlkIDs[j] >= 0 )
210 {
211 SubAddress[j] = (unsigned int*)BI_ifSuMMITRTDbWrite(subAddBlkIDs[j],Descriptor[j]);
212 }
213 else
214 {
215 ret_val = BI_SUB_ADRS_ERROR;
216 }
217 }
218
219
220 BI_1553McmdCounter = 0;
221
222 return (ret_val == BI_OK) ? SUCCESSFUL : UNSATISFIED;
223 #else
224 return SUCCESSFUL;
225 #endif // SIMULATOR
226 }
227
228
229 /*****************************************************************************/
230 /* @Function: BI_op1553BInterruptHandler */
231 /* @Purpose : */
232 /* The function is called by interrups received from 1553 and manages */
233 /* the macrocommands high level protocol. Retrieves data from the */
234 /* accesssed subaddress and then restores it */
235 /* */
236 /* @@ */
237 /* @Parameter Name @Mode @Description */
238 /* status_code OUT Return code */
239 /* @@ */
240 /*****************************************************************************/
241 status_code BI_op1553BInterruptHandler ( void )
242 {
243 status_code status = SUCCESSFUL;
244 unsigned int irq_pending_reg;
245 unsigned int irq_log_list_reg;
246 unsigned int offset,
247 *dbadrs,
248 num_irq;
249 BI_TYPE_1553SUBAD sub_accessed = MAX_1553SUBAD;
250 DESC_BLK db;
251 unsigned int* pexg;
252 unsigned int ssw, i;
253 MsgTsk sndMsg;
254 RG_RTFHEADER hd;
255 unsigned short int* pDump;
256
257 irq_log_list_reg = 0;
258 num_irq = 0;
259 /* reading the pending regs to determinate the event that generate intr */
260 BI_ifSuMMITRTRegRead(BI_SUM_PENDING_INTR_REG, &irq_pending_reg);
261
262 /* determinating if a SUBAD interrupt has been received (bit 10 in PIR) */
263 if( (irq_pending_reg & BI_IRQ_SUBAD_MASK) == BI_IRQ_SUBAD_MASK )
264 {
265 /* retrieves the starting address of Interrupt Log List */
266 BI_ifSuMMITRTRegRead(BI_SUM_INTR_LOG_LIST_PTR_REG, &irq_log_list_reg);
267
268 num_irq = (irq_log_list_reg & 0x001F) >> 1;
269
270 if( num_irq == 0 ) /* wrap around circular buffer 1^ or 16^ IRQ received */
271 {
272 offset = *((unsigned int*)EXG_MEM_ADRS_AREA0 + irq_log_list_reg + 0x1F) >> 16;
273 }
274 else
275 {
276 offset = *((unsigned int*)EXG_MEM_ADRS_AREA0 + irq_log_list_reg - 1) >> 16;
277 }
278
279 dbadrs = (unsigned int*)EXG_MEM_ADRS_AREA0 + offset;
280
281 if( dbadrs == SubAddress[BI_RSA21] ) /* EXECUTE */
282 {
283 sub_accessed = BI_RSA21;
284
285 BI_ifSuMMITRTDbGet( subAddBlkIDs[BI_RSA20], &db );
286
287 if ( !(db.ctrlWord & BI_RX_SUBADD_ACCESSED) )
288 {
289 status = UNSATISFIED;
290 BI_1553MCMDACKWord[0] |= BI_MCMD_NOT_OK | BI_MCMD_PROTOCOL_ERROR;
291 }
292 else
293 {
294 if( HandshakeExecAck == TRUE )
295 {
296 status = UNSATISFIED;
297 BI_1553MCMDACKWord[0] |= BI_MCMD_NOT_OK | BI_MCMD_PROTOCOL_ERROR;
298 }
299 else
300 {
301 HandshakeExecAck = TRUE;
302 BI_1553MCMDACKWord[0] = 0;
303 BI_1553MCMDACKWord[1] = 0;
304 status = BI_if1553BLoadMCMD(subAddBlkIDs[BI_RSA20],BI_1553MCMDBuffer,BI_1553MCMDACKWord);
305 if( BI_1553McmdCounter == 0xFFFF )
306 {
307 BI_1553McmdCounter = 0;
308 }
309 else
310 {
311 BI_1553McmdCounter += 1;
312 }
313 }
314 }
315
316 BI_if1553BWriteAck(subAddBlkIDs[BI_TSA03],subAddBlkIDs[BI_RSA20],BI_1553MCMDACKWord);
317 BI_if1553BWriteCCA(subAddBlkIDs[BI_TSA04],BI_1553CCABuffer,BI_1553MCMDACKWord);
318 }
319 else if(dbadrs == SubAddress[BI_RSA22]) /* PREPARE FORMAT */
320 {
321 sub_accessed = BI_RSA22;
322 pexg = BI_ifSuMMITRTGetDataAddress(subAddBlkIDs[BI_RSA22]);
323
324 if ( pexg == (unsigned int*)0 )
325 {
326 status = UNSATISFIED;
327 }
328 else
329 {
330 switch ( *pexg >> 16 ) /* only 16MSB are meaningful */
331 {
332 case BI_SSW:
333 BI_ifSuMMITRTDbWrite(subAddBlkIDs[BI_TSA02], Descriptor[BI_TSA02]);
334 status = BI_if1553BWriteSSW(subAddBlkIDs[BI_TSA02]);
335 break;
336
337 case BI_CCA:
338 BI_ifSuMMITRTDbWrite(subAddBlkIDs[BI_TSA03], Descriptor[BI_TSA03]);
339 status = BI_if1553BWriteCCA(subAddBlkIDs[BI_TSA04],BI_1553CCABuffer,BI_1553MCMDACKWord);
340 break;
341
342 case BI_RT:
343 BI_ifSuMMITRTDbWrite(subAddBlkIDs[BI_TSA05], Descriptor[BI_TSA05]);
344 sndMsg.LlInfo = 0;
345 sndMsg.Code = RG_PREPARE_FRM_RT;
346 status = RG_piSndMsgReportGenerator(&sndMsg);
347 break;
348
349 case BI_HA:
350 BI_ifSuMMITRTDbWrite(subAddBlkIDs[BI_TSA07], Descriptor[BI_TSA07]);
351 sndMsg.LlInfo = 0;
352 sndMsg.Code = HA_PREPAREFORMAT;
353 status = HA_piSndMsgHistoryArea(&sndMsg);
354 break;
355
356 case BI_DUMP:
357 BI_ifSuMMITRTDbWrite(subAddBlkIDs[BI_TSA06], Descriptor[BI_TSA06]);
358 RG_piPrepareHeader((unsigned short int*)&hd, RG_FORMAT_DUMP);
359
360 /* retrieve the start memory address of dumped data from PatchDump module */
361 PD_piGetDumpDataAddress(&pDump);
362
363 pexg = BI_ifSuMMITRTGetDataAddress(subAddBlkIDs[BI_TSA06]);
364 pexg[0] = hd.FmtBeginId;
365 pexg[1] = hd.SourceState;
366 pexg[2] = hd.FmtLength_Type;
367 pexg[3] = hd.FrmCounter;
368 pexg[4] = hd.OBTHigh;
369 pexg[5] = hd.OBTLow;
370 pexg[6] = hd.AnomCnt_HASpace;
371
372 pexg[PD_DUMP_MAX_BUFFER-1] = PD_DUMP_END_ID;
373
374 /* skip the header so increase by this value */
375 pexg += 7;
376
377 /* copies the dump into 1553 exchange memory */
378 i = 0;
379 while( i < PD_BUFFER_DUMP_MAX_SIZE )
380 {
381 *pexg++ = pDump[i++];
382 }
383 break;
384 default:
385 status = UNSATISFIED;
386 break;
387 }
388
389 }
390 }
391 else if(dbadrs == SubAddress[BI_TSA03]) /* SEND ACK */
392 {
393 sub_accessed = BI_TSA03;
394 if( HandshakeExecAck == TRUE )
395 {
396 HandshakeExecAck = FALSE;
397 }
398 else
399 {
400 status = UNSATISFIED;
401 BI_1553MCMDACKWord[0] |= BI_MCMD_NOT_OK | BI_MCMD_PROTOCOL_ERROR;
402 BI_if1553BWriteAck(subAddBlkIDs[BI_TSA03],subAddBlkIDs[BI_RSA20],BI_1553MCMDACKWord);
403 BI_if1553BWriteCCA(subAddBlkIDs[BI_TSA04],BI_1553CCABuffer,BI_1553MCMDACKWord);
404 }
405 }
406 else
407 {
408 sub_accessed = MAX_1553SUBAD;
409 status = UNSATISFIED;
410 }
411
412 if( sub_accessed != MAX_1553SUBAD )
413 {
414 BI_ifSuMMITRTDbWrite(subAddBlkIDs[BI_RSA20], Descriptor[BI_RSA20]);
415 BI_ifSuMMITRTDbWrite(subAddBlkIDs[sub_accessed], Descriptor[sub_accessed]);
416 }
417 }
418
419
420 return (status);
421 }
422
423
424
425 /*****************************************************************************/
426 /* @Function: BI_op1553BWriteHistory */
427 /* @Purpose : */
428 /* This function writes History Area Logs into 1553 memory area. */
429 /* Return code can be SUCCESSFUL or UNSATISFIED. */
430 /* */
431 /* @@ */
432 /* @Parameter Name @Mode @Description */
433 /* History IN Buffer in RAM from where to reads the data */
434 /* status_code OUT Return code */
435 /* @@ */
436 /*****************************************************************************/
437 status_code BI_op1553BWriteHistory(unsigned short int* History)
438 {
439 unsigned int *pexg, i;
440 status_code status = SUCCESSFUL;
441
442 pexg = BI_ifSuMMITRTGetDataAddress(subAddBlkIDs[BI_TSA07]);
443
444 if ( pexg == (unsigned int*)0 )
445 {
446 status = UNSATISFIED;
447 }
448 else
449 {
450 /* copy the History data into 1553 exchange memory */
451 i = 0;
452 while( i < BI_HA_SIZE )
453 {
454 *pexg++ = History[i++];
455 }
456 }
457
458 return status;
459 }
460
461
462 /*****************************************************************************/
463 /* @Function: BI_op1553BWriteRTFrm */
464 /* @Purpose : */
465 /* This function writes Telemetry formats into 1553 memory area. */
466 /* Return code can be SUCCESSFUL or UNSATISFIED. */
467 /* */
468 /* @@ */
469 /* @Parameter Name @Mode @Description */
470 /* tmlf IN Buffer in RAM from where to reads the data */
471 /* nword16 IN number of 16 bit words to be written */
472 /* status_code OUT Return code */
473 /* @@ */
474 /*****************************************************************************/
475 status_code BI_op1553BWriteRTFrm(unsigned short int* tmlf, unsigned int nword16)
476 {
477
478 unsigned int *pexg, *pmcmd_cnt, i;
479 status_code status = SUCCESSFUL;
480
481 pexg = BI_ifSuMMITRTGetDataAddress(subAddBlkIDs[BI_TSA05]);
482
483 if ( pexg == (unsigned int*)0 )
484 {
485 status = UNSATISFIED;
486 }
487 else
488 {
489 /* copy the RTF data into 1553 exchange memory */
490 i = 0;
491 while( i <= nword16 )
492 {
493 *pexg++ = tmlf[i++];
494 }
495 }
496
497 return status;
498 }
499
500
501
502 /*****************************************************************************/
503 /* @Function: BI_op1553BWriteStatusWord */
504 /* @Purpose : */
505 /* This function writes the subsystem status word into 1553 exchange */
506 /* memory at a fixed address of subaddress TSA2. */
507 /* Return code can be SUCCESSFUL or UNSATISFIED. */
508 /* */
509 /* @@ */
510 /* @Parameter Name @Mode @Description */
511 /* substatusword IN subsystem status word */
512 /* status_code OUT Return code */
513 /* @@ */
514 /*****************************************************************************/
515 status_code BI_op1553BWriteStatusWord(unsigned short int substatusword)
516 {
517 *(unsigned int *)BI_SSW_EXG_MEM_ADDR = substatusword;
518
519 return (status_code)SUCCESSFUL;
520 }
521
522
523 /*****************************************************************************/
524 /* @Function: BI_opGetCCAFormat */
525 /* @Purpose : */
526 /* This function returns the CCA format words. */
527 /* */
528 /* @@ */
529 /* @Parameter Name @Mode @Description */
530 /* CCABuffer IN CCA buffer */
531 /* status_code OUT Return code */
532 /* @@ */
533 /*****************************************************************************/
534 status_code BI_opGetCCAFormat (unsigned short int* CCABuffer)
535 {
536 unsigned int i;
537
538 BI_if1553BWriteCCA(subAddBlkIDs[BI_TSA04],BI_1553CCABuffer,BI_1553MCMDACKWord);
539 for (i=0; i<BI_MAX_CCA_VORDS; i++)
540 {
541 CCABuffer[i] =BI_1553CCABuffer[i];
542 }
543 return (SUCCESSFUL);
544 }

  ViewVC Help
Powered by ViewVC 1.1.23