📄 emac_isr.c
字号:
#include "emac.h"
volatile Int32 RxCount; // RX count
volatile Int32 TxCount; // TX count
volatile Int32 ErrCount; // Error count
volatile EMAC_Desc *pDescRx; // Next descriptors to ACK in ISR
volatile EMAC_Desc *pDescTx; // Next descriptors to ACK in ISR
/*
* Interrupt service routine
*/
void EMAC_isr( )
{
Uint32 intr_flags;
Uint32 tmp;
Uint32 error;
CSL_INTC1_REGS->FIQ0 = 0xffffffff; // Clear all flags
CSL_INTC1_REGS->FIQ1 = 0xffffffff;
CSL_INTC1_REGS->IRQ0 = 0xffffffff;
CSL_INTC1_REGS->IRQ1 = 0xffffffff;
/* Disable EMAC/MDIO interrupts in wrapper */
CSL_FINST( EWRAP_REGS->EWCTL, EWRAP_EWCTL_INTEN, DISABLE );
/* Read the interrupt cause */
intr_flags = EMAC_REGS->MACINVECTOR ;
/*
* Look for fatal errors first
*/
if ( intr_flags & CSL_FMK( EMAC_MACINVECTOR_HOSTPEND, 1 ) )
{
/* Read the error status - we'll decode it by hand */
error = EMAC_REGS->MACSTATUS ;
ErrCount++;
/* return with interrupt disabled in the wrapper */
return;
}
/*
* Look for statistics interrupt
*/
if ( intr_flags & CSL_FMK( EMAC_MACINVECTOR_STATPEND, 1 ) )
{
ErrCount++;
/*
// Normally, we would read the statistics here, and reset the
// counters to "ack" the interrupt. However, in this test, there
// is no chance of overflowing the statistics. Thus any such
// indication is an error. We log the error and return
*/
/* return with interrupt disabled in the wrapper */
return;
}
/*
* Look for TX interrupt ( channel 0 )
*/
if ( intr_flags & CSL_FMK( EMAC_MACINVECTOR_TXPEND, 1 << 0 ) )
{
tmp = EMAC_REGS->TX0CP;
EMAC_REGS->TX0CP = tmp;
/* This while loop is only used when ACK'ing more than one desc */
while ( tmp != ( Uint32 )pDescTx )
{
if ( pDescTx->PktFlgLen & EMAC_DSC_FLAG_OWNER )
{
ErrCount++;
return;
}
pDescTx++;
TxCount++;
}
if ( pDescTx->PktFlgLen & EMAC_DSC_FLAG_OWNER )
{
ErrCount++;
return;
}
pDescTx++;
TxCount++;
}
/*
* Look for RX interrupt ( channel 0 )
*/
if ( intr_flags & CSL_FMK( EMAC_MACINVECTOR_RXPEND, 1 << 0 ) )
{
tmp = EMAC_REGS->RX0CP;
EMAC_REGS->RX0CP = tmp;
/* This while loop is only used when ACK'ing more than one desc */
while ( tmp != ( Uint32 )pDescRx )
{
pDescRx++;
RxCount++;
}
pDescRx++;
RxCount++;
}
/* Enable EMAC/MDIO interrupts in wrapper */
CSL_FINST( EWRAP_REGS->EWCTL, EWRAP_EWCTL_INTEN, ENABLE );
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -