📄 cs8900a.c
字号:
NU_Activate_HISR (&CS8900A_inter_BufferE);
//#endif
break;
case REG_NUM_RX_MISS:
break;
case REG_NUM_TX_COL:
/* Unused events */
break;
}
/* Read another event from the interrupt Status Queue */
if ( CS8900AInMemoryMode )
Event = CS8900AReadPacketPage( PKTPG_ISQ );
else
Event = *((unsigned short *)PORT_ISQ);
}
//////////////////////////////////////////////////////////////////////////
// 杨天池,修改于2003.11.3
// 清楚EINTPEND SRCPND INTPND 三个寄存器的挂起位,避免开中断后,有进入中断
//////////////////////////////////////////////////////////////////////////
//清除EINTPEND的相应位
// rEINTPEND = 0x00000200;
//清除SRCPND的相应位
// ClearPending(BIT_EINT8_23);
rEINTMASK &= 0xfffffdff; // 屏蔽 EINT9
rINTMSK= rINTMSK&(~BIT_EINT8_23);
//////////////////////////////////////////////////////////////////////////
// 杨天池,修改于2003.11.3 结束
//////////////////////////////////////////////////////////////////////////
} /* end CS8900A_LISR */
/****************************************************************************/
/* FUNCTION */
/* */
/* CS8900A_Recv_HISR */
/* */
/* DESCRIPTION */
/* */
/* This function simply sets an event that lets the upper layer software */
/* know that there is at least one packet waiting to be processed. */
/* */
/* AUTHOR */
/* */
/* CALLED BY */
/* */
/* No functions call this function */
/* */
/* CALLS */
/* */
/* NU_Set_Events */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 02/17/96 Initial version. */
/* */
/****************************************************************************/
void CS8900A_Recv_HISR (void)
{
NU_Set_Events(&Buffers_Available, (UNSIGNED)2, NU_OR);
} /* end interrupt CS8900A_Recv_HISR routine */
/****************************************************************************/
/* FUNCTION */
/* */
/* CS8900A_Chip_Write */
/* */
/* DESCRIPTION */
/* */
/* This function will use the DMA to copy a packet from host memory to */
/* the CS8900A. */
/* */
/* AUTHOR */
/* */
/* */
/* CALLED BY */
/* */
/* NU_Xmit */
/* */
/* CALLS */
/* */
/* OUTB */
/* OUTW */
/* */
/* INPUTS */
/* */
/* io_addr : The IO base address of the device. */
/* buf_ptr : A pointer to the buffer to transmit. */
/* */
/* OUTPUTS */
/* */
/* 0 upon success. */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 02/17/96 Initial version. */
/* */
/****************************************************************************/
int CS8900A_Chip_Write(int16 io_addr, NET_BUFFER *buf_ptr)
{
uint16 i;
uint16 *pack_addr;
uint16 pktlen = buf_ptr->mem_total_data_len;
uint16 len;
uint16 total_sent;
unsigned short BusStatus;
unsigned short *pFrame;
STATUS previous_int_value;
total_sent=0;
/* Put the header into the frame buffer */
if ( CS8900AInMemoryMode )
{
// pFrame =(CS8900A_pPacketPage + (PKTPG_TX_FRAME/2));
}
/* Ethernet has a minimum packet size of 60 bytes. Pad if necessary. */
if (pktlen < 60)
pktlen = 60;
/* Force the packet length to an even number of bytes. */
pktlen += (pktlen & 1);
/* Request to start a new transmit */
BusStatus = CS8900ARequestTransmit(pktlen);
//#ifdef PACKET
// while (!(CS8900AReadPacketPage(PKTPG_BUS_ST ) & BUS_ST_RDY4TXNOW));
//#endif
if ( BusStatus & BUS_ST_RDY4TXNOW )
{
/* Lock out interrupts. */
previous_int_value = NU_Local_Control_Interrupts(NU_DISABLE_INTERRUPTS);
/* The chip is ready for transmit now */
/* Copy the frame to the chip to start transmission */
/* Get the length and the pointer to the data for the first buffer. */
len = buf_ptr->data_len + (buf_ptr->data_len & 1);
pack_addr = (uint16 *)buf_ptr->data_ptr;
if ( CS8900AInMemoryMode )
{
for(i=0; i<len/2; i++)
*pFrame++ = *pack_addr++;
}
else
{
for(i=0; i<len/2; i++)
*((unsigned short *)PORT_RXTX_DATA)=*pack_addr++;
}
total_sent = i;
/* Point to the next buffer in the chain. */
buf_ptr = (NET_BUFFER *)buf_ptr->next_buffer;
/* While there are more buffers in the chain transfer the data therin to
the chip. */
while (buf_ptr)
{
/* Guarentee the length is divisible by two. This should only be a
problem when the last buffer in the chain is encountered. */
len = buf_ptr->data_len + (buf_ptr->data_len & 1);
/* Get a pointer to the data. */
pack_addr = (uint16 *)buf_ptr->data_ptr;
/* Transfer the data to the chip. */
if ( CS8900AInMemoryMode )
{
for(i=0; i<len/2; i++)
*pFrame++ = *pack_addr++;
}
else
{
for(i=0; i<len/2; i++)
*((unsigned short *)PORT_RXTX_DATA)=*pack_addr++;
}
total_sent += i;
buf_ptr = (NET_BUFFER *)buf_ptr->next_buffer;
}
/* This loop is only necessary when the packet to be sent is less than the
ethernet minimum of 60. In that case this loop will send the bytes
required to pad the whole length out to 60. */
while (total_sent++ < pktlen/2)
{
if ( CS8900AInMemoryMode )
{
*pFrame++ = *pack_addr++;
}
else
{
*((unsigned short *)PORT_RXTX_DATA)=*pack_addr++;
}
}
/* Re-enable interrupts. */
NU_Local_Control_Interrupts(previous_int_value);
}
else
total_sent=0;
return(total_sent);
} /* CS8900A_Chip_Write */
/****************************************************************************/
/* FUNCTION */
/* */
/* CS8900A_Chip_Read */
/* */
/* DESCRIPTION */
/* */
/* This function will use the DMA to copy a from the CS8900A to RAM. */
/* */
/* AUTHOR */
/* */
/* CALLED BY */
/* */
/* NU_Recv_Packet */
/* */
/* CALLS */
/* */
/* OUTB */
/* OUTW */
/* */
/* INPUTS */
/* */
/* io_addr : The IO base address of the device. */
/* ptr : Location to put the data. */
/* r_size : The amoutn of data to read. */
/* */
/* OUTPUTS */
/* */
/* 0 upon success. */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 02/17/96 Initial version. */
/* */
/****************************************************************************/
STATUS CS8900A_Chip_Read( int16 io_addr, NET_BUFFER *buf_ptr,unsigned short *pFrame)
{
int pkt_len = buf_ptr->mem_total_data_len;
uint16 *pack_addr;
uint16 len;
int i;
/* Force the packet length to an even number of bytes. */
pkt_len += (pkt_len & 1);
len = buf_ptr->data_len + (buf_ptr->data_len & 1);
pack_addr = (uin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -