📄 pquicc.c
字号:
memcpy((void *)tx_bd->data_ptr,
(void *)buf_ptr->data_ptr,
buf_ptr->data_len);
tx_bd->data_len = (ushort)buf_ptr->data_len;
if ( buf_ptr->next_buffer != NU_NULL )
{
tx_bd->status &= TX_BD_Wrap;
tx_bd->status |= TX_BD_Ready;
}
}
if ( buf_ptr->next_buffer == NU_NULL )
{
tx_bd->status |= TX_BD_PaddingAdded
| TX_BD_TransmitCRC
| TX_BD_Last;
tx_bd->status |= TX_BD_Ready;
}
while ( tx_bd->status & TX_BD_Ready == 1 )
waiting++;
errortrans = 0;
if ( pquicc->scc_regs[0].scc_scce & ETHERNET_TXE )
{
if ( tx_bd->status & TX_ERR_HEARTBEAT )
{
waiting++;
}
if ( tx_bd->status & TX_ERR_LATECOLLSN )
{
issue_cmd(0x0110);
errortrans = 1;
}
if ( tx_bd->status & TX_ERR_UNDERRUN )
{
issue_cmd(0x0110);
errortrans = 1;
}
if ( tx_bd->status & TX_ERR_CARRIERLOST )
{
waiting++;
}
if ( tx_bd->status & TX_ERR_RETRYLIMIT )
{
issue_cmd(0x0110);
errortrans = 1;
}
}
if ( errortrans == 0 )
buf_ptr = buf_ptr->next;
if ( (tx_bd->status & TX_BD_Wrap ) == 0 )
tx_bd++;
else
{
tx_bd->status |= TX_BD_Wrap;
tx_bd = (struct _tx_bd *)First_TX_BD;
}
}
NU_Local_Control_Interrupts(old_level);
return 0;
} /* NU_Xmit_Packet */
/****************************************************************************/
/* FUNCTION */
/* */
/* PQUICC_Recv_Frame */
/* */
/* DESCRIPTION */
/* */
/* A receive_frame interrupt or a receive_buffer intterrupt causes */
/* this routine to run. The buffer is identified as either a complete */
/* frame that fits in a buffer, the first in a chain of buffers, the */
/* middle in a chain of buffers, or the last in a chain of buffers. */
/* */
/* AUTHOR */
/* */
/* Bill Haggerty */
/* */
/* CALLED BY */
/* */
/* PQUICC_LISR */
/* */
/* CALLS */
/* */
/* memcpy */
/* MEM_Buffer_Enqueue */
/* MEM_Buffer_Dequeue */
/* NU_Activate_HISR */
/* NU_Local_Control_Interrupts */
/* */
/* INPUTS */
/* */
/* device pointer : device to use */
/* */
/* OUTPUTS */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* B. Haggerty 05-07-1998 Created version 1.0 */
/* */
/****************************************************************************/
STATUS PQUICC_Recv_Frame(DV_DEVICE_ENTRY *device)
{
static NET_BUFFER *buf_ptr;
static NET_BUFFER *first_buffer;
int receiving_frame;
int old_level;
old_level = NU_Local_Control_Interrupts(NU_DISABLE_INTERRUPTS);
while ( ! ( rx_bd->status & RX_BD_Empty ) )
{
if ( (rx_bd->status & RX_BD_First) && (rx_bd->status & RX_BD_Last) )
{
buf_ptr = MEM_Buffer_Dequeue(&MEM_Buffer_Freelist);
if (buf_ptr != NU_NULL)
{
buf_ptr->data_len = (rx_bd->data_len - 4);
memcpy((void *)buf_ptr->mem_parent_packet,
(void *)rx_bd->data_ptr,
(rx_bd->data_len - 4));
buf_ptr->mem_buf_device = device;
buf_ptr->mem_flags = 0;
buf_ptr->data_ptr = buf_ptr->mem_parent_packet;
buf_ptr->next_buffer = NU_NULL;
MEM_Buffer_Enqueue (&MEM_Buffer_List, buf_ptr);
NU_Activate_HISR(&PQUICC_Ether_Inter_Control);
}
} /* receive frame */
/* This belongs in the First bit set case */
if ( (rx_bd->status & RX_BD_First) && !(rx_bd->status & RX_BD_Last) )
{
buf_ptr = MEM_Buffer_Dequeue(&MEM_Buffer_Freelist);
memcpy((void *)buf_ptr->mem_parent_packet,
(void *)rx_bd->data_ptr,
rx_bd->data_len );
buf_ptr->data_ptr = buf_ptr->mem_parent_packet;
buf_ptr->mem_buf_device = device;
buf_ptr->mem_flags = 0;
buf_ptr->data_len = rx_bd->data_len;
first_buffer = buf_ptr;
buf_ptr->next_buffer = MEM_Buffer_Dequeue(&MEM_Buffer_Freelist);
buf_ptr = buf_ptr->next_buffer;
Numbuffs = 1;
}
/* end of first bit set case */
/* This belongs in the Last bit set case */
if ( (rx_bd->status & RX_BD_Last) && !(rx_bd->status & RX_BD_First) )
{
memcpy((void *)buf_ptr->mem_parent_packet,
(void *)rx_bd->data_ptr,
( rx_bd->data_len -
( NET_PARENT_BUFFER_SIZE * Numbuffs )
- 4 ) );
buf_ptr->data_len = ( rx_bd->data_len -
( (NET_PARENT_BUFFER_SIZE * Numbuffs ) - 4 ));
buf_ptr->next_buffer = NU_NULL;
buf_ptr->data_ptr = buf_ptr->mem_parent_packet;
buf_ptr->mem_buf_device = device;
buf_ptr->mem_flags = 0;
first_buffer->mem_total_data_len = ( rx_bd->data_len - 4 );
MEM_Buffer_Enqueue (&MEM_Buffer_List, first_buffer);
NU_Activate_HISR(&PQUICC_Ether_Inter_Control);
}
/* end of last bit case */
/* case where neither the first or last bit is set */
if ( !(rx_bd->status & RX_BD_Last | rx_bd->status & RX_BD_First) )
{
memcpy((void *)buf_ptr->mem_parent_packet,
(void *)rx_bd->data_ptr,
rx_bd->data_len );
buf_ptr->data_ptr = buf_ptr->mem_parent_packet;
buf_ptr->mem_buf_device = device;
buf_ptr->mem_flags = 0;
buf_ptr->data_len = rx_bd->data_len;
buf_ptr->next_buffer = MEM_Buffer_Dequeue(&MEM_Buffer_Freelist);
buf_ptr = buf_ptr->next_buffer;
Numbuffs++;
}
if ( (rx_bd->status & RX_BD_Wrap ) == 0 )
{
rx_bd->data_len = 0;
rx_bd->status = 0;
rx_bd->status |= RX_BD_Interrupt;
rx_bd->status |= RX_BD_Empty;
rx_bd++;
}
else
{
rx_bd->data_len = 0;
rx_bd->status = 0;
rx_bd->status |= RX_BD_Interrupt;
rx_bd->status |= RX_BD_Wrap;
rx_bd->status |= RX_BD_Empty;
rx_bd = (struct _rx_bd *)First_RX_BD;
}
} /* end while */
NU_Local_Control_Interrupts(old_level);
return(0);
} /* PQUICC_Recv_Frame */
/****************************************************************************/
/* FUNCTION */
/* */
/* PQUICC_LISR */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -