W5300 single chip source code

The W5300 has greatly improved memory space and data processing capabilities. The W5300 is especially suitable for the transmission of large-traffic multimedia data such as IPTV, IP set-top boxes and digital TV. The Internet connection is very simple and fast through a single chip with integrated TCP/IP protocol and 10/100M Ethernet MAC and PHY.

The W5300 and the host (MCU) use a bus interface. The W5300 can be easily interfaced to the host by direct access or indirect access, just like accessing SRAM memory. The W5300's communication data can be accessed through the TX/RX FIFO registers of each port. Thanks to these features, even a beginner can easily use the W5300 for Internet connectivity.

characteristic

Supports soft and hardware hybrid TCP/IP protocols: TCP, UDP, ICMP, IGMP, IPv4, ARP, PPPoE, Ethernet;

Support 8 independent ports (sockets) to connect at the same time;

Network data transmission, the rate can reach 80Mbps;

Support ADSL connection (support PPPOE protocol with PAP/CHAP authentication);

Internal 128K byte memory for TX/RX buffer;

Dynamically adjusting internal TX/RX memory allocation based on port communication data throughput;

Embedded 10BaseT/100BaseTX Ethernet physical layer, support automatic response (full duplex / half duplex mode);

Optional TX1:1 RX1:1 network transformer interface YL18-2050S, YT37-1107S and YL2J011D, YL2J201A

Support automatic polarity conversion (MDI/MDIX);

Support 8/16-bit data bus; l 0.18μm CMOS process;

3.3V working voltage, I / O port can withstand 5V voltage, internal with 1.8V voltage regulator;

LQFP-100, 14x14mm lead-free package.

The source code of the MCU control W5300 is as follows:

/**

************************************************** ****************************

* @file W5100.c

* This document consists of 5 parts:

* 1. W5100 initialization

* 2. Socket initialization of W5100

* 3. Socket connection

* If the Socket is set to TCP server mode, the Socket_Listen() function is called and the W5100 is in the listening state until the remote client connects to it.

* If the Socket is set to TCP client mode, the Socket_Connect() function is called.

* Each time the Socket_Connect(s) function is called, a connection is made.

* If the connection is unsuccessful, a timeout interrupt is generated and then the function can be called again to connect.

* If the Socket is set to UDP mode, the Socket_UDP function is called.

* 4. Socket data receiving and sending

* 5. W5100 interrupt processing

*

* Set W5100 as the server mode call process: W5100_Init()--"Socket_Init(s)--"Socket_Listen(s), the setup process is completed, waiting for the client's connection.

* Set W5100 as the calling mode of client mode: W5100_Init()--"Socket_Init(s)--"Socket_Connect(s), the setup process is completed and connected with the remote server.

* Set W5100 to UDP mode call process: W5100_Init()--"Socket_Init(s)--"Socket_UDP(s), the setup process is completed, and can communicate with remote host UDP.

*

* W5100 connection success, termination of connection, receiving data, sending data, timeout and other events can be obtained from the interrupt status.

************************************************** ****************************

*/

#include"W5100.h" /* Defines the register address and status of W5100*/

#include"REG51.h"

Typedef unsigned char SOCKET;

Sbit SPI_CS= P1^0;

Sbit SPI_SCK= P1^1;

Sbit SPI_SO= P1^2;

Sbit SPI_SI= P1^3;

Sbit SPI_EN= P1^4;

Sbit KEY= P1^5;

/* Port Data Buffer*/

Unsigned char Rx_Buffer[20]; /* Port receive data buffer */

Unsigned char Tx_Buffer[20]; /* Port send data buffer */

/* Network Parameter Register*/

Unsigned char Gateway_IP[4]={192,168,2,254}; /* Gateway IP Address */

Unsigned char Sub_Mask[4]={255,255,255,0}; /* Subnet Mask */

Unsigned char Phy_Addr[6]={0x00,0x08,0xDC,0x01,0x02,0x03}; /* Physical Address */

Unsigned char IP_Addr[4]={192,168,2,1}; /* Loacal IP Address */

Unsigned char S0_Port[2]={0x13,0x88}; /* Socket0 Port number 5000 */

Unsigned char S0_DIP[4]={192,168,2,43}; /* Socket0 DesTInaTIon IP Address */

Unsigned char S0_DPort[2]={0x13,0x88}; /* Socket0 DesTInaTIon Port number 5000*/

Unsigned char S0_State=0; /* Socket0 state recorder */

Unsigned char S0_Data; /* Socket0 receive data and transmit OK */

Unsigned char W5100_Interrupt;

/* UDP Destionation IP address and Port number */

Unsigned char UDP_DIPR[4];

Unsigned char UDP_DPORT[2];

Void Delay(unsigned int x)

{

Unsigned int i;

For(i=0;i"x;i++){

SPI_EN=1;

}

}

Unsigned char SPI_ReadByte(void){

Unsigned char i, rByte=0;

For(i=0;i"8;i++){

rByte "=1;

rByte|=SPI_SO;

SPI_SCK=0;

Delay(10);

SPI_SCK=1;

SPI_SCK=0;

}

Return rByte;

}

Void SPI_SendByte(unsigned char dt)

{

Unsigned char i;

For(i=0;i"8;i++)

{

If((dt""i)&0x80)

{

SPI_SI=1;

}

Else

{

SPI_SI=0;

}

SPI_SCK=0;

Delay(10);

SPI_SCK=1;

SPI_SCK=0;

}

}

Unsigned char Read_W5100(unsigned short addr)

{

Unsigned char i;

/* Set CS of W5100 to low level*/

SPI_CS=0;

/* Send read command */

SPI_SendByte(0x0f);

/* sending address*/

SPI_SendByte(addr/256);

SPI_SendByte(addr);

/* Read data*/

i=SPI_ReadByte();

/* Set CS of W5100 to high level*/

SPI_CS=1;

Return i;

}

Void Write_W5100(unsigned short addr, unsigned char dat)

{

/* Set CS of W5100 to low level*/

SPI_CS=0;

Delay(100);

/* Send write command */

SPI_SendByte(0xf0);

/* sending address*/

SPI_SendByte(addr/256);

SPI_SendByte(addr);

/* data input*/

SPI_SendByte(dat);

Delay(100);

/* Set CS of W5100 to high level*/

SPI_CS=1;

}

Void W5100_Init(void)

{

Unsigned char i;

SPI_EN=1; SPI_SCK=0; SPI_CS=1; SPI_SO=1;

Write_W5100(W5100_MODE, MODE_RST); /* Soft reset W5100*/

Delay(100);

///Write_W5100(W5100_MODE,0); /*Soft reset W5100*/

Delay(100); /* delay 100ms, define the function yourself*/

/*Set the IP address of the gateway (Gateway), 4 bytes */

/*Using a gateway allows communication to break through the limitations of subnets, allowing gateways to access other subnets or enter the Internet*/

For(i=0;i"4;i++)

Write_W5100(W5100_GAR+i,Gateway_IP); /*Gateway_IP is a 4-byte unsigned char array, which defines itself*/

For(i=0;i"4;i++)

Gateway_IP=Read_W5100(W5100_GAR+i);

/* Set the subnet mask (MASK) value, 4 bytes. Subnet mask for subnet operation*/

For(i=0;i"4;i++)

Write_W5100(W5100_SUBR+i, Sub_Mask); /*SUB_MASK is a 4-byte unsigned char array, which defines itself*/

/*Set the physical address, 6 bytes, to uniquely identify the physical address value of the network device

The address value needs to be applied to the IEEE. According to the OUI regulations, the first 3 bytes are the vendor code, and the last three bytes are the product serial number.

If you define your own physical address, note that the first byte must be even */

For(i=0;i"6;i++)

Write_W5100(W5100_SHAR+i, Phy_Addr); /*PHY_ADDR6 byte unsigned char array, define by yourself*/

/*Set the IP address of this machine, 4 bytes

Note that the gateway IP must belong to the same subnet as the local IP, otherwise the local machine will not be able to find the gateway*/

For(i=0;i"4;i++)

Write_W5100(W5100_SIPR+i, IP_Addr); /*IP_ADDR is a 4-byte unsigned char array, which defines itself*/

/*Set the size of the send buffer and receive buffer, refer to the W5100 data sheet*/

Write_W5100(W5100_RMSR, 0x55); /*Socket Rx memory size=2k*/

Write_W5100(W5100_TMSR, 0x55); /*Socket Tx mempry size=2k*/

/* Set the retry time, the default is 2000 (200ms) */

Write_W5100 (W5100_RTR, 0x07);

Write_W5100(W5100_RTR+1, 0xd0);

/* Set the number of retries, the default is 8 times * /

Write_W5100(W5100_RCR,8);

/* Start interrupt, refer to the W5100 data sheet to determine the type of interrupt you need.

IMR_CONFLICT is an IP address conflict abort

IMR_UNREACH is an abnormal interrupt that the address cannot be reached during UDP communication.

Others are Socket event interrupts, add */ as needed

Write_W5100(W5100_IMR,(IMR_CONFLICT|IMR_UNREACH|IMR_S0_INT));

}

Unsigned char Detect_Gateway(void)

{

Unsigned char i;

Write_W5100((W5100_S0_MR), S_MR_TCP); /*Set socket0 to TCP mode*/

Write_W5100((W5100_S0_CR), S_CR_OPEN); /*Open socket0*/

If(Read_W5100(W5100_S0_SSR)!=S_SSR_INIT)

{

Write_W5100((W5100_S0_CR), S_CR_CLOSE); /*Open unsuccessful, close Socket, then return */

Return FALSE;

}

/*Check the gateway and get the physical address of the gateway*/

For(i=0;i"4;i++)

Write_W5100 ((W5100_S0_DIPR+i), IP_Addr+1); /* Writes a different IP value from the local IP address to the destination address register*/

Write_W5100((W5100_S0_CR), S_CR_CONNECT); /*Open the TCP connection of socket0*/

Delay(20); /* Delay 20ms */

i=Read_W5100(W5100_S0_DHAR); /*Read the physical address of the destination host, which is the gateway address*/

Write_W5100((W5100_S0_CR), S_CR_CLOSE); /*Close socket0*/

If(i==0xff)

{

/**********The gateway server was not found, or it was not successfully connected to the gateway server***********/

/********** Add processing code yourself***********/

Return FALSE;

}

Return TRUE;

}

Void Socket_Init(SOCKET s)

{

Unsigned int i;

/ * Set the fragment length, refer to the W5100 data sheet, this value can be modified * /

Write_W5100((W5100_S0_MSS+s*0x100), 0x00); /*Maximum number of fragments = 16*/

Write_W5100((W5100_S0_MSS+s*0x100+1), 0x10);

/* Set Socket Port number */

Switch(s)

{

Case 0:

Write_W5100(W5100_S0_PORT, S0_Port[0]); /* Set Local Socket Port number */

Write_W5100 (W5100_S0_PORT+1, S0_Port[1]);

Write_W5100 (W5100_S0_DPORT, S0_DPort[0]); /* Set Destination port number */

Write_W5100 (W5100_S0_DPORT+1, S0_DPort[1]);

For(i=0;i"4;i++)

Write_W5100 (W5100_S0_DIPR+i, S0_DIP); /* Set Destination IP Address */

Break;

Case 1:

Break;

Case 2:

Break;

Case 3:

Break;

Default:

Break;

}

}

/**

* @brief Set Socket to connect client to remote server

* When the native Socket works in client mode, refer to the program and establish a connection with the remote server.

*

* If a timeout interrupt occurs after the connection is initiated, the connection to the server fails and the program connection needs to be recalled.

*The program generates a connection with the server every time it is called.

**/

Unsigned char Socket_Connect(SOCKET s)

{

Write_W5100((W5100_S0_MR+s*0x100), S_MR_TCP); /*Set the socket to TCP mode*/

Write_W5100((W5100_S0_CR+s*0x100), S_CR_OPEN); /*Open Socket*/

If(Read_W5100(W5100_S0_SSR+s*0x100)!=S_SSR_INIT)

{

Write_W5100(W5100_S0_CR+s*0x100, S_CR_CLOSE); /*Open unsuccessful, close Socket, then return */

Return FALSE;

}

Write_W5100((W5100_S0_CR+s*0x100), S_CR_CONNECT); /*Set Socket to Connect mode*/

Return TRUE;

/* This completes the open connection work of the Socket. As for whether it establishes a connection with the remote server, it needs to wait for the Socket interrupt.

To determine whether the connection of the Socket is successful. Refer to the Socket Interrupt Status of the W5100 Data Sheet*/

}

/**

RX 6900XT Graphic Card

About this item

1.Axial-tech Fan Design has been enhanced with more fan blades and a new rotation scheme
2.2.9-slot design expands cooling surface area compared to last gen for more thermal headroom than ever before
3.Super Alloy Power II includes premium alloy chokes, solid polymer capacitors, and an array of high-current power stages
4.MaxContact heat spreader allows 2X more contact with the GPU chip for improved thermal transfer
5.Reinforced frame prevents excessive torsion and lateral bending of the PCB
6.FanConnect II equips a hybrid-controlled fan header for optimal system cooling
7.Vented backplate prevents hot air from recirculating through the cooling array


The ROG STRIX Radeon RX 6700 XT merges an industry-leading cooling solution with high-end power performance and additional creature comforts.
A massive heatsink is cooled by Axial-tech fans that utilize a new rotation scheme.
And top-shelf capacitors, chokes, and MOSFETs effortlessly deliver hundreds of watts at a millisecond's notice.

rx6900xt,amd rx 6900xt,radeon rx 6900xt,amd radeon rx 6900xt,rx6900xt price

Easy Electronic Technology Co.,Ltd , https://www.yxpcelectronicgroups.com