/** * MIL-STD 1553B Library - Carlo Gavazzi Space * * Filename : \file MilRt.c * * Purposes : \brief MIL-STD 1553B Library - Carlo Gavazzi Space * * Logical Task : N/A * * Author : CGSpace * * Last Developer : $Author: lorenzo $ * * Revision : $Revision: 1.3 * * Checkout Tag : $Name: $ * * Last Modification : $Date: 2006/10/20 09:22:14 $ * * Location : $RCSfile: MilRt.c,v $ * * \version : $Header: /home/local/cvsrep/OBS_FM/1553_Lib/MilRt.c,v 1.10 2006/10/20 09:22:14 lorenzo Exp $ */ /** * Commitments History : * As reported in Main cvs Documentation * ( https://www.cvshome.org/docs/manual/cvs-1.11.18/cvs_12.html#SEC102 ) * The Modification Log has been posted at End Of File. */ // ---------------------------------------------------------------------------// /* Rt.c - These routines allow for managing the ACE chip in Remote Terminal configuration */ /* Purpose: The module contains the routines for managing the ACE chip in RT mode. Content: The module contains the following functions: - SUBHEADINGS Project : HSO/FIRST BASIC S/W Component : HSO/FIRST DRIVERS S/W Filename : $RCSfile: MilRt.c,v $ CI Number : Revision : Revision: 1.3 Company : Carlo Gavazzi Space S.P.A. Author : Andrea Bertoli Creation Date : 2000/05/15 SEE ALSO: ADD Ref: Inserted here reference with Architectural Design and Detail Document. Other Ref: Notes: */ #include "MilDef.h" /* static variable */ FrameType spw_RxFrameID[MIL_SA_MESSAGE]; FrameType spw_TxFrameID[MIL_SA_MESSAGE]; ConfigDDCMemType saw_ConfigDDCMem[MIL_SA_MESSAGE]; extern RxMsgPointerStructType gbv_RxMessages[MIL_SA_MESSAGE]; extern RxMsgPointerStructType gbv_TxMessages[MIL_SA_MESSAGE]; /* #define PD pw_MilConf-BcstMm; j_Temp |= 0x0008 * pw_Sacw->BcstBuffInt; j_Temp |= 0x0010 * pw_Sacw->BcstEomInt; j_Temp |= 0x0020 * pw_Sacw->RxMm; j_Temp |= 0x0100 * pw_Sacw->RxBuffInt; j_Temp |= 0x0200 * pw_Sacw->RxEomInt; j_Temp |= 0x0400 * pw_Sacw->TxMm; j_Temp |= 0x2000 * pw_Sacw->TxBuffInt; j_Temp |= 0x4000 * pw_Sacw->TxEomInt; j_Temp |= 0x8000 * pw_Sacw->RcvBufferType; return(j_Temp); } /******************************************************************** * * Word2Sacw - converts the Subaddress control word from word * format in structure format * * Description * converts the Subaddress control word from word * format in structure format * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Word subaddres control word * * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: handle to new block * * SEE ALSO: * * * INTERNAL * This section will not appear in the generated manual entry. * */ SubAddrCtrlWrd Word2Sacw (MilConf_p pw_MilConf, unsigned int j_Word) { SubAddrCtrlWrd w_Temp; w_Temp.BcstMm = j_Word & 0x0007; w_Temp.BcstBuffInt = (j_Word & 0x08) >> 3; w_Temp.BcstEomInt = (j_Word & 0x10) >> 4; w_Temp.RxMm = (j_Word & 0xE0) >> 5; w_Temp.RxBuffInt = (j_Word & 0x100) >> 8; w_Temp.RxEomInt = (j_Word & 0x200) >> 9; w_Temp.TxMm = (j_Word & 0x1C00) >> 10; w_Temp.TxBuffInt = (j_Word & 0x2000) >> 13; w_Temp.TxEomInt = (j_Word & 0x4000) >> 14; w_Temp.RcvBufferType = (j_Word & 0x8000) >> 15; return(w_Temp); } /******************************************************************** * * MilReadRTAddress - Reads the Remote Terminal Address * * Description * Reads the Remote terminal address * RT Address 0 - 31 * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Remote terminal Address * * SEE ALSO: * * * INTERNAL * This section will not appear in the generated manual entry. * */ unsigned char MilRTAddress(MilConf_p pw_MilConf) { /* return the Remote Terminal subaddress */ /* shift of one bit to retuinr the Remote terminal address */ return((unsigned char)((MilReadReg(pw_MilConf,CONFIG_5) & 0x003E)>>1)); } /******************************************************************** * * MilReadParityBit - Reads the parity bit * * Description * Reads the parity bit * the RTADP must be programmed to create an odd parity * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Remote terminal Address * * SEE ALSO: * * * INTERNAL * This section will not appear in the generated manual entry. * */ unsigned char MilReadParityBit(MilConf_p pw_MilConf) { /* return the Remote Terminal subaddress */ /* shift of one bit to retuinr the Remote terminal address */ return((unsigned char)(MilReadReg(pw_MilConf,CONFIG_5) & 0x0001)); } /******************************************************************** * * MilRTIrqMsgSAEnable - This routine enables circular buffer rollover * * Description * This routine enables circular buffer rollover * * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_SubAddr Mil1553 Subaddress * - d_t_r receive and transmit flag * - d_Selection CIRCULAR_BUFFER and END_OF_MESSAGE * * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * */ MilError_t MilRTIrqMsgSaEnable( MilConf_p pw_MilConf, unsigned int j_SubAddr, unsigned char d_t_r, unsigned char d_Selection ) { /* local var */ RTWords w_Temp; /* initilize w_temp */ w_Temp.j_Word = 0x0000; switch (d_t_r) { case TRANSMIT: if (d_Selection == RT_CIRCULAR_BUFFER) w_Temp.w_Sacw.TxBuffInt = RT_ENABLE; else { if (d_Selection == RT_END_OF_MESSAGE) w_Temp.w_Sacw.TxEomInt = RT_ENABLE; else return MIL_BAD_SELECTION; } break; case RECEIVE: if (d_Selection == RT_CIRCULAR_BUFFER) w_Temp.w_Sacw.RxBuffInt = RT_ENABLE; else { if (d_Selection == RT_END_OF_MESSAGE) w_Temp.w_Sacw.RxEomInt = RT_ENABLE; else return MIL_BAD_SELECTION; } break; case BROADCAST: if (d_Selection == RT_CIRCULAR_BUFFER) w_Temp.w_Sacw.BcstBuffInt = RT_ENABLE; else { if (d_Selection == RT_END_OF_MESSAGE) w_Temp.w_Sacw.BcstEomInt = RT_ENABLE; else return MIL_BAD_SELECTION; } break; default: return MIL_BAD_SELECTION; break; } /* set the value in RAM */ MilWriteRam(pw_MilConf, LOOKUP_A+96+j_SubAddr,(MilReadRam(pw_MilConf, LOOKUP_A+96+j_SubAddr) | w_Temp.j_Word)); return MIL_SUCCESS; }/* end procedure */ /******************************************************************** * * MilRTIrqMsgSADisable - This routine disables circular buffer rollover * * Description * This routine enables circular buffer rollover * * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_SubAddr Mil1553 Subaddress * - d_t_r receive and transmit flag * - d_Selection CIRCULAR_BUFFER and END_OF_MESSAGE * * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * */ MilError_t MilRTIrqMsgSaDisable( MilConf_p pw_MilConf, unsigned int j_SubAddr, unsigned char d_t_r, unsigned char d_Selection ) { /* local var */ RTWords w_Temp; /* initilize w_temp */ w_Temp.j_Word = 0xFFFF; switch (d_t_r) { case TRANSMIT: if (d_Selection == RT_CIRCULAR_BUFFER) w_Temp.w_Sacw.TxBuffInt = RT_DISABLE; else { if (d_Selection == RT_END_OF_MESSAGE) w_Temp.w_Sacw.TxEomInt = RT_DISABLE; else return MIL_BAD_SELECTION; } break; case RECEIVE: if (d_Selection == RT_CIRCULAR_BUFFER) w_Temp.w_Sacw.RxBuffInt = RT_DISABLE; else { if (d_Selection == RT_END_OF_MESSAGE) w_Temp.w_Sacw.RxEomInt = RT_DISABLE; else return MIL_BAD_SELECTION; } break; case BROADCAST: if (d_Selection == RT_CIRCULAR_BUFFER) w_Temp.w_Sacw.BcstBuffInt = RT_DISABLE; else { if (d_Selection == RT_END_OF_MESSAGE) w_Temp.w_Sacw.BcstEomInt = RT_DISABLE; else return MIL_BAD_SELECTION; } break; default: return MIL_BAD_SELECTION; break; } /* set the value in RAM */ MilWriteRam(pw_MilConf, LOOKUP_A+96+j_SubAddr,(MilReadRam(pw_MilConf, LOOKUP_A+96+j_SubAddr) & w_Temp.j_Word)); return MIL_SUCCESS; } /******************************************************************** * * MilRTDefSA - This routine is used to configure the memory management * and interrupt schemes * * Description * This routine is used to configure the memory management * and interrupt schemes for the respective subaddress for * transmit, receive and broadcast commands. Valid memory * management schemes are SINGLE_MESSAGE, CIRCULAR_128, * CIRCULAR_256, CIRCULAR_512, CIRCULAR_1024, * CIRCULAR_2048, CIRCULAR_4096, and CIRCULAR_8192. End of * message interrupts may be generated by enabling the * selected message type (ex: Sacw->RxEomInt=YES) provided * that rt subaddress interrupts are enabled ( * MilIrqEnable(IRQ_END_OF_MESSAGE)). Circular buffer interrupts * may be generated by enabling the selected message type * (ex: Sacw->TxCircBuffInt=YES) provided that rt * subaddress interrupts are enabled ( * MilIrqEnable(IRQ_RT_CIRC_BUFFR_ROLLOVR)* * * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_SubAddr Mil1553 Subaddress * - w_Sacw subaddres control word * * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * */ MilError_t MilRTDefSA( MilConf_p pw_MilConf, unsigned int j_SubAddr, SubAddrCtrlWrd *pw_Sacw ) { RTWords w_Temp; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); w_Temp.j_Word = Sacw2Word(pw_MilConf, pw_Sacw); if(pw_Sacw->RcvBufferType) { /* turn on SA double buffering set bit 12 set enable Rx Sa Double buffer enable */ MilWriteReg(pw_MilConf, CONFIG_2,((MilReadReg(pw_MilConf, CONFIG_2)&0xefff)|0x1000)); } /* write subaddress in the look table A in the subaddres control word field */ MilWriteRam(pw_MilConf, LOOKUP_A+96+j_SubAddr,w_Temp.j_Word); return(MIL_SUCCESS); } /******************************************************************** * * MilRTMapBlk - This routine is used to configure the memory management * and interrupt schemes * * Description * This function is used to define the data block number * that is to be used with the selected transmit, receive * or broadcast subaddress. BlockHdl is a handle to a * memory block. This routine calls BuGetBlkAddress() * to obtain the absolute address of the block in ACE memory. * This address is placed in the rt lookup table. * * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_SubAddr Subaddress in the command word. * - j_t_r transmit/receive bit in the command word * - pw_BlockHdl a handle to a declared block of memory * - area Lookup table area * - Offset Word offset into buffer * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Absaddr of old data block ptr * * SEE ALSO: * * * INTERNAL * */ unsigned long MilRTMapBlk( MilConf_p pw_MilConf, unsigned int j_SubAddr, unsigned int j_t_r, RTBlkHandle pw_BlockHdl, unsigned int j_Offset ) { unsigned long m_Oldptr; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); /* gp will hold the subaddress and t_r bits for the associated block */ pw_BlockHdl->j_Gp =(j_SubAddr<<2)|j_t_r; /* save the old pointer */ m_Oldptr=(unsigned long)MilReadRam(pw_MilConf, (LOOKUP_A+(32*j_t_r)+ j_SubAddr)); /* write the new pointer */ MilWriteRam(pw_MilConf, (LOOKUP_A+(32*j_t_r)+ j_SubAddr), (pw_BlockHdl->m_AbsAddr + j_Offset)); /* return of old pointer */ return(m_Oldptr); } /******************************************************************** * * MilRTRun - Run the remote terminal * * Description * start the remote terminal * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Mil Error * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTRun(MilConf_p pw_MilConf) { if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT) return(MIL_ERROR_RTNOTOPENED); /* clear the stack */ MilBlockFill(pw_MilConf, STACK_A, 0x0000, 256); /* reset the stack pointer */ MilWriteRam(pw_MilConf, STACK_POINTER_A, STACK_A); /* initialize the last message number pointer */ pw_MilConf->pw_RT->MilRTLastMsg = STACK_A; /* set mode to remote terminal */ MilWriteReg(pw_MilConf, CONFIG_1,(MilReadReg(pw_MilConf, CONFIG_1)&0x3fff)|0x8000 ); /* to set enhanced mode bit#15 in CONFIG #3 register has to set TRUE */ return(MIL_SUCCESS); } /******************************************************************** * * MilRTAllocBlk - function will allocate a data block * * Description * This function will allocate a data block within the * ACE memory space. The function is passed a block type * describing the size of the requested data block, * Valid values for BlkType are SINGLE_MESSAGE, * CIRCULAR_128, CIRCULAR_256, CIRCULAR_512, * CIRCULAR_1024, CIRCULAR_2048, CIRCULAR_4096, and * CIRCULAR_8192. If sucessfully, the function returns an * allocated handleto the data block * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - d_BlkType defined constant indicating size of data block * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: handle to allocated block if sucessfull otherwise * NULL ptr is returned * * SEE ALSO: * * * INTERNAL * * */ RTBlkHandle MilRTAllocBlk(MilConf_p pw_MilConf, unsigned char d_BlkType) { unsigned int j_Size; if(!pw_MilConf) return(NULL); if(!pw_MilConf->pw_RT) return(NULL); switch(d_BlkType) { case SINGLE_MESSAGE : j_Size=32; return(MilAllocHandle(pw_MilConf,j_Size)); case DOUBLE_MESSAGE : j_Size=64; break; case RTBUFFER128 : j_Size=128; break; case RTBUFFER256 : j_Size=256; break; case RTBUFFER512 : j_Size=512; break; case RTBUFFER1024 : j_Size=1024; break; case RTBUFFER2048 : j_Size=2048; break; case RTBUFFER4096 : j_Size=4096; break; case RTBUFFER8192 : j_Size=8192; break; default : return(NULL); } return(MilAllocHandleBoundary(pw_MilConf, j_Size, j_Size)); } /******************************************************************** * * MilRTFreeBlk - Free an allocated memory block * * Description * This function will free an allocated memory block and the * associated handle. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pw_BlockHdl memory block to free * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Mil Error * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTFreeBlk(MilConf_p pw_MilConf, RTBlkHandle pw_BlockHdl) { if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT) return(MIL_ERROR_RTNOTOPENED); MilReleaseHandle(pw_MilConf, pw_BlockHdl); return(MIL_SUCCESS); } /******************************************************************** * * MilRTFreeBlk - Free an allocated memory block * * Description * Allocates RT private data, sets up protected areas of memory, * sets all subaddress to point to the same SINGLE_MESSAGE * allocated block, and sets up enhanced RT mode.* * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Mil Error * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTOpen(MilConf_p pw_MilConf) { RTPtr pw_Tp; /* last message pointer */ MemBlockHandle pw_Tphdl; /* alloc the structure for memorizing the last message pointer */ pw_Tp = MilMalloc(pw_MilConf, sizeof(RTType)); if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); /* if it is alerady configured close RT */ if(pw_MilConf->pw_RT) MilRTClose(pw_MilConf); pw_MilConf->pw_RT = pw_Tp; /* MilPreset(pw_MilConf); */ /* create permanent stack pointer block */ /* permant block on until the message data block */ pw_Tphdl=CreateProtectedMemBlock(pw_MilConf, pw_MilConf->pw_AceMemory,0x0000,0x260); pw_Tphdl=pw_Tphdl->pw_Next; /* Illegalization table protection */ pw_Tphdl=CreateProtectedMemBlock(pw_MilConf, pw_Tphdl,0x0300,0x100); pw_Tphdl=pw_Tphdl->pw_Next; /* stack B protection */ CreateProtectedMemBlock(pw_MilConf, pw_Tphdl,0x0F00,0x100); return(MIL_SUCCESS); } /******************************************************************** * * MilRTClose - Close RT * * Description * Clear all the allocated structure * * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Mil Error * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTClose(MilConf_p pw_MilConf) { RTPtr pw_Tp; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT) return(MIL_ERROR_RTNOTOPENED); pw_Tp=pw_MilConf->pw_RT; MilFree(pw_MilConf, pw_Tp); pw_MilConf->pw_RT=NULL; MilPreset(pw_MilConf); MilClearBlockList(pw_MilConf); return(MIL_SUCCESS); } /******************************************************************** * * MilRTMsgOK - Check the block status of a received message * * Description * Checks the block status of a received message for and * returns true if receive message was good. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - message = a pointer to a message structure. * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: TRUE if a valid message was sent/received * * SEE ALSO: * * * INTERNAL * * */ unsigned char MilRTMsgOK(MilConf_p pw_MilConf, MsgType *pw_Message) { return(!((pw_Message->j_BlockStatus&0xDF00)^0x8000)); } /******************************************************************** * * MilRTReadMsg - Return a structure of type MsgType which contains * the four word descriptor * * Description * This routine will return a structure of type * MsgType which contains the four word descriptor * stack entry (block status word, time tag, data block * pointer, and command word) and the data associated * with the message. Note data words are only valid for * receive commands and mode commands * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - message = a pointer to a message structure. * - MessageNum = message number index off of stack or * LAST_MESSAGE for last processed msg. * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS:MIL_SUCCESS if a message was processed and returned. * message = message read * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTReadMsg( MilConf_p pw_MilConf, unsigned int j_MessageNum, MsgType *pw_Message ) { RTWords w_Tp1; unsigned int j_Boundary,j_Count,j_Count1,j_DataPtr; unsigned int j_StackPtr; RTWords w_Temp; unsigned int j_MM; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT) return(MIL_ERROR_RTNOTOPENED); /* check if last rcvd message is requested, if it is, load StackPtr * and set MessageNum to the global pointer to the last message. If * this global pointer is equal to the current stack pointer, then * the message has not completed; or if the stack pointer has * incremented to the next address and the SOM, start of message, bit * is set the message has also not completed; we return MIL_ERROR_NOMSG * in this case. */ if(j_MessageNum==LAST_MESSAGE) { j_StackPtr=(unsigned int)MilReadRam(pw_MilConf, STACK_POINTER_A); j_MessageNum=pw_MilConf->pw_RT->MilRTLastMsg; //if((j_MessageNum==j_StackPtr)||((j_StackPtr==((j_MessageNum+4)%256)) && // (MilReadRam(pw_MilConf,j_MessageNum)&0x4000))) if((j_MessageNum==j_StackPtr)||((j_StackPtr==((j_MessageNum+4)& 0x000000FF)) && (MilReadRam(pw_MilConf,j_MessageNum)&0x4000))) return(MIL_ERROR_RT_NOMSG); /* otherwise we increment the global message pointer and read * in the correct words for the message type */ //pw_MilConf->pw_RT->MilRTLastMsg=(j_MessageNum+4)%256; pw_MilConf->pw_RT->MilRTLastMsg=(j_MessageNum+4)& 0x000000FF; } pw_Message->j_BlockStatus = MilReadRam(pw_MilConf,j_MessageNum); pw_Message->j_TimeTag = MilReadRam(pw_MilConf, j_MessageNum+1); j_DataPtr = MilReadRam(pw_MilConf, j_MessageNum+2); w_Tp1.j_Word = pw_Message->j_CmdWord1 = MilReadRam(pw_MilConf, j_MessageNum+3); /* we first check to see if the message is mode code. if it * is we check to see if enhanced mode codes are enabled. * When enhanced is DISABLED the tx or rx data word is stored * in the associated data block. This is read from the DataPtr. * when enhanced is ENABLED the DataPtr read from the descriptor * stack is actually the data word that was tx or rx'd. */ if((w_Tp1.w_Cmd.b_SubAddr == 0)||(w_Tp1.w_Cmd.b_SubAddr==31)) { /*check if it is a mode code */ if(MilReadReg(pw_MilConf, CONFIG_3)&0x8000) pw_Message->aj_Data[0]=j_DataPtr; else pw_Message->aj_Data[0]= MilReadRam(pw_MilConf, j_DataPtr); pw_Message->d_WordCount = 1; } else {/* not mode code */ if(MilReadReg(pw_MilConf, CONFIG_2)&2) {/*enhanced mode*/ w_Temp.j_Word = MilReadRam(pw_MilConf, 0x01A0+w_Tp1.w_Cmd.b_SubAddr); w_Temp.w_Sacw = Word2Sacw(pw_MilConf,w_Temp.j_Word); /* check to see if command was a transmit) */ if(w_Tp1.w_Cmd.b_TR) j_MM = w_Temp.w_Sacw.TxMm; else { if((w_Tp1.w_Cmd.b_RTaddr!=0x1f)|~(MilReadReg(pw_MilConf, CONFIG_2)&1)) j_MM= w_Temp.w_Sacw.RxMm; else j_MM=w_Temp.w_Sacw.BcstMm; } j_Count=w_Tp1.w_Cmd.b_WordCount; /* convert word count = 0 to 32 */ if(!j_Count) j_Count=32; pw_Message->d_WordCount = j_Count; /* Upper Boundary of circular buffer */ j_Boundary= j_DataPtr|((1<<(j_MM+6))-1); /* Circular Buffer Mode Rollover occurs */ if(j_MM&&((j_DataPtr+ j_Count)>j_Boundary)) { j_Count1= j_Boundary- j_DataPtr+1; MilBlockRead(pw_MilConf,j_DataPtr,pw_Message->aj_Data, j_Count1); j_Boundary &= ~((1<<(j_MM+6))-1); /* Lower Boundary of circular buffer */ MilBlockRead(pw_MilConf, j_Boundary, &(pw_Message->aj_Data[j_Count1]), j_Count- j_Count1); } else { /* Single Message Mode or No Buffer Rollover */ MilBlockRead(pw_MilConf, j_DataPtr, pw_Message->aj_Data, j_Count); } } else { /* not Enhanced Rt Memory Management mode */ j_Count=w_Tp1.w_Cmd.b_WordCount; if(!j_Count) j_Count=32; /* convert word count = 0 to 32 */ MilBlockRead(pw_MilConf, j_DataPtr,pw_Message->aj_Data, j_Count); }/* handle for non-enhanced mode */ }/*handle for non-mode codes */ return(MIL_SUCCESS); } /******************************************************************** * * MilRTReadInactive - This routine will read the currently inactive * data buffer * * Description * This routine will read the currently inactive data buffer * use with the RT, receive double buffered mode. The sacw * is located, double buffering is disabled, the inactive area * is calculated by inverting bit 5 of the current data block * pointer, the data is copied from the inactive block, and * double buffering is enabled. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - PW_BlockHdl block handle to DOUBLE_MESSAGE block * - pw_Buffer pointer to a 32 word data buffer * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: TRUE if a valid message was sent/received * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTReadInactive( MilConf_p pw_MilConf, RTBlkHandle pw_BlockHdl, unsigned int *pw_Buffer ) { unsigned int j_t_r; unsigned int j_Sa; unsigned int j_SacwAddr; unsigned int j_BAddr; j_t_r= pw_BlockHdl->j_Gp & 0x0003; j_Sa= pw_BlockHdl->j_Gp >>2; j_SacwAddr=LOOKUP_A+96+j_Sa; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT) return(MIL_ERROR_RTNOTOPENED); MilWriteRam(pw_MilConf,j_SacwAddr,(MilReadRam(pw_MilConf, j_SacwAddr)&0x7fff)); /* shutoff dbl buf */ /* block address read is active */ j_BAddr = MilReadRam(pw_MilConf, LOOKUP_A+(32*(j_t_r!=0))+j_Sa); j_BAddr^=0x20; MilBlockRead(pw_MilConf, j_BAddr,pw_Buffer,32); MilWriteRam(pw_MilConf, j_SacwAddr,(MilReadRam(pw_MilConf, j_SacwAddr)|0x8000)); /*turnon dbl buf */ return(MIL_SUCCESS); } /******************************************************************** * * MilRTDefMsgLegal - Sets the legality to legal for messages * * Description * Sets the legality to legal for messages based * on the subaddress word count and transmit/receive bit * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - MessType transmit or receive message. * - wc word count. * - subaddress sub address to be made legal * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTDefMsgLegal( MilConf_p pw_MilConf, unsigned int j_MessType, unsigned int j_Subaddr, unsigned int j_Wc ) { unsigned int j_FirstMess,j_LastMess; unsigned int j_FirstSa,j_LastSa; unsigned int j_Offset,j_Mess,j_Sa; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT) return(MIL_ERROR_RTNOTOPENED); /* check for valid definition of parameters */ if((j_MessType>2)&&(j_MessType!=ALL)) return(MIL_ERROR_RTDEFMSGILLTYPE); if((j_Subaddr>31)&&(j_Subaddr!=ALL)) return(MIL_ERROR_RTDEFMSGILLSA); if(j_Wc==32) j_Wc=0; if((j_Wc>31)&&(j_Wc!=ALL)) return(MIL_ERROR_RTDEFMSGILLWC); if(j_MessType==ALL) { j_FirstMess=0; j_LastMess=2; } else { j_FirstMess=j_LastMess=j_MessType; } if(j_Subaddr==ALL) { j_FirstSa=0; j_LastSa=31; } else { j_FirstSa=j_LastSa=j_Subaddr; } for(j_Mess=j_FirstMess;j_Mess<(j_LastMess+1);j_Mess++) { for(j_Sa=j_FirstSa;j_Sa<(j_LastSa+1);j_Sa++) { j_Offset=0x0300+((j_Mess^02)<<6)+(j_Sa<<1); if(j_Wc==ALL) { MilWriteRam(pw_MilConf, j_Offset, 0x0000); MilWriteRam(pw_MilConf, j_Offset+1, 0x0000); } else { j_Offset += j_Wc>>4; MilWriteRam(pw_MilConf, j_Offset,MilReadRam(pw_MilConf, j_Offset)&(~(1<<(j_Wc&0x0f)))); } } } return(MIL_SUCCESS); } /******************************************************************** * * MilRTDefMsgIllegal - Sets the legality to illegal for messages * * Description * Sets the legality to illegal for messages based * on the subaddress word count and transmit/receive bit * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - MessType transmit or receive message. * - wc word count. * - subaddress sub address to be made legal * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTDefMsgIllegal( MilConf_p pw_MilConf, unsigned int j_MessType, unsigned int j_Subaddr, unsigned int j_Wc ) { unsigned int j_FirstMess,j_LastMess; unsigned int j_FirstSa,j_LastSa; unsigned int j_Offset,j_Mess,j_Sa; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf)return(MIL_ERROR_RTNOTOPENED); /* check for valid definition of parameters */ if((j_MessType>2)&&(j_MessType!=ALL)) return(MIL_ERROR_RTDEFMSGILLTYPE); if((j_Subaddr>31)&&(j_Subaddr!=ALL)) return(MIL_ERROR_RTDEFMSGILLSA); if(j_Wc==32) j_Wc=0; if((j_Wc>31)&&(j_Wc!=ALL)) return(MIL_ERROR_RTDEFMSGILLWC); if(j_MessType==ALL) { j_FirstMess=0; j_LastMess=2; } else { j_FirstMess=j_LastMess=j_MessType; } if(j_Subaddr==ALL) { j_FirstSa=0; j_LastSa=31; } else { j_FirstSa=j_LastSa=j_Subaddr; } for(j_Mess=j_FirstMess;j_Mess<(j_LastMess+1);j_Mess++) { for(j_Sa=j_FirstSa;j_Sa<(j_LastSa+1);j_Sa++) { j_Offset=0x0300+((j_Mess^02)<<6)+(j_Sa<<1); if(j_Wc==ALL) { MilWriteRam(pw_MilConf, j_Offset,0xffff); MilWriteRam(pw_MilConf, j_Offset+1,0xffff); } else { j_Offset+=j_Wc>>4; MilWriteRam(pw_MilConf, j_Offset+(j_Wc>>4),MilReadRam(pw_MilConf, j_Offset)|(01<<(j_Wc&0x0f))); } } } return(MIL_SUCCESS); } /******************************************************************** * * MilRTConfigureMemory - Configure the ACE memory * * Description * Configure ACE memory as defined by user * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTConfigMemory( MilConf_p pw_MilConf ) { unsigned int j_Index; RTBlkHandle pw_TxBlk, pw_RxBlk, pw_BcBlk; SubAddrCtrlWrd w_SubAddrConfig; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); /* define Memory Configuration */ /* warning: select the message type */ /* Sub-address 0 */ saw_ConfigDDCMem[0].j_Broadcast = SINGLE_MESSAGE; saw_ConfigDDCMem[0].j_Receive = NO_BUFFER; saw_ConfigDDCMem[0].j_Transmit = NO_BUFFER; /* Sub-address 1 */ saw_ConfigDDCMem[1].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[1].j_Receive = NO_BUFFER; saw_ConfigDDCMem[1].j_Transmit = NO_BUFFER; /* Sub-address 2 */ saw_ConfigDDCMem[2].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[2].j_Receive = NO_BUFFER; saw_ConfigDDCMem[2].j_Transmit = NO_BUFFER; /* Sub-address 3 */ saw_ConfigDDCMem[3].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[3].j_Receive = NO_BUFFER; saw_ConfigDDCMem[3].j_Transmit = NO_BUFFER; /* Sub-address 4 */ saw_ConfigDDCMem[4].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[4].j_Receive = NO_BUFFER; saw_ConfigDDCMem[4].j_Transmit = NO_BUFFER; /* Sub-address 5 */ saw_ConfigDDCMem[5].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[5].j_Receive = NO_BUFFER; saw_ConfigDDCMem[5].j_Transmit = NO_BUFFER; /* Sub-address 6 */ saw_ConfigDDCMem[6].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[6].j_Receive = NO_BUFFER; saw_ConfigDDCMem[6].j_Transmit = NO_BUFFER; /* Sub-address 7 */ saw_ConfigDDCMem[7].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[7].j_Receive = NO_BUFFER; saw_ConfigDDCMem[7].j_Transmit = NO_BUFFER; /* Sub-address 8 */ saw_ConfigDDCMem[8].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[8].j_Receive = NO_BUFFER; saw_ConfigDDCMem[8].j_Transmit = NO_BUFFER; /* Sub-address 9 */ saw_ConfigDDCMem[9].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[9].j_Receive = NO_BUFFER; saw_ConfigDDCMem[9].j_Transmit = NO_BUFFER; /* Sub-address 10 */ saw_ConfigDDCMem[10].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[10].j_Receive = SINGLE_MESSAGE; saw_ConfigDDCMem[10].j_Transmit = RTBUFFER128; /* Sub-address 11 */ saw_ConfigDDCMem[11].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[11].j_Receive = RTBUFFER128; saw_ConfigDDCMem[11].j_Transmit = RTBUFFER128; /* Sub-address 12 */ saw_ConfigDDCMem[12].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[12].j_Receive = RTBUFFER128; saw_ConfigDDCMem[12].j_Transmit = RTBUFFER128; /* Sub-address 13 */ saw_ConfigDDCMem[13].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[13].j_Receive = RTBUFFER128; saw_ConfigDDCMem[13].j_Transmit = RTBUFFER128; /* Sub-address 14 */ saw_ConfigDDCMem[14].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[14].j_Receive = RTBUFFER128; saw_ConfigDDCMem[14].j_Transmit = RTBUFFER128; /* Sub-address 15 */ saw_ConfigDDCMem[15].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[15].j_Receive = NO_BUFFER; saw_ConfigDDCMem[15].j_Transmit = RTBUFFER128; /* Sub-address 16 */ saw_ConfigDDCMem[16].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[16].j_Receive = NO_BUFFER; saw_ConfigDDCMem[16].j_Transmit = RTBUFFER128; /* Sub-address 17 */ saw_ConfigDDCMem[17].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[17].j_Receive = NO_BUFFER; saw_ConfigDDCMem[17].j_Transmit = RTBUFFER128; /* Sub-address 18 */ saw_ConfigDDCMem[18].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[18].j_Receive = NO_BUFFER; saw_ConfigDDCMem[18].j_Transmit = RTBUFFER128; /* Sub-address 19 */ saw_ConfigDDCMem[19].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[19].j_Receive = NO_BUFFER; saw_ConfigDDCMem[19].j_Transmit = RTBUFFER128; /* Sub-address 20 */ saw_ConfigDDCMem[20].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[20].j_Receive = NO_BUFFER; saw_ConfigDDCMem[20].j_Transmit = RTBUFFER128; /* Sub-address 21 */ saw_ConfigDDCMem[21].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[21].j_Receive = NO_BUFFER; saw_ConfigDDCMem[21].j_Transmit = RTBUFFER128; /* Sub-address 22 */ saw_ConfigDDCMem[22].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[22].j_Receive = NO_BUFFER; saw_ConfigDDCMem[22].j_Transmit = RTBUFFER128; /* Sub-address 23 */ saw_ConfigDDCMem[23].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[23].j_Receive = NO_BUFFER; saw_ConfigDDCMem[23].j_Transmit = RTBUFFER128; /* Sub-address 24 */ saw_ConfigDDCMem[24].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[24].j_Receive = NO_BUFFER; saw_ConfigDDCMem[24].j_Transmit = RTBUFFER128; /* Sub-address 25 */ saw_ConfigDDCMem[25].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[25].j_Receive = NO_BUFFER; saw_ConfigDDCMem[25].j_Transmit = RTBUFFER128; /* Sub-address 26 */ saw_ConfigDDCMem[26].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[26].j_Receive = NO_BUFFER; saw_ConfigDDCMem[26].j_Transmit = RTBUFFER128; /* Sub-address 27 */ saw_ConfigDDCMem[27].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[27].j_Receive = SINGLE_MESSAGE; saw_ConfigDDCMem[27].j_Transmit = RTBUFFER128; /* Sub-address 28 */ saw_ConfigDDCMem[28].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[28].j_Receive = NO_BUFFER; saw_ConfigDDCMem[28].j_Transmit = NO_BUFFER; /* Sub-address 29 */ saw_ConfigDDCMem[29].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[29].j_Receive = NO_BUFFER; saw_ConfigDDCMem[29].j_Transmit = NO_BUFFER; /* Sub-address 30 */ saw_ConfigDDCMem[30].j_Broadcast = NO_BUFFER; saw_ConfigDDCMem[30].j_Receive = NO_BUFFER; saw_ConfigDDCMem[30].j_Transmit = NO_BUFFER; /* Sub-address 31 */ saw_ConfigDDCMem[31].j_Broadcast = SINGLE_MESSAGE; saw_ConfigDDCMem[31].j_Receive = NO_BUFFER; saw_ConfigDDCMem[31].j_Transmit = NO_BUFFER; for (j_Index=0;j_Index< MIL_SA_MESSAGE;j_Index++) { /* define default subaddress control word */ w_SubAddrConfig.BcstEomInt = FALSE; w_SubAddrConfig.RxEomInt = FALSE; w_SubAddrConfig.TxEomInt = FALSE; w_SubAddrConfig.BcstBuffInt = FALSE; w_SubAddrConfig.RxBuffInt = FALSE; w_SubAddrConfig.TxBuffInt = FALSE; w_SubAddrConfig.RcvBufferType = SINGLEBUFFER; /* alloc single message */ if (saw_ConfigDDCMem[j_Index].j_Receive != NO_BUFFER) { pw_RxBlk = MilRTAllocBlk(pw_MilConf,saw_ConfigDDCMem[j_Index].j_Receive); w_SubAddrConfig.RxMm = saw_ConfigDDCMem[j_Index].j_Receive; MilRTCreateMsgStruct(pw_MilConf,&gbv_RxMessages[j_Index]); } else w_SubAddrConfig.RxMm = SINGLE_MESSAGE; if (saw_ConfigDDCMem[j_Index].j_Broadcast != NO_BUFFER) { pw_BcBlk = MilRTAllocBlk(pw_MilConf,saw_ConfigDDCMem[j_Index].j_Broadcast); w_SubAddrConfig.BcstMm = saw_ConfigDDCMem[j_Index].j_Broadcast; /* to be defined */ MilRTCreateMsgStruct(pw_MilConf,&gbv_RxMessages[j_Index]); } else w_SubAddrConfig.BcstMm = SINGLE_MESSAGE; if (saw_ConfigDDCMem[j_Index].j_Transmit != NO_BUFFER) { pw_TxBlk = MilRTAllocBlk(pw_MilConf,saw_ConfigDDCMem[j_Index].j_Transmit); w_SubAddrConfig.TxMm = saw_ConfigDDCMem[j_Index].j_Transmit; MilRTCreateMsgStruct(pw_MilConf,&gbv_TxMessages[j_Index]); } else w_SubAddrConfig.TxMm = SINGLE_MESSAGE; MilRTDefSA( pw_MilConf, j_Index, &w_SubAddrConfig); if (saw_ConfigDDCMem[j_Index].j_Receive != NO_BUFFER) MilRTMapBlk(pw_MilConf, j_Index,RECEIVE,pw_RxBlk,0); if (saw_ConfigDDCMem[j_Index].j_Transmit != NO_BUFFER) MilRTMapBlk(pw_MilConf, j_Index,TRANSMIT,pw_TxBlk,0); if (saw_ConfigDDCMem[j_Index].j_Broadcast != NO_BUFFER) MilRTMapBlk(pw_MilConf, j_Index,BROADCAST,pw_BcBlk,0); } MilBlockFill(pw_MilConf, ILLEGALIZATION_TABLE, 0x0000, 256); MilBlockFill(pw_MilConf, ENH_MODE_IRQ_TABLE, 0x0000, 8); MilRTEnhMM(pw_MilConf, TRUE); MilRTAltStatusEna(pw_MilConf, FALSE); MilRTFlagWrap(pw_MilConf, TRUE); /* no flags set in status */ MilRTSetBusy(pw_MilConf, FALSE); MilRTSetSSflag(pw_MilConf, FALSE); MilRTSetSvcReq(pw_MilConf, FALSE); MilRTFlag(pw_MilConf, FALSE); MilTimeout(pw_MilConf, RESPONSE_185); /* enhanced mode codes disabled * separate broadcast messages * clear external BIT word */ /* change as requested by IFSI */ MilRTEnhModeCode(pw_MilConf, TRUE); MilRTSeparateBcst(pw_MilConf, TRUE); MilWriteRam(pw_MilConf, RT_ENH_BIT_WORD_ADDR,0x0000); return MIL_SUCCESS; } /******************************************************************** * * MilRTAltStatusEna - Enables/Disables alternate status word capibility * * Description * Enables/Disables alternate status word capibility. The * alternate status word allows for direct control over the * bits in the rt status word * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 0 disable alternate status word * 1 enable alternate status word. * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTAltStatusEna( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_3,(MilReadReg(pw_MilConf, CONFIG_3)&0xffdf)|(j_Selection<<5))); } /******************************************************************** * * MilRTBusyTableEna - When the alternate RT status word is not selected * * Description * When the alternate RT status word is not selected, the * busy bit (in the rt status words) are controllable on a * subaddress basis. This routine enables the option. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 0 busy table disable * 1 busy table enable * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTBusyTableEna( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_2,(MilReadReg(pw_MilConf, CONFIG_2)&0xdfff)|(j_Selection<<13))); } /******************************************************************** * * MilRTExtBITWord - Allows selection of internal BIT word * * Description * Allows selection of internal BIT word (controlled by * the ACE not the host processor) or external BIT word * fully controlled by the host processor. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 0 internal bit word * 1 external bit word * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTExtBITWord( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_4,(MilReadReg(pw_MilConf, CONFIG_4)&0x7fff)|(j_Selection<<15))); } /******************************************************************** * * MilRTBitInhibit - Allows the transmission of the BUSY bit word * * Description * Allows the transmission of the BUSY bit word * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 0 internal bit word * 1 external bit word * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTBitInhibit( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_4,(MilReadReg(pw_MilConf, CONFIG_4)&0xbfff)|(j_Selection<<14))); } /******************************************************************** * * MilRTBrdcst - Enables/Disables the use of RT address 31 as a broadcast * address * * Description * Enables/Disables the use of RT address 31 as a broadcast * address * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 0 internal bit word * 1 external bit word * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTBrdcst( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_5,(MilReadReg(pw_MilConf, CONFIG_5)&0xff7f)|(j_Selection<<7))); } /******************************************************************** * * MilRTModeCode - Configures ACE for advanced mode codes * * Description * Configures ACE for advanced mode codes * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - Enhanced 0 cannot request irq, no advanced mapping * 1 can request irq, advanced mapping * - OverRideEnable 0 message error for T/R* of 0, and MSB 0 * 1 ACE will respond for T/R* of 0, and MSB 0 * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTModeCode( MilConf_p pw_MilConf, unsigned int j_Enhanced, unsigned int j_OverRideEnable) { return(MilWriteReg(pw_MilConf, CONFIG_3, ((MilReadReg(pw_MilConf, CONFIG_3)&0xffbe) |(j_Enhanced) |(j_OverRideEnable<<6)))); } /******************************************************************** * * MilRTAltStat - The bit controls whether the DBCA, Busy, ServReq, SubSysFlag, * and TerminalFlag RT status word bits are under control of the * host uP ONLY * * Description * The bit controls whether the DBCA, Busy, ServReq, SubSysFlag, * and TerminalFlag RT status word bits are under control of the * host uP ONLY, or all 11 bits are under control of the host * uP * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel = 0 only the DBCA, Busy, ServReq, SubSysFlag, * and TerminFlag bits are under control by the host uP * 1 all 11 RT status word bits are under control * of the host uP * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTAltStat( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_3,(MilReadReg(pw_MilConf, CONFIG_3)&0xffdf)|((j_Selection)<<5))); } /******************************************************************** * * MilRTMsgErrValid - Allows an RT response to a transmit command * * Description * Allows an RT response to a transmit command followed by * no data words, with the Message Error bit set to be * considered valid or invalid. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 1 valid response with ME bit/no data * 0 format error response with ME bit/no data * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTMsgErrValid( MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_4,(MilReadReg(pw_MilConf, CONFIG_4)&0xffbf)|(j_Selection<<6))); } /******************************************************************** * * MilRTBusyValid - This allows the response to a transmit command of the * status word * * Description * This allows the response to a transmit command of the * status word with the busy bit set followed by no data * words to be considered a valid response rather than a * format error. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 1 valid response with busy bit/no data * 0 format error response with busy bit/no data * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTBusyValid( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_4,(MilReadReg(pw_MilConf, CONFIG_4)&0xffdf)|(j_Selection<<5))); } /******************************************************************** * * MilRTBusyValid - Determines if the data from an illegal command is stored * to ram or discarded. * * Description * Determines if the data from an illegal command is stored * to ram or discarded. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 1 does not store data, 0 data is stored * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTIllegal( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_3,(MilReadReg(pw_MilConf, CONFIG_3)&0xffef)|(j_Selection<<4))); } /******************************************************************** * * MilRTFlagWrap - Determines wether the RTFLAG status bit is controlled by * the uP only, or the uP and error condition. * * Description * Determines wether the RTFLAG status bit is controlled by * the uP only, or the uP and error condition * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - sel 1 enable bit control from uP, xmit timeout, loop tst * 0 enable bit control from uP only * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTFlagWrap( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_3,(MilReadReg(pw_MilConf, CONFIG_3)&0xfffb)|(j_Selection<<2))); } /******************************************************************** * * MilRTFlag - Controls the Terminal Flag bit in status word. * * Description * Controls the Terminal Flag bit in status word. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - d_Selection 1 set flag, 0 reset flag * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTFlag( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_1,(MilReadReg(pw_MilConf, CONFIG_1)&0xFF7F)|((!j_Selection)<<7))); } /******************************************************************** * * MilRTSetSSFlag - Controls the subsystem request flag in status * word * * Description * Controls the subsytem request flag in status words. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 set flag, 0 reset flag * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTSetSSflag( MilConf_p pw_MilConf, unsigned int j_Selection ) { return(MilWriteReg(pw_MilConf, CONFIG_1,(MilReadReg(pw_MilConf, CONFIG_1)&0xFEFF)|((!j_Selection)<<8))); } /******************************************************************** * * MilRTSetSvcReq - Controls the service request bit in status word . * * Description * Controls the service request bit in status words * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 set flag, 0 reset flag * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTSetSvcReq(MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_1,(MilReadReg(pw_MilConf, CONFIG_1)&0xFDFF)|((!j_Selection)<<9))); } /******************************************************************** * * MilRTSetBusy - Controls the busy bit in the status words * * Description * Controls the busy bit in the status words * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 set flag, 0 reset flag * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTSetBusy(MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_1,(MilReadReg(pw_MilConf, CONFIG_1)&0xFBFF)|((!j_Selection)<<10))); } /******************************************************************** * * MilRTSetDba - Controls the DBA bit in the status words. * * Description * Controls the DBA bit in the status words. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 set flag, 0 reset flag * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTSetDba(MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_1,(MilReadReg(pw_MilConf, CONFIG_1)&0xF7FF)|((!j_Selection)<<11))); } /******************************************************************** * * MilRTEnhMN - Controls RT mode enhanced memory management * * Description * Controls RT mode enhanced memory management * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 enhanced, 0 standard * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTEnhMM(MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_2,(MilReadReg(pw_MilConf, CONFIG_2)&0xFFFD)|((j_Selection)<<1))); } /******************************************************************** * * MilRTEnhModeCode - Enhanced mode code handling enable. * * Description * Enhanced mode code handling enable. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 enhanced, 0 standard * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTEnhModeCode(MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_3,(MilReadReg(pw_MilConf, CONFIG_3)&0xFFFE)|(j_Selection))); } /******************************************************************** * * MilRTSeparateBcst - Separates Bcst Rx, Tx data (including mode codes) * * Description * Separates Bcst Rx, Tx data (including mode codes) to * a separate lookup table and data blocks. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Selection 1 separate, 0 DOES NOT separate * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTSeparateBcst(MilConf_p pw_MilConf, unsigned int j_Selection) { return(MilWriteReg(pw_MilConf, CONFIG_2,(MilReadReg(pw_MilConf, CONFIG_2)&0xFFFE)|(j_Selection))); } /******************************************************************** * * MilRTReadEnhMCData - When in enhanced mode, the ACE has separate data locations for mode codes * * Description * When in enhanced mode, the ACE has separate data locations * for mode codes. These data locations (from 110h-13fh) can * be read with this routine. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Addr = address of mode code * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: mode code data word * * SEE ALSO: * * * INTERNAL * * */ unsigned int MilRTReadEnhMCData(MilConf_p pw_MilConf, unsigned int j_Addr) { if((j_Addr<0x110)||(j_Addr>0x13f))return(0); else return(MilReadRam(pw_MilConf, j_Addr)); } /******************************************************************** * * MilRTWriteEnhMCData - When in enhanced mode, the ACE has separate data locations * for mode codes * * Description * When in enhanced mode, the ACE has separate data locations * for mode codes. These data locations (from 110h-13fh) can * be written to with this routine. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Addr = address of mode code * - j_Data = mode code data to write * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTWriteEnhMCData(MilConf_p pw_MilConf, unsigned int j_Addr, unsigned int j_Data) { if((j_AddrENH_MODE_TABLE_END)) return(MIL_ERROR_INVALIDMODECODE); else return(MilWriteRam(pw_MilConf, j_Addr, j_Data)); } /******************************************************************** * * MilRTModeIrqEnable - This routine will enable selected mode code interrupts * * Description * This routine will enable selected mode code interrupts * when enhanced mode codes are enabled. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Broadcast = is this a broadcast mode code? boolean * - d_t_r = is this a transmit or recieve code? 0=RX * - d_Data = is there a data word involved? 0=No * - j_Map = bitmap that will be set in table * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTModeIrqEnable( MilConf_p pw_MilConf, unsigned int j_Broadcast, unsigned char d_t_r, unsigned char d_Data, unsigned int j_Map) { unsigned int j_Addr; j_Addr=(ENH_MODE_IRQ_TABLE|(j_Broadcast<<2)|(d_t_r<<1)|d_Data); return(MilWriteRam(pw_MilConf, j_Addr,MilReadRam(pw_MilConf, j_Addr)| j_Map)); } /******************************************************************** * * MilRTModeIrqDisable - This routine will disable selected mode code interrupts * * Description * This routine will disable selected mode code interrupts * when enhanced mode codes are enabled. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Broadcast = is this a broadcast mode code? boolean * - d_t_r = is this a transmit or recieve code? 0=RX * - d_Data = is there a data word involved? 0=No * - j_Map = bitmap that will be set in table * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTModeIrqDisable( MilConf_p pw_MilConf, unsigned char d_Broadcast, unsigned char d_t_r, unsigned char d_Data, unsigned int j_Map) { unsigned int j_Addr; j_Addr=(ENH_MODE_IRQ_TABLE|(d_Broadcast<<2)|(d_t_r<<1)|d_Data); return(MilWriteRam(pw_MilConf, j_Addr,MilReadRam(pw_MilConf, j_Addr)&(~j_Map))); } /******************************************************************** * * MilRTExtBITWrite - If the ACE has Enhanced Mode Code Handling enabled and * External BIT word enabled * * Description * If the ACE has Enhanced Mode Code Handling enabled and * External BIT word enabled, the BIT word is programmed * using this routine. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Map = BIT word to be written * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTExtBITWrite( MilConf_p pw_MilConf, unsigned int j_Map) { if((MilReadReg(pw_MilConf, CONFIG_3)&1)&&(MilReadReg(pw_MilConf, CONFIG_4)&0x8000)) return(MilWriteRam(pw_MilConf, RT_ENH_BIT_WORD_ADDR,j_Map)); else return(MIL_ERROR_ENHANCEDMODEOFF); } /******************************************************************** * * MilRTBITRead - Reads the BIT word * * Description * Reads the BIT word (internal or external is don't care since * we read from register 0Fh) * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: BIT word * * SEE ALSO: * * * INTERNAL * * */ unsigned int MilRTBITRead(MilConf_p pw_MilConf) { return(MilReadReg(pw_MilConf, RT_BIT_WORD)); } /******************************************************************** * * MilRTBusyBitEnable - If ALTERNATE RT STATUS word is disabled, the Busy Bit can * be SET on a broadcast/t_r basis with this function. * * Description * If ALTERNATE RT STATUS word is disabled, the Busy Bit can * be SET on a broadcast/t_r basis with this function. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - d_Broadcast = broadcast command? boolean * - d_t_r = transmit or recieve command? 0=RX * - d_Sa = subaddress that is busy * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTBusyBitEnable( MilConf_p pw_MilConf, unsigned char d_Broadcast, unsigned char d_t_r, unsigned char d_Sa) { unsigned int j_Addr; j_Addr=(ENH_SA_BUSY_TABLE|(d_Broadcast<<2)|(d_t_r<<1)|((d_Sa&0x10)?1:0)); return(MilWriteRam(pw_MilConf, j_Addr,(1<d_Size = MIL_NUM_MESSAGE_SIZE; /* alloc the memory */ pw_PntTmp = malloc(bw_VectorMsg->d_Size * sizeof(RxMsgPointerType)); /* assign the pointer */ bw_VectorMsg->pm_InitMsg = pw_PntTmp; bw_VectorMsg->pm_CurrWriteMsg = pw_PntTmp; /* save the pointer */ pw_PntCurr = pw_PntTmp; /* initiliaze the memory space */ for (j_Index = 0; j_Index < bw_VectorMsg->d_Size; j_Index++) { /* initialize the structure */ pw_PntCurr->j_Words = 0; pw_PntCurr->d_MsgStatus = MIL_MSG_FREE; pw_PntCurr->pm_Msg = 0; pw_PntCurr++; } return MIL_SUCCESS; }/* end procedure*/ /******************************************************************** * * MilRTDeleteMsgStruct - Deletes the message pointers * * Description * Deletes the message pointers * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * -.bw_VectorMsg pointer to the structure * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTDeleteMsgStruct( MilConf_p pw_MilConf, RxMsgPointerStructType *bw_VectorMsg ) { /* local */ unsigned int j_Index; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf)return(MIL_ERROR_RTNOTOPENED); /* free the allocated memory */ for (j_Index = 0; j_Index < MIL_SA_MESSAGE; j_Index++) { /* is it a NULL pointer */ if (bw_VectorMsg->pm_InitMsg != NULL) free(bw_VectorMsg->pm_InitMsg); bw_VectorMsg++; } return MIL_SUCCESS; }/*end procedure */ /******************************************************************** * * MilRTCreateFrame - Create Frame Message * * Description * the function will create a pointer to a frame message * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pw_FrameID FrameIdentifier * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: Pointer to the Frame * * SEE ALSO: * * * INTERNAL * * */ FrameType *MilRTCreateFrame( MilConf_p pw_MilConf ) { /* local var */ FrameType *pw_FrameID; /* checks Mil structure */ if (pw_MilConf == NULL) return NULL; pw_FrameID = malloc(sizeof(FrameType)); /* initilize field */ pw_FrameID->pw_InitFrame = NULL; pw_FrameID->d_FrameStatus = MIL_FRAME_CREATION_SUCCESS; /* return the pointer */ return pw_FrameID; } /******************************************************************** * * MilRTAddMsgtoFrame - Adds a 1553 message to a frame * * Description * Adds a 1553 single message to a created frame * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pw_FrameID FrameIdentifier * - j_Sa Subaddress * - d_t_r transmit, receive * - j_WordCount number of word * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTAddMsgtoFrame( MilConf_p pw_MilConf, FrameType *pw_FrameID, unsigned int j_Sa, unsigned char d_t_r, unsigned int j_Words ) { /* local var */ FrameElementType *pw_FrameElTmp, *pw_FrameElCurr; RTWords w_Temp; unsigned int j_MM, j_TxLookPnt; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); pw_FrameElTmp = malloc(sizeof(FrameElementType)); /* initilize the pointer */ pw_FrameElCurr = pw_FrameID->pw_InitFrame; /* if it is the first element in the list */ if (pw_FrameElCurr == NULL) { /* link the element */ pw_FrameID->pw_InitFrame = pw_FrameElTmp; pw_FrameElTmp->pw_NextFrameElement = NULL; } else { /* scroll the list */ while (pw_FrameElCurr->pw_NextFrameElement != NULL) pw_FrameElCurr=pw_FrameElCurr->pw_NextFrameElement; /* link the message */ pw_FrameElCurr->pw_NextFrameElement = pw_FrameElTmp; pw_FrameElTmp->pw_NextFrameElement = NULL; } if (d_t_r == TRANSMIT) { if (j_Sa < MIL_SA_MESSAGE) { /* is the message defined */ if (gbv_TxMessages[j_Sa].pm_InitMsg != NULL) { pw_FrameElTmp->pw_CurrMsg = gbv_TxMessages[j_Sa].pm_InitMsg; pw_FrameElTmp->pw_InitMsg = gbv_TxMessages[j_Sa].pm_InitMsg; /* read the look table and assign the write pointer*/ j_TxLookPnt = MilReadRam(pw_MilConf, LOOK_UP_TABLE_TX_MSG+j_Sa); /* store the value in write pointer */ pw_FrameElTmp->pm_WriteMsg = j_TxLookPnt & 0X0000FFFF; /* set the number of words in transmission */ pw_FrameElTmp->j_Words = j_Words; /* set the subaddress */ pw_FrameElTmp->j_Sa = j_Sa; /* read the memory management setting*/ w_Temp.j_Word = MilReadRam(pw_MilConf, LOOK_UP_TABLE_SACW + j_Sa); w_Temp.w_Sacw = Word2Sacw(pw_MilConf,w_Temp.j_Word); j_MM = w_Temp.w_Sacw.TxMm; pw_FrameElTmp->j_MemMng = 1 <<(j_MM+6); } else return MIL_ERROR_SUBADDRES_MSG_NOT_DEFINED; } else return MIL_ERROR_SA_OVERFLOW; } else { if (d_t_r == RECEIVE) { if (j_Sa < MIL_SA_MESSAGE) { /* is the message defined */ if (gbv_RxMessages[j_Sa].pm_InitMsg != NULL) { pw_FrameElTmp->pw_CurrMsg = gbv_RxMessages[j_Sa].pm_InitMsg; pw_FrameElTmp->pw_InitMsg = gbv_RxMessages[j_Sa].pm_InitMsg; /* set the subaddress */ pw_FrameElTmp->j_Sa = j_Sa; /* set the number of words in transmission */ pw_FrameElTmp->j_Words = j_Words; /* read the memory management setting*/ w_Temp.j_Word = MilReadRam(pw_MilConf, LOOK_UP_TABLE_SACW + j_Sa); w_Temp.w_Sacw = Word2Sacw(pw_MilConf,w_Temp.j_Word); j_MM = w_Temp.w_Sacw.RxMm; pw_FrameElTmp->j_MemMng = 1 <<(j_MM+6); } } else return MIL_ERROR_SA_OVERFLOW; } else return MIL_ERROR_TX_RX_BAD_DEFINED; } return MIL_SUCCESS; } /******************************************************************** * * MilRTDeleteFrame - Deletes a 1553 frame * * Description * Deletes a 1553 single frame * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pw_FrameID FrameIdentifier * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTDeleteFrame( MilConf_p pw_MilConf, FrameType *pw_FrameID ) { /* local var */ FrameElementType *pw_FrameElCurr, *pw_FrameElTmp; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); if (pw_FrameID == NULL) return MIL_ERROR_FRAME_NOT_DEFINED; if (pw_FrameID->pw_InitFrame == NULL) { free(pw_FrameID); return MIL_ERROR_FRAME_NOT_DEFINED; } /*save start pointer */ pw_FrameElTmp = pw_FrameElCurr = pw_FrameID->pw_InitFrame; while (pw_FrameID->pw_InitFrame->pw_NextFrameElement != NULL) { pw_FrameElCurr = pw_FrameID->pw_InitFrame->pw_NextFrameElement; pw_FrameElTmp = pw_FrameElCurr->pw_NextFrameElement; while (pw_FrameElTmp->pw_NextFrameElement != NULL) { pw_FrameElCurr = pw_FrameElTmp; pw_FrameElTmp = pw_FrameElTmp->pw_NextFrameElement; } free(pw_FrameElTmp); pw_FrameElCurr->pw_NextFrameElement = NULL; } free(pw_FrameID->pw_InitFrame); free(pw_FrameID); return MIL_SUCCESS; } /******************************************************************** * * MilRTFrameRead - reads a frame message * * Description * Reads sequentially the messages in the frame * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pw_FrameID FrameIdentifier * - pj_Buffer buffer pointer * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTFrameRead( MilConf_p pw_MilConf, FrameType *pw_FrameID, unsigned int *pj_Buffer ) { /* local var */ FrameElementType *pw_FrameElCurr; unsigned int j_WordsCount, j_Boundary, j_DataPtr, j_Count1; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); /* read frame */ pw_FrameElCurr = pw_FrameID->pw_InitFrame; /* reset the number of words */ pw_FrameID->j_PacketLenght = 0; /* reset status report message */ pw_FrameID->d_FrameStatus = MIL_SUCCESS_FRAME_READ; while (pw_FrameElCurr != NULL) { if (pw_FrameElCurr->pw_CurrMsg->d_MsgStatus == MIL_MSG_FREE) { /* message not ready */ pw_FrameID->d_FrameStatus = MIL_FRAME_NOT_READY; return pw_FrameID->d_FrameStatus; } else { if (pw_FrameElCurr->pw_CurrMsg->d_MsgStatus == MIL_MSG_READY) { /* save the word count */ j_WordsCount = pw_FrameElCurr->pw_CurrMsg->j_Words; if (j_WordsCount != 0) { /* word count update */ pw_FrameID->j_PacketLenght += j_WordsCount; /* extract pointer */ j_DataPtr = 0x0000FFFF & pw_FrameElCurr->pw_CurrMsg->pm_Msg; /* Compute the upper Boundary of circular buffer */ j_Boundary= ( j_DataPtr | (pw_FrameElCurr->j_MemMng - 1)); if ((j_DataPtr + j_WordsCount)>j_Boundary) { j_Count1= j_Boundary - j_DataPtr + 1; MilBlockRead(pw_MilConf,j_DataPtr, pj_Buffer, j_Count1); /* Lower Boundary of circular buffer */ j_Boundary &= ~(pw_FrameElCurr->j_MemMng -1); MilBlockRead(pw_MilConf, j_Boundary, pj_Buffer + j_Count1, j_WordsCount - j_Count1); } else { /* Single Message Mode or No Buffer Rollover */ MilBlockRead(pw_MilConf, j_DataPtr, pj_Buffer, j_WordsCount); } /* update buffer */ pj_Buffer = pj_Buffer + j_WordsCount; /* set MIL message free */ pw_FrameElCurr->pw_CurrMsg->d_MsgStatus = MIL_MSG_FREE; } } else { if (pw_FrameElCurr->pw_CurrMsg->d_MsgStatus == MIL_MSG_FAILED) pw_FrameID->d_FrameStatus = MIL_FRAME_READ_FAILED; else pw_FrameID->d_FrameStatus = MIL_FRAME_BAD_SETTING; } /* increment message */ pw_FrameElCurr->pw_CurrMsg++; /* checks the array boundary */ if (pw_FrameElCurr->pw_CurrMsg >= (pw_FrameElCurr->pw_InitMsg + MIL_NUM_MESSAGE_SIZE)) pw_FrameElCurr->pw_CurrMsg = pw_FrameElCurr->pw_InitMsg; } /* pointer to the next element */ pw_FrameElCurr = pw_FrameElCurr->pw_NextFrameElement; } return pw_FrameID->d_FrameStatus; } /******************************************************************** * * MilRTFrameWrite - writes a frame message * * Description * writes the data from the Buffer in the in the frame * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pw_FrameID FrameIdentifier * - pj_Buffer buffer pointer * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTFrameWrite( MilConf_p pw_MilConf, FrameType *pw_FrameID, unsigned int *pj_Buffer ) { /* local var */ FrameElementType *pw_FrameElCurr; unsigned int j_WordsCount,j_MM, j_DataPtr, j_Boundary; unsigned int j_Count1; if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); /* read frame */ pw_FrameElCurr = pw_FrameID->pw_InitFrame; /* reset the number of words */ pw_FrameID->j_PacketLenght = 0; /* reset status report message */ pw_FrameID->d_FrameStatus = MIL_FRAME_WRITE_SUCCESS; while (pw_FrameElCurr !=NULL) { /* save the number of words */ j_WordsCount = pw_FrameElCurr->j_Words; if (j_WordsCount != 0) { /* reads the buffer dimension */ j_MM = pw_FrameElCurr->j_MemMng; /* extract pointer */ j_DataPtr = pw_FrameElCurr->pm_WriteMsg; /* Compute the upper Boundary of circular buffer */ j_Boundary= ( j_DataPtr | (pw_FrameElCurr->j_MemMng - 1)); if ((j_DataPtr + j_WordsCount)>j_Boundary) { j_Count1= j_Boundary - j_DataPtr + 1; MilBlockWrite(pw_MilConf,j_DataPtr, pj_Buffer, j_Count1); /* Lower Boundary of circular buffer */ j_Boundary &= ~(pw_FrameElCurr->j_MemMng -1); MilBlockWrite(pw_MilConf, j_Boundary, pj_Buffer + j_Count1, j_WordsCount - j_Count1); pw_FrameElCurr->pm_WriteMsg = j_Boundary + j_WordsCount - j_Count1; } else { /* Single Message Mode or No Buffer Rollover */ MilBlockWrite(pw_MilConf, j_DataPtr, pj_Buffer, j_WordsCount); pw_FrameElCurr->pm_WriteMsg += j_WordsCount; } /* update buffer */ pj_Buffer = pj_Buffer + j_WordsCount; } /* pointer update */ pw_FrameElCurr = pw_FrameElCurr->pw_NextFrameElement; }/* end while */ return pw_FrameID->d_FrameStatus; } /******************************************************************** * * MilRTCreateSingleMsg - Creates a single standard message * * * Description * Creates the single standard message * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Sa Subaddress * - d_t_r transmit, receive * - j_WordCount number of word * * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTCreateSingleMsg(MilConf_p pw_MilConf, unsigned int j_Sa, unsigned char d_t_r, unsigned int j_Words) { /* local var */ if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); /* initilize field */ if (d_t_r == TRANSMIT) { if (spw_TxFrameID[j_Sa].pw_InitFrame != NULL) return MIL_ERROR_MSG_ALREADY_DEFINED; return MilRTAddMsgtoFrame(pw_MilConf,&spw_TxFrameID[j_Sa],j_Sa,TRANSMIT,j_Words); } else { if (d_t_r == RECEIVE) { if (spw_RxFrameID[j_Sa].pw_InitFrame != NULL) return MIL_ERROR_MSG_ALREADY_DEFINED; return MilRTAddMsgtoFrame(pw_MilConf,&spw_RxFrameID[j_Sa],j_Sa,RECEIVE,j_Words); } else return MIL_ERROR_TX_RX_BAD_DEFINED; } } /******************************************************************** * * MilRTDeleteSingleMsg - Deletes a single standard message * * * Description * Deletes the single standard message * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - j_Sa Subaddress * - d_t_r transmit, receive * * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTDeleteSingleMsg(MilConf_p pw_MilConf, unsigned int j_Sa, unsigned char d_t_r) { /* local var */ if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); /* initilize field */ if (d_t_r == TRANSMIT) { if (spw_TxFrameID[j_Sa].pw_InitFrame == NULL) return MIL_ERROR_MSG_NOT_DEFINED; free(spw_TxFrameID[j_Sa].pw_InitFrame); return MIL_SUCCESS; } else { if (d_t_r == RECEIVE) { if (spw_RxFrameID[j_Sa].pw_InitFrame == NULL) return MIL_ERROR_MSG_NOT_DEFINED; free(spw_RxFrameID[j_Sa].pw_InitFrame); return MIL_SUCCESS; } else return MIL_ERROR_TX_RX_BAD_DEFINED; } } /******************************************************************** * * MilRTReadSingleMsg - reads a single standard message Transmit, * receive or boradcast or mode code * * Description * reads a single standard message and writes it in the buffer * the message can be transmit, receive broadcast. * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pj_Buffer pointer to a buffer * - j_Sa Subaddress * - j_WordCount number of word * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTReadSingleMsg( MilConf_p pw_MilConf, unsigned int *pj_Buffer, unsigned int j_Sa, unsigned int j_WordCount ) { /* local var */ if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); if (spw_RxFrameID[j_Sa].pw_InitFrame == NULL) return MIL_ERROR_MSG_NOT_DEFINED; else { if (j_WordCount != spw_RxFrameID[j_Sa].pw_InitFrame->pw_CurrMsg->j_Words) return MIL_ERROR_BAD_NUMBER_OF_WORDS; return MilRTFrameRead(pw_MilConf,&spw_RxFrameID[j_Sa],pj_Buffer); } } /******************************************************************** * * MilRTWriteSingleMsg - writes a single standard message Transmit, * receive or boradcast * * Description * Writes a single standard message from the data buffer in MIL * internal RAM ready for the Bus Controller * * ARGUMENTS * Input Parameters * - pw_MilConf Mil1553 management structure * - pj_Buffer pointer to a buffer * - j_Sa Subaddress * - j_WordCount number of word * * Output Parameters * N/A * * Global Variables * N/A * * RETURNS: error condition * * SEE ALSO: * * * INTERNAL * * */ MilError_t MilRTWriteSingleMsg( MilConf_p pw_MilConf, unsigned int *pj_Buffer, unsigned int j_Sa, unsigned int j_WordCount ) { /* local var */ if(!pw_MilConf) return(MIL_ERROR_NOTCONFIGURED); if(!pw_MilConf->pw_RT)return(MIL_ERROR_RTNOTOPENED); if (spw_TxFrameID[j_Sa].pw_InitFrame == NULL) return MIL_ERROR_MSG_NOT_DEFINED; else { spw_TxFrameID[j_Sa].pw_InitFrame->j_Words = j_WordCount; return MilRTFrameWrite(pw_MilConf,&spw_TxFrameID[j_Sa],pj_Buffer); } } /* end of file */ // ---------------------------------------------------------------------------// /* modification history -------------------- $Log: MilRt.c,v $ Revision 1.10 2006/10/20 09:22:14 lorenzo 1553 library updated Revision 1.7 2006/06/07 11:44:55 scige Some More Comment by Scige John Liu IFSI Revision 1.6 2006/02/15 14:56:57 scige Abstract comment reformatted History log replaced or moved at end of file modification history -------------------- $Log: MilRt.c,v $ Revision 1.10 2006/10/20 09:22:14 lorenzo 1553 library updated Revision 1.7 2006/06/07 11:44:55 scige Some More Comment by Scige John Liu IFSI Revision 1.6 2006/02/15 14:56:57 scige Abstract comment reformatted History log replaced or moved at end of file Revision 1.5 2006/02/15 14:34:03 scige Some more comments restored Revision 1.3 2005/09/16 13:09:39 scige *** empty log message *** Revision 1.1 2005/08/10 12:53:39 scige Communication Library: 1553 com1553 Base Common Version of Spire/Pacs OBS Revision 1.1.4.3 2005/08/04 12:49:26 scige nincpy Revision 1.1.2.1 2005/08/04 08:55:09 scige status: - empty LIB1553 directory - milmemcpy --> nincpy - memcpy --> nincpy no optimization Revision 1.1.1.1 2002/07/11 13:23:01 giovanni no message Revision 1.14 2002/02/06 10:49:47 fabrizio MilWriteFrame and MilReadFrame has been correted Revision 1.13 2002/01/24 11:08:47 andrea The MilRtOpen procedure has been modified, the Protected area size has changed from 0xFF to 0x100 Revision 1.10 2002/01/15 18:06:49 andrea defined new message SA 27 Revision 1.9 2002/01/15 13:08:50 andrea defined the Tx message at subaddress 10 Revision 1.8 2001/12/13 10:31:22 andrea inserted filtering on Data Pointer in MilRTFrameRead function Revision 1.7 2001/12/13 08:54:44 andrea single message functions revision Revision 1.6 2001/12/12 15:55:28 andrea Create Single message procedure revision Revision 1.5 2001/12/12 08:14:43 andrea no message Revision 1.4 2001/12/10 16:39:06 andrea revision of the Add frame messanger Revision 1.3 2001/12/06 18:13:01 andrea single message function revision Memory configuration function update Revision 1.2 2001/11/14 18:48:31 andrea Mil frame message functions inserted */