Line 253... |
Line 253... |
{
|
{
|
int length;
|
int length;
|
int rc;
|
int rc;
|
unsigned int ticks, ticksLast=0;
|
unsigned int ticks, ticksLast=0;
|
IPFrame *ethFrame=NULL;
|
IPFrame *ethFrame=NULL;
|
|
static int ethErrorCount=0;
|
(void)arg;
|
(void)arg;
|
|
|
for(;;)
|
for(;;)
|
{
|
{
|
OS_InterruptMaskSet(IRQ_ETHERNET_RECEIVE);
|
OS_InterruptMaskSet(IRQ_ETHERNET_RECEIVE);
|
Line 272... |
Line 273... |
OS_ThreadSleep(50);
|
OS_ThreadSleep(50);
|
break;
|
break;
|
}
|
}
|
length = EthernetReceive(ethFrame->packet, PACKET_SIZE);
|
length = EthernetReceive(ethFrame->packet, PACKET_SIZE);
|
if(length == 0)
|
if(length == 0)
|
|
{
|
|
#if 1 //Disable this on quiet networks
|
|
//No Ethernet packets seen for 60 seconds?
|
|
if(++ethErrorCount >= 120)
|
|
{
|
|
printf("\nEthernetInit\n");
|
|
ethErrorCount = 0;
|
|
EthernetInit(NULL); //Need to re-initialize
|
|
}
|
|
#endif
|
break;
|
break;
|
|
}
|
|
ethErrorCount = 0;
|
Led(1, 1);
|
Led(1, 1);
|
rc = IPProcessEthernetPacket(ethFrame, length);
|
rc = IPProcessEthernetPacket(ethFrame, length);
|
Led(1, 0);
|
Led(1, 0);
|
if(rc)
|
if(rc)
|
ethFrame = NULL;
|
ethFrame = NULL;
|
Line 362... |
Line 375... |
//unsigned long data=0x5f800000; //SMI R0 = 10Mbps half duplex
|
//unsigned long data=0x5f800000; //SMI R0 = 10Mbps half duplex
|
int i, value;
|
int i, value;
|
volatile unsigned char *buf = (unsigned char*)ETHERNET_RECEIVE;
|
volatile unsigned char *buf = (unsigned char*)ETHERNET_RECEIVE;
|
|
|
CrcInit();
|
CrcInit();
|
|
if(MacAddress)
|
|
{
|
for(i = 0; i < 6; ++i)
|
for(i = 0; i < 6; ++i)
|
{
|
{
|
value = MacAddress[i];
|
value = MacAddress[i];
|
gDestMac[i+1] = (unsigned char)((value >> 4) | (value << 4));
|
gDestMac[i+1] = (unsigned char)((value >> 4) | (value << 4));
|
}
|
}
|
|
}
|
|
|
//Configure Ethernet PHY for 10Mbps full duplex via SMI interface
|
//Configure Ethernet PHY for 10Mbps full duplex via SMI interface
|
MemoryWrite(GPIO0_OUT, ETHERNET_MDIO | ETHERNET_MDIO_WE | ETHERENT_MDC);
|
MemoryWrite(GPIO0_OUT, ETHERNET_MDIO | ETHERNET_MDIO_WE | ETHERENT_MDC);
|
for(i = 0; i < 34; ++i)
|
for(i = 0; i < 34; ++i)
|
{
|
{
|
Line 399... |
Line 415... |
|
|
//Start receive DMA
|
//Start receive DMA
|
MemoryWrite(GPIO0_OUT, ETHERNET_ENABLE);
|
MemoryWrite(GPIO0_OUT, ETHERNET_ENABLE);
|
|
|
//Setup interrupts for receiving data
|
//Setup interrupts for receiving data
|
|
OS_InterruptRegister(IRQ_ETHERNET_RECEIVE, EthernetIsr);
|
|
if(SemEthernet)
|
|
return;
|
SemEthernet = OS_SemaphoreCreate("eth", 0);
|
SemEthernet = OS_SemaphoreCreate("eth", 0);
|
SemEthTransmit = OS_SemaphoreCreate("ethT", 1);
|
SemEthTransmit = OS_SemaphoreCreate("ethT", 1);
|
OS_ThreadCreate("eth", EthernetThread, NULL, 240, 0);
|
OS_ThreadCreate("eth", EthernetThread, NULL, 240, 0);
|
OS_InterruptRegister(IRQ_ETHERNET_RECEIVE, EthernetIsr);
|
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|