📄 44b0net.c
字号:
#include "44b0net.h"
#include "necfg.h"
#include "ne2000.h"
#include "Armnet.h"
#include "44b.h"
//#include "stdio.h"
extern unsigned int IP_ADDRESS;
extern ETHERFRAME etherframe;
extern NODE locnode;
unsigned char default_mac[MACLEN] = {0x12,0x34,0x56,0x78,0x90,0xab};
void z44b0net_init(void)
{
//初始化片选
// PORT B GROUP
/* BIT 10 9 8 7 6 5 4 3 2 1 0 */
/* /CS5 /CS4 /CS3 /CS2 /CS1 nWBE3 nWBE2 /SRAS /SCAS SCLS SCKE */
/*RTL8019 NC USBD12 NV_Flash NC NC Sdram Sdram Sdram Sdram*/
/* 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1 */
//nGCS5 net cs
// rPDATB = rPDATB|(1<<10);
rPCONB = rPCONB|(1<<10);
//EXTINT1 as net int ,falling
// rPDATG |= (3<<2);
// rPUPG &= ~(1<<1); // 0 enable
//rPUPG |= (1<<1);//1 disable
// rEXTINT &= ~(0x7<<4);
// rEXTINT |= (0x3<<4); //extint1 falling
NodeInit();
// NetIntPreInit();
ArpInit();
}
void z44b0net_testmenu(void)
{
printf("\nTEST NET FOR EELAB44B0 BOARD");
printf("IP: %u.%u.%u.%u\n", (IP_ADDRESS>>24)&0xff, (IP_ADDRESS>>16)&0xff, (IP_ADDRESS>>8)&0xff, IP_ADDRESS&0xff);
printf("\n1:TEST ICMP ");
printf("\n2:TEST TFTP ");
}
void z44b0net_testicmp(void)
{
printf("testa\n\n");
}
void z44b0net_testtftp(void)
{
printf("testb\n\n");
}
void NetSever(void)
{
unsigned short rxlen,ip_len;
unsigned char net_isr;
ARPKT *arp;
ETHERFRAME *efp;
IPKT *ip;
efp = ðerframe;
net_isr = EN_ISR;
// printf("EN_ISR:0x%x\n",net_isr);
if(net_isr & ENISR_RX)
{
DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted RX\n"));
EN_ISR |= ENISR_RX;
memset((unsigned char *)efp, 0, sizeof(ETHERFRAME)); //buffer set 0
rxlen = GetEthernet(efp);
SwapEther(efp);
if(IsArp(efp, rxlen))
{
arp = (ARPKT *)(efp->edata);
if(READ_PACKED(arp->dip)==locnode.ip &&(arp->op==ARPREQ || arp->op==ARPRESP))
{
DEBUGF(ARP_DEBUG,("Get ARP\n"));
ArpRcvPacket(efp);
}
}
else
{
ip_len = IsIp(efp, rxlen);
if(ip_len)
{
ip = (IPKT *)(efp->edata);
DEBUGF(DEMO_DEBUG,("Get IP\n"));
if(IsIcmp(ip, ip_len))
{
DEBUGF(ICMP_DEBUG,("Get ICMP\n"));
IcmpRcvPacket(efp);
}
else if(IsUdp(ip, ip_len))
{
DEBUGF(DEMO_DEBUG,("Get UDP\n"));
UdpRcvPacket(efp);
}
}
}
}
if(net_isr & ENISR_RX_ERR)
{
DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted RX_ERR\n"));
EN_ISR |= ENISR_RX_ERR;
}
if(net_isr & ENISR_TX)
{
DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted TX\n"));
EN_ISR |= ENISR_TX;
}
if(net_isr & ENISR_TX_ERR)
{
DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted TX_ERR\n"));
EN_ISR |= ENISR_TX_ERR;
}
}
//***************************************************************************
void NodeInit(void)
{
IP_ADDRESS = IP4_ADDR(192,168,0,100);
locnode.ip = IP_ADDRESS;
locnode.mask = IP4_ADDR(255,255,255,0);
locnode.gate = IP4_ADDR(192,168,0,1);
memcpy(locnode.mac,default_mac,6);
locnode.port = 9000;
}
void NetIntPreInit(void)
{
// rPCONG = rPCONG | 0x00c0;
// rPUPG = rPUPG & 0xf7;
// rEXTINT |= 0x4000;
//nGCS5 net cs
// rPDATB = rPDATB|(1<<10);
rPCONB = rPCONB|(1<<10);
rPCONG = rPCONG | 0x000c;
rPUPG = rPUPG & 0xfd;
rEXTINT |= 0x0040; //rising //falling 0x0020;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -