⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtset.c

📁 实现vxworks下的1553b通讯功能
💻 C
📖 第 1 页 / 共 2 页
字号:
		 exc_summit->illegal[index] = wForceWordWrite;
    }
    else
    {

	     wForceWordWrite = exc_summit->illegal[index] | (usint)(1 << bit_position);
		 exc_summit->illegal[index] = wForceWordWrite;
    }
    return (0);
} /* end Set_Legal_Command */


int borland_dll Enable_Subaddr_Int (unsigned short subaddr, short txorrx, short msgtype, short inttype)
{
    unsigned short offset, intbit;

    if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
         return (emode);
    if (subaddr > 31)
         return (einval);
    if ((txorrx != TRANSMIT) && (txorrx != RECEIVE))
         return (einval);
    if ((msgtype != MODECODE) && (msgtype != STANDARD))
         return (einval);
    if ((inttype != ACCESS) && (inttype != BROADCAST))
         return (einval);

    offset = subaddr;
    if (msgtype == MODECODE)
         offset += (unsigned short)64;
    if (txorrx == TRANSMIT)
         offset += (unsigned short)32;
    if (inttype == BROADCAST)
         intbit = 0x20;
    else
         intbit = 0x40;
    exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) ] |= intbit;
    return (0);
} /* end Enable_Subaddr_Int */


int borland_dll Disable_Subaddr_Int (unsigned short subaddr, short txorrx, short msgtype, short inttype)
{
    unsigned short offset, intbit;

    if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
         return (emode);
    if (subaddr > 31)
         return (einval);
    if ((txorrx != TRANSMIT) && (txorrx != RECEIVE))
         return (einval);
    if ((msgtype != MODECODE) && (msgtype != STANDARD))
         return (einval);
    if ((inttype != ACCESS) && (inttype != BROADCAST))
         return (einval);

    offset = subaddr;
    if (msgtype == MODECODE)
         offset +=(unsigned short) 64;
    if (txorrx == TRANSMIT)
         offset += (unsigned short)32;
    if (inttype == BROADCAST)
         intbit = 0x20;
    else
         intbit = 0x40;
    exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) ] &=(unsigned short) ~intbit;
    return (0);
} /* end Disable_Subaddr_Int */


/* **********************************************************************
*
* Function: Datablk_Accessed (in module RTSET.C)
*
* Inputs:
*          subaddr - the selected subaddress of the RT
*          txorrx  - flag, indicates we are looking for a
*                    Transmit or Receive msg
*          msgtype - either MODE or STANDARD
*          inttype - interrupt type, to allow interrupt on any ACCESS or only
*                    on BROADCAST
*
* Outputs: none
* Returns: 1 if datablock has been accessed (ie, completion of
*               message processing)
*          0 otherwise
*
*
* Check the Block Accessed bit in the area of memory assigned to the
* selected subaddress for the RT. If the Block Accessed (BAC) bit in
* the Receive Control Word is set to 1, this indicates that the block
* has been accessed (ie, completion of message processing, either of
* a Transmit or a Receive message). Reset the bit to 0, and set the return
* value to indicate accessed. If the BAC bit is set to 0, this indicates
* that no message has completed processing since this bit was last checked.
*
   ********************************************************************** */

int borland_dll Datablk_Accessed(unsigned short subaddr, short txorrx, short msgtype, short inttype)
{
    unsigned short temp;
    unsigned short offset;
    int accessed;
    short BAC_Bit = 0x10;

    if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
         return (emode);
    if (subaddr > 31)
         return (einval);
    if ((txorrx != TRANSMIT) && (txorrx != RECEIVE))
         return (einval);
    if ((msgtype != MODECODE) && (msgtype != STANDARD))
         return (einval);
    if ((inttype != ACCESS) && (inttype != BROADCAST))
         return (einval);

    offset = subaddr;
    if (msgtype == MODECODE)
         offset +=(unsigned short) 64;
    if (txorrx == TRANSMIT)
         offset +=(unsigned short) 32;

    temp = exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) ];
    if ((temp & BAC_Bit) == BAC_Bit)
    {
        accessed = 1;
        exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) ] &=(unsigned short) ~BAC_Bit;
    }
    else
        accessed = 0;

    return (accessed);
} /* end Disable_Subaddr_Int */

/*CR1*/
int borland_dll Load_Buffer (usint buffernum, usint *data)
{
	usint dataind,  buffindex, maxdata=32;

	if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
		return (emode);
	if (gMultiBuf == 1)
		return (emode);
	if (buffernum > MAXBUFFERS)
		return einval;

	buffindex = (buffernum * MCH_BUFSIZE)+2; /* 2: put data after info wd and ttag */

	for (dataind=0; dataind < maxdata; dataind++)
		exc_summit_int[buffindex++] = data[dataind];


	return(0);
}
/*CR1*/
int borland_dll Assign_Buffer(usint subaddr, usint buffernum)
{
	int idx;
	if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
		return (emode);
	if (gMultiBuf == 1)
		return (emode);
	if (buffernum > MAXBUFFERS)
		return einval;

	idx = INIT_RT_DSCRPT + ((32+subaddr) * DESCRIPTORSIZE) ;

/*  	exc_summit_int[ idx + 1] = BANK1_OFFSET + (buffernum *BUFSIZE);*/
  	exc_summit_int[ idx + 1] = (buffernum * MCH_BUFSIZE);

	return 0;
}
/* **********************************************************************
*
* Function: Setup_Multibuffer
*
* Inputs:
*          subaddr - the selected subaddress of the RT
*          numbufs - the number of multibuffers to asociate with the subaddress
*          startaddr - the word address of the beginning of the data buffer
*
* Outputs: none
* Returns: einval  if the buffer would crash into the RT descriptors or other bad input
*          0 otherwise
*
*
* Sets up the descriptor associated with the selected suabddress to work in
* buffer2 (multibuffer) mode. In this mode 2 circular buffers are used. The first contains * the data
* to be sent on consecutive transmit messages. The pointer to this buffer is placed in the
* second word of the descriptor block. The second buffer contains the timetag and
* message information words for each command received. The pointer to this buffer is
* placed in the fourth word of the descriptor block. Since the second buffer contains two
* words per block, its size is twice the number of blocks. That number - 1 is placed in the
* high byte of the control word.
   ********************************************************************** */

int borland_dll Setup_Multibuffer(unsigned short subaddr, short numbufs, short startaddr)
{
    unsigned short temp;
    unsigned short offset;

    if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
         return (emode);
	if (gMultiBuf == 0)
		return (emode);
    if (subaddr > 31)
         return (einval);
    if (((startaddr + (numbufs * 34)) >  INIT_RT_DSCRPT) || (startaddr  < Start_DPRAM))
         return (einval);
    offset = subaddr + 32;  /*we only support transmit buffering right now */

    temp = exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) ];
    temp |= ((numbufs * 2) - 1)<<8; /*size of ttag buffer - 1 */
	 exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) ] = temp;
    exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) + 1 ] = startaddr;
    exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) + 2 ] = startaddr;
    exc_summit_int[ INIT_RT_DSCRPT + (offset * DESCRIPTORSIZE) + 3 ] = startaddr + (numbufs * 32);
return (0);
}

int borland_dll Load_Multibuffer_Data(unsigned short numwords, short address, short *data)
{
    int loop;

    if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
         return (emode);
	if (gMultiBuf == 0)
		return (emode);
    if (((address + numwords) >  INIT_RT_DSCRPT)|| (address  < Start_DPRAM))
         return (einval);
	 for (loop = 0; loop < numwords; loop++) {
		 exc_summit_int[address + loop] = data[loop];
	 }
    return 0;
 }

int borland_dll Enable_Multibuffer(void)
{
    int i, idx;
	unsigned short bufstart;

	 bufstart = INIT_RT_BUFFER;
    idx = INIT_RT_DSCRPT;
    if ((curmode != RT_MODE) && (curmode != BM_RT_MODE))
         return (emode);
    gMultiBuf = 1;
    for (i=0; i < 128; i++) /* receive descriptors */
	   {
   		exc_summit_int[ idx ] = 0x0100; /*single buffer */
	      exc_summit_int[ idx + 1] = bufstart + 2; /*pointer to data */
   	   exc_summit_int[ idx + 2] = bufstart + 2; /*current pointer */
	      exc_summit_int[ idx + 3] = bufstart; /*ttag and msginfo */
	      idx += DESCRIPTORSIZE;
   	   bufstart += MCH_BUFSIZE;
		}

return (0);
}

int borland_dll Disable_Multibuffer(void)
{
	return Set_Mode(curmode);
}

void zeroMultibufFlag(void)
{
    gMultiBuf = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -