|
各位大虾,经过几天的努力,网卡中断无法响应的问题已经解决了,可是现在又遇到个问题:中断程序虽然响应了,也进入的接收数据的函数,可是在查询接收状态寄存器的时候,总是返回接收没有OK,我用的是网卡的混杂模式,初始化以及接收函数如下:
- put_reg (PP_RxCTL,PP_RxCTL_Promiscuous| PP_RxCTL_IA | PP_RxCTL_Broadcast | PP_RxCTL_RxOK);
- /* enable receive interrupt on receive operations */
- put_reg (PP_RxCFG, 0x0003 | PP_RxCFG_RxOK/*RXIRQ*/);
- /* do not generate any interrupts on transmit operations */
- put_reg (PP_TxCFG, 0x0007 | 0);
- /* use interrupt number 0*/
- put_reg (PP_IntReg, PP_IntReg_IRQ0);
- /* interrupt before counter overflow on buffer operations */
- put_reg (PP_BufCFG, PP_BufCFG_Miss | PP_BufCFG_TxCol);
- /* enable interrupt generation */
- put_reg (PP_BusCTL, 0x0017 | PP_BusCTL_EnableIRQ/*EnableIRQ*/);
- /* enable transmitter/receiver mode */
- put_reg (PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx);
复制代码
处理函数:
- int eth_rx (void)
- {
- int i;
- unsigned short rxlen;
- unsigned short *addr;
- unsigned short status;
- status = get_reg (PP_RER);
- if ((status & PP_RER_RxOK) == 0)
- return 0;
- status = CS8900_RTDATA; /* stat */
- rxlen = CS8900_RTDATA; /* len */
- #ifdef DEBUG
- if (rxlen > PKTSIZE_ALIGN + PKTALIGN)
- Uart_Printf ("packet too big!\n");
- #endif
- /*NetRxPackets--接收数据的缓存区*/
- for (addr = (unsigned short *) NetRxPackets[0], i = rxlen >> 1; i > 0;i--)
- {
- *addr++ = CS8900_RTDATA;
- }
- if (rxlen & 1)
- {
- *addr++ = CS8900_RTDATA;
- }
- /* Pass the packet up to the protocol layers. */
- // NetReceive (NetRxPackets[0], rxlen);
- // main_count=0;
- Uart_Printf("Rv OK!\n");
- return rxlen;
- }
复制代码
上面的status总是返回4,也就是初始化的值,而我的中断处理函数部分如下:
- irq_status = get_reg (PP_ISQ);
- // ISQ interrupt event, and allowed to service in this loop?
- while ((irq_status != 0x0000) && (events2service-- > 0))
- {
- // investigate event
- if ((irq_status & 0x003f) == 0x0004/*Receiver Event*/)
- {
- // correctly received frame, either broadcast or individual address
- // TODO: think where these checks should appear: here or in cs8900_input()
- if ((irq_status & 0x0100/*RxOK*/) && (irq_status & 0x0c00/*Broadcast | Individual*/))
- {
- // read the frame from the cs8900a
- eth_rx();
- }
复制代码
能够成功进入eth_rx函数。可是既然进去了,又为什么Rx不OK呢?请高手指教,谢谢了!
|
|