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

📄 socket1.h

📁 这是本人以前用C51做的TCP/IP协议,也是借鉴了一些前辈的东西,,,,绝对可用!
💻 H
📖 第 1 页 / 共 2 页
字号:
#define pcbreakfg			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x00)))  //1
#define caliwrfg			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x01)))  //1
#define caliwrfg8			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x02)))  //1
#define caliwrfgxx			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x03)))  //1
#define	dev_typebk			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x04)))  //1
#define	scale574b			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x06)))  //1
#define	got_2da(i)			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x08+i)))  //1*4

#define	startch			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x0e)))  //1
#define	startchfg			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x0f)))  //1

#define	closechfg			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x10)))  //1
#define	disp4light(i)			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x12+i)))  //1*4
#define	lostpstatus			(*((volatile u_char  xdata *)(RAM_BASEC1 + 0x18)))  //1
#define	pccomutm			(*((volatile u_long  xdata *)(RAM_BASEC1 + 0x20)))  //4

xdata u_char  tempr[16]                        _at_ 0x8130;

#define RAM_BASE   0x8200  //
#define plostway		(*(( volatile  u_char  xdata*)(RAM_BASE +0)))
#define plostfag(i)		(*(( volatile  u_char  xdata*)(RAM_BASE +0x02+ i)))
//#define nwtm(i)	         	(*(( volatile  u_char  xdata*)(RAM_BASE+0x10+ i)))
//#define nwtmbcd(i)	         	(*(( volatile  u_char  xdata*)(RAM_BASE+0x20+ i)))
//#define timebk(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x30+ i)))

#define wrsta_size   0x04  //
#define wrstatus0(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x20+wrsta_size*i)))  //4*4=16
#define relatotal(i)		(*(( volatile  u_long  xdata*)(RAM_BASE+0x30+4*i)))  // 4*4
#define relatotalc(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x30+4*i)))  // 4*4

#define schendfg(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x40+i)))  //   1*4

#define hvnewsch(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x48+i)))  //   1*4  type
#define hvstarsch(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x4c+i)))  //   1*4

#define cynum0(i)		(*(( volatile  u_int  xdata*)(RAM_BASE+0x50+2*i)))  //   2*4
#define wknum0(i)		(*(( volatile  u_int  xdata*)(RAM_BASE+0x58+2*i)))  //   2*4
#define crefnum(i)		(*(( volatile  u_int  xdata*)(RAM_BASE+0x60+2*i)))  //   2*4
#define crefnumchar(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x60+i)))  //   2*4
#define drefnum(i)		(*(( volatile  u_int  xdata*)(RAM_BASE+0x68+2*i)))  //   2*4
#define drefnumchar(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x68+i)))  //   2*4

#define schlastc(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x70+i)))  //   1*4
#define schlastd(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x74+i)))  //   1*4
#define refccfg(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x78+i)))  //   1*4
#define refcdfg(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x7c+i)))  //   1*4

#define statufg(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x80+i)))  //   1*4
#define claimdeg_size   0x10  //
#define claimdeg(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0x90+claimdeg_size*i)))  //   16*4
#define vcref0_size   0x08  //
#define vcref0(i)		(*(( volatile  u_char  xdata*)(RAM_BASE+0xd0+vcref0_size*i)))  //   8*4
////*********************************
#define     RAM_BASEA   0X8300
#define detv2i2_size   0x40  //
#define detv2i2(i)		(*(( volatile  u_int  xdata*)(RAM_BASEA+0x00+detv2i2_size*i)))  //   (2v+2i)*16*4
#define detv2i2xx(i)		(*(( volatile  u_char  xdata*)(RAM_BASEA+0x00+detv2i2_size*i)))  //
//#define detv2i2(i)		(*(( volatile  u_char  xdata*)(RAM_BASEA+0x00+detv2i2_size*i)))  //   32*4
//#define nowrefi0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEA+0x80+detv2i2_size*i)))  //   32*4


#define     RAM_BASEB   0X8400
#define     chstp_size   0x10  //
#define     chele_size   0x20  //
#define     nwstp0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEB+0x00+chstp_size*i)))  //  1*16*4
#define     nwstatu0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEB+0x40+chstp_size*i)))  //  1*16*4
#define     tlimtway(i)		(*(( volatile  u_char  xdata*)(RAM_BASEB+0x80+chstp_size*i)))  //  1*16*4
#define     nwcycle0(i)		(*(( volatile  u_int  xdata*)(RAM_BASEB+0xc0+chele_size*i)))  //  2*16*4
#define     chele_size   0x20  //
#define     eleclmt0(i)		(*(( volatile  u_int  xdata*)(RAM_BASEB+0x140+chele_size*i)))  //   32*4
#define     chtim_size   0x40  //
#define     timclmt0(i)		(*(( volatile  u_long  xdata*)(RAM_BASEB+0x1c0+chtim_size*i)))  //   64*4
#define     ch2da_size   0x20  //
#define     vi2da0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEB+0x2c0+ch2da_size*i)))  //  2*16*4
#define     vi2darefg_size   0x10  //
#define     da2frefg(i)		(*(( volatile  u_char  xdata*)(RAM_BASEB+0x340+vi2darefg_size*i)))  //  1*16*4

#define     RAM_BASEC   0X8800
#define     pause_size   0x10  //
#define     pause0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEC+0x00+pause_size*i)))  //  1*16*4
#define     pauseb0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEC+0x00+i)))  //  1*16*4
#define     resume0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEC+0x40+pause_size*i)))  //  1*16*4
#define     resumeb0(i)		(*(( volatile  u_char  xdata*)(RAM_BASEC+0x40+i)))  //  1*16*4
//#define     RAM_BASED   0X8890
//#define     kbbuf(i)		(*(( volatile  u_char  xdata*)(RAM_BASED+0x00+i)))  //  1*16*4  =1328
//#define     kbbufa(i)		(*(( volatile  u_char  xdata*)(RAM_BASED+0x530+i)))  //  1*16*4   =1328

#define     RAM_BASEE   0X9300   //
#define     detbuf1(i)		(*(( volatile  u_char  xdata*)(RAM_BASEE+0x00+i)))  //  576
#define     detbuf1zz(i)		(*(( volatile  u_char  xdata*)(RAM_BASEE+0x08+0x88*i)))  //  576
#define     detbuf1cy(i)		(*(( volatile  u_int  xdata*)(RAM_BASEE+0x0a+0x88*i)))  //  576
#define     detbuf1retim(i)		(*(( volatile  u_char  xdata*)(RAM_BASEE+0x0c+0x88*i)))  //  576

#define     detbuf2(i)		(*(( volatile  u_char  xdata*)(RAM_BASEE+0x240+i)))  //  576
#define     detbuf2zz(i)		(*(( volatile  u_char  xdata*)(RAM_BASEE+0x240+0x08+0x88*i)))  //  576
#define     detbuf3(i)		(*(( volatile  u_char  xdata*)(RAM_BASEE+0x480+i)))  //  576

#define     RAM_BASEF   0X99C0   //
#define     sch_size   0x4b0  //
//#define     recibuf(i)		(*(( volatile  u_char  xdata*)(RAM_BASEF+0x00)))  //  1600  tcp
#define     schbuf(i)		(*(( volatile  u_char  xdata*)(RAM_BASEF+0x640+0x4b0*i)))  //  1200*4 //a000h

xdata u_char dst_buf[1600]                           _at_ 0X99C0 ; //  1600  tcp
xdata u_char real_buf[576]                           _at_ 0X9540 ;   //=detbuf2(i)
//FREE free 0xb2c0h---0Xd000
#define     RAM_BASEH   0xb300   //
#define     sendreal(i)		(*(( volatile  u_int  xdata*)(RAM_BASEH+4*i)))        //2+2=  256
#define     err1da2da(i)        (*(( volatile  u_int  xdata*)(RAM_BASEH+0x100+4*i)))  //2+2=  256

#define nwtm(i)	         	(*(( volatile  u_char  xdata*)(RAM_BASEH+0x200+ i)))
#define nwtmbcd(i)	         	(*(( volatile  u_char  xdata*)(RAM_BASEH+0x210+ i)))
#define timebk(i)		(*(( volatile  u_char  xdata*)(RAM_BASEH+0x220+ i)))

//FREE free 0xb500h---0Xc500
#define     RAM_BASED   0xc480
#define     kbbuf(i)		(*(( volatile  u_char  xdata*)(RAM_BASED+0x00+i)))  //  1*16*4  =1334
#define     kbbufa(i)		(*(( volatile  u_char  xdata*)(RAM_BASED+0x5b0+i)))  //  1*16*4   =1334  //1456
xdata u_char  kbbufa[1450]                        _at_ 0xca30;

#define     RAM_BASEG   0xd000   //
#define     ckch_size   0x580 //1376 //0x480  //1152 =64*18   1024 1280   ,last one >1280
#define     ckbuf(i)		(*(( volatile  u_char  xdata*)(RAM_BASEG+i)))  //  84 bytes
#define     hjbuf(i)		(*(( volatile  u_char  xdata*)(RAM_BASEG+i)))  //  84 bytes
#define     ckbufu(i)		(*(( volatile  u_int  xdata*)(RAM_BASEG+2*i)))  //  84 bytes
#define     hjbufu(i)		(*(( volatile  u_int  xdata*)(RAM_BASEG+2*i)))  //  84 bytes

xdata u_char  RamSource_IP[4]                        _at_ 0xff00;
xdata u_int Source_port                              _at_ 0xff04; //0xc004;
xdata u_char Destination_IP[4]                       _at_ 0xff06; //0xc006;
xdata u_int Destination_port                         _at_ 0xff0a; //0xc00a;
xdata u_char RamGateway_IP[4]                        _at_ 0xff0c; //0xc00c;
xdata u_char NetparameterRamSubnet_Mask_Value[4]     _at_ 0xff10; //0xc010;
xdata u_char  RamMac_address[6]                      _at_ 0xff14; //0xc014;
xdata u_char timeout1[2]                             _at_ 0xff1a; //0xc01a;

xdata u_char sendok[12]                _at_ 0xff40; //0xd000;    //64
xdata u_char sender[12]                _at_ 0xff50; //0xd00c;    //64
xdata u_char recibuf[32]               _at_ 0xff60; //0xd000;      //serial int get the net address 32 bytes

xdata u_char cali_buf[16]               _at_ 0xffc0; //0xd000;  cali real sample data

xdata unsigned long int temp1bytexi     _at_ 0xffd0;
xdata unsigned long int temp1byteyi     _at_ 0xffd4;
xdata unsigned long int temp1bytezi     _at_ 0xffd8;

xdata unsigned long int temp1bytezzi     _at_ 0xffdc;

xdata unsigned long int temp1bytem1    _at_ 0xffe0; //0xe000;
xdata u_char temp1bytem1x[4]           _at_ 0xffe0; //0xe00c;    //64
xdata unsigned long int temp1bytem2    _at_ 0xffe4; //0xe004;
xdata unsigned long int temp1bytem3    _at_ 0xffe8; //0xe008;
xdata unsigned long int temp1bytem4    _at_ 0xffec; //0xe00c;
xdata u_char temp1bytem4x[4]           _at_ 0xffec; //0xe00c;    //64

xdata unsigned long int temp1bytex     _at_ 0xfff0;
xdata unsigned long int temp1bytey     _at_ 0xfff4;
xdata unsigned long int temp1bytez     _at_ 0xfff8;

xdata unsigned long int temp1bytezz     _at_ 0xfffc;
//
//formation end

      //tcp/ip
void initW3100A(void);							// Initialize W3100A
void InitSYA();
void InitNetConfig();
extern void NBlisten(SOCKET s) reentrant;

void sysinit(u_char sbufsize, u_char rbufsize);                         // Specify flexible memory and soft reset W3100A
void setsubmask(u_char * addr);						// Set subnet mask value
void setgateway(u_char * addr);                                         // Set Gateway IP address
void setMACAddr(u_char * addr);                                         // Set Mac address
void setIP(u_char * addr);                                              // Set source IP address
void setdesAddr(u_char *addr);
void setipagain(void);
extern int socket(SOCKET s, u_char protocol, u_int port, u_char flag) reentrant;        // Open a channel among TCP, UDP, IP_RAW mode

void setIPprotocol(SOCKET s, u_char ipprotocol);			// Set upper protocol of IP
void settimeout(u_char * val);						// Set re-transmition timeout value
void setINTMask(u_char mask);						// Set Interrupt mask value
void setTOS(SOCKET s, u_char tos);                                      // Set type of service
void reset_sock(SOCKET s);                                              // Reset the specified channel

extern void initseqnum(SOCKET s) reentrant;
extern int send(SOCKET s,  u_char  * buf, u_int len) reentrant;
extern int send_in(SOCKET s,  u_char  * buf, u_int len) reentrant;
extern int recv(SOCKET s,  u_char   * buf, u_int len) reentrant;

extern u_int read_data(SOCKET s, u_char   * src, u_char  * dst, u_int len) reentrant;
extern u_int write_data(SOCKET s, u_char  * src, u_char  * dst, u_int len) reentrant;

extern void close(SOCKET s) reentrant;
extern int select(SOCKET s, u_char func) reentrant;
void settimeout(u_char * val);
extern unsigned long int sum_Result(uchar * d,uint len) reentrant;
extern unsigned long int sumre_Result(uchar *d,uint len) reentrant ;

extern void snedokmake(void) reentrant;
extern void snedermake(void) reentrant;

void prginition(void);
unsigned long int sumex_Result(uchar * d,uint len) ;

void intunion(void);
void clrmen(void);
extern void delay(uint gg) reentrant;
void delayx(uint ggg) ;
void Int7(void);
void checkint1(void); //reentrant;
char serialsend(char * d,int len);
void snd1char(uchar dats);
void get1char(void);
void serialint(void);
void quiterror(void);
void quitok(void);
////////////////        formation software
/////////******************************************
//formation software

void startnewsch(void);
void testrealdat(void);// reentrant;
void compaelectr(void);
void compatime(void);
void dowithdegre(void);
void getpcpauf(void);
void getpcpause(void);
void getpcresume(void);

void changecctocv(void);
void changeccc(void);
void changeccd(void);
void changeall(void);
void changnextcy(void);
//void checknewsch(void);
void firenextsp(uchar zone,uchar ch,uchar stp);
/////////

unsigned long int rd1255_Result(void) ;//reentrant;
void readhjkbv(uchar chv);  //void readhjkbi(uint ii)
void readhjkbi(uchar zonea,uchar chi);
extern void inition1255(void) ;
void read1255(void);
void clrmen(void);   //buf8000[tt]
void calcutime(void);
void dispprg(void);
void readat256(void);    //void wrtat256(void)
void wrtat256(void);

void initon1390(void);
void initon1390int(void);
uchar read1390();
void readtime(void);
void write1390(uchar b);

void set88346(uchar ldadds,uchar ld8chan,uchar dat2dah,uchar dat2dal) ;
void set7558(uchar ldcs,uchar chanadds,uchar dat2dah,uchar dat2dal);
void startrut(uchar zone);// reentrant;
void assemstatus(uchar zone);
void refrstatus(uchar zone);
void buildref(uchar zone);
void sleepall(uchar zone);
void testcalid(void);
void ready2da(uchar zonea,uchar ch);   //
void readat256ck(uchar zonea,uchar ch) ;
void readat256hj(uchar zonea,uchar ch) ;
void calcu2da(uchar zonea);

void set_time(void);
void receive_sch(void);
void send_realdat(void) ;
void send_calidat(void);
void begin_test(void);
void locate_start(void) ; //reentrant;
void get_2da(void);
void get_pausef(void);
void get_resume(void);
void receive_kbv(void);
void sendback_kbv(void);
void lostpow_set(void)  ;

void startchxx(void);
void closechxx(void);

void invertbcdcode(void);


uchar code tab83ad[12]={0x08,0x04,0x0c,0x02,0x0a,0x06,0x0e,0x01,0x09,0x05,0x0d,0x03};
//uchar code tab88346[16]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code tab88346[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar code tabdcdc[4]={0x03,0x02,0x01,0x02} ;
uchar code tabgal[4]={0xfc,0xf3,0xcf,0x3f} ;
uchar code tabdisp[4]={0x01,0x02,0x00,0x02};   //gong yang   03=no,00=shuang;02=red;01=green
uchar code scaledx[8]={0xfe,0xfd,0xfb,0xf7,0xf1,0xf2,0xf4,0xf8} ; //
uchar code tabmap[64]= {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
                     16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
                     32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
                     48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63};   //gong yin  */

⌨️ 快捷键说明

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