⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 51单片机下的RTL8019网络芯片的驱动程序
💻 C
字号:
#include <reg51.h>
#include <stdio.h>
#include "config.h"
#include "GloblDef.h"
#include "TCPIPmem.h"
#include "RTL8019.h"
//#include "IP.h"
//#include "etherif.h"
//#include "ARP.h"
//#include "Netif.h"
//#include "ICMP.h"
//#include "TCP.h"
//#include "UDP.h"
//#include "I2C.h"
//#include "w77e58.h"
#include <absacc.h>

/******************************************************************************
函数:Delay()
功能:延时chDelay ms
参数:
      unsigned char chDelay:要延时的时长,<=255MS
返回:无
说明:请根据具体情况调整延时值
******************************************************************************/
void delay(unsigned int iDly)
{
 unsigned char chTmpIn;
 unsigned int iTmpOut;
 for(iTmpOut = 0;iTmpOut < iDly;iTmpOut++)
     //针对24MHZ的主频
     for(chTmpIn = 0;chTmpIn < 250;chTmpIn++)
     {
     ;
     }
}

/******************************************************************************
函数:SerialInit()
功能:对串口进行初始化,设置工作模式、波特率等
参数:无
返回:无
说明:
*****************************************************************************
void SerialInit()
{
	//set TI to 1, set TR1 to 1 
	SCON = 0x52;// SM0 SM1 =1 SM2 REN TB8 RB8 TI RI 
	TMOD = 0x20;// GATE=0 C/T-=0 M1 M0=2 GATE C/T- M1 M0 
	TH1 = 0xE6;	// TH1=E6 4800 when at 24MHz,TH1=F3,9600,24MHz 
	PCON = 0x80;
	TCON = 0x40;// 01101001 TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT 
}*/


/******************************************************************************
函数:InterruptInit()
功能:对定时中断进行初始化,设置定时器及其中断时长
参数:无
返回:无
说明:
*****************************************************************************
void InterruptInit()
{
	TMOD |= 0x01;
	TH0 = 0x3C;	//TIMER_24M_25MS_H;
	TL0 = 0xAA;	//TIMER_24M_25MS_L;
	TR0 = 1;

	//open interrupt for rtl and timer 
	EA = 1;
	// EX0 = 1;
	ET0 = 1;
} */

/******************************************************************************

					主程序

******************************************************************************/
void main()
{
    //分配显示缓冲,每屏显示32个字
    //unsigned int xdata chDisplayBuf[64];
    //unsigned char chtmp = 0;

    //分配网络缓冲
    //struct SMemHead xdata *MemHead;
	//struct SEtherDevice xdata DevRTL;
    //struct SNetIf xdata *pNetIf;
    //unsigned long	IPAddr	= 0xc0a80103;	//本机IP地址:192.168.1.3
	//unsigned long	NetMask	= 0xffffff00;	//子网掩码:255.255.255.0 */
	//unsigned long	GateWay	= 0xc0a80101;	//网关地址:192.168.1.1  */
    //unsigned char xdata EtherAddr[6] = {0x52,0x54,0x4C,0x30,0x2e,0x2f};  //本机MAC地址

    //      显示驱动流程      //
    //SerialInit();
    //LEDInit();

    //中断
    //InterruptInit();

    //      网络驱动流程      //
    RTL8019Init();

    //     协议栈处理流程     //

    //MemInit();
	//NetIfInit();
	//ARPInit();
	//TCPInit();
	/* init Devcie struct and init this device */
	//EtherDevInit(&DevRTL,EtherAddr,&RTLSendPacket,RTLReceivePacket);
	/* add this device to NetIf */
	//pNetIf = NetIfAdd(IPAddr,NetMask,GateWay,EtherInput,EtherOutput,&DevRTL);

    //      解码驱动流程      //
    //I2CInit();
    //Sta013Init();
       

    //         主循环         //
    while(1)
    {
         RTL8019SendPacketTest();
    }



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -