RT-Thread-packages / wiznet

WIZnet TCP/IP chips (such as W5500/W5100..) SAL framework implement.
Apache License 2.0
49 stars 35 forks source link
iot sal w5100 w5500

WIZnet

中文页 | English

1. Introduction

The WIZnet software package is a porting implementation of RT-Thread based on the WIZnet official website ioLibrary_Driver code base, and currently only supports W5500 devices. On the basis of the original code library function, this software package docks with the RT-Thread SAL socket abstraction layer, realizes the support for standard BSD Socket APIs, is perfectly compatible with a variety of software packages and network functions, and improves the compatibility of WIZnet devices.

1.1 Directory structure

The WIZnet software package directory structure is as follows:

wiznet
├───inc           // RT_Thread transplant header file
├───iolibrary     // WIZnet official library file
│ └───Ethernet    // WIZnet official Socket APIs and WIZCHIP driver
│ │ └───W5500     // WIZCHIP driver
│ │ wizchip_conf.c // Socket configuration file
│ │ wizchip_socket.c // Socket APIs file
│ └───Internet // WIZnet official network function realization
│ │ └───DHCP // DHCP function implementation
│ └───────DNS // DNS function realization
├───src // RT_Thread transplant source code file
│ └───wiz_af_inet.c // WIZnet BSD Socket registered to SAL
│ │ wiz_device.c // WIZnet device initialization
│ │ wiz_ping.c // WIZnet device Ping command realization
│ │ wiz_socket.c // WIZnet BSD Socket APIs implementation
│ └───wiz.c // WIZnet initialization (device initialization, network initialization)
│ LICENSE // package license
│ README.md // Software package instructions
└───SConscript // RT-Thread default build script

1.2 License

The WIZnet software package complies with the Apache-2.0 license, see the LICENSE file for details.

1.3 Dependency

2. Get the software package

To use the WIZnet software package, you need to select it in the RT-Thread package management. The specific path is as follows:

WIZnet: WIZnet TCP/IP chips SAL framework implement
        WIZnet device type (W5500) --->
        WIZnet device configure --->
            (spi30) SPI device name
            (10) Reset PIN number
            (11) IRQ PIN number
  [] Enable alloc IP address through DHCP
            WIZnet network configure --->
                (192.168.1.10) IPv4: IP address
                (192.168.1.1) IPv4: Gateway address
                (255.255.255.0) IPv4: Mask address
  [] Enable Ping utility
  [] Enable debug log output
        Version (latest) --->

WIZnet device type: Configure the supported device type (currently only supports W5500 devices)

WIZnet device configure: configure the parameters of the device used

Enable alloc IP address through DHCP: Configure whether to use DHCP to allocate IP addresses (enabled by default)

WIZnet network configure: If you do not enable the DHCP function, you need to configure the statically connected IP address, gateway and subnet mask

Enable Ping utility: Configure to enable Ping command (enabled by default)

Enable debug log output: Configure to enable debug log display

Version: software package version selection

3. Use the software package

The initialization function of WIZnet software package is as follows:

int wiz_init(void);

This function supports component initialization. If the automatic component initialization function is enabled, the application layer does not need to call this function. The main functions of the function are:

Each WIZnet device needs a unique MAC address. The user can call the following function in the application layer program to set the MAC address of the WIZnet device. If this function is not called, the device will use the default MAC address. The default MAC address is 00-E0-81 -DC-53-1A (Note: If there are devices with the same MAC address in the same LAN, it may cause the device network to be abnormal).

int wiz_set_mac(const char *mac);

After the device is powered on and initialized, the device's MAC address is successfully set, and then you can enter the command wiz_ifconfig in FinSH to view the device's IP address, MAC address and other network information, as shown below:

msh />ifconfig
network interface device: W5500 (Default)    ## Device name
MTU: 1472                                    ## Network maximum transmission unit
MAC: 00 e0 81 dc 53 1a                       ## Device MAC address
FLAGS: UP LINK_UP INTERNET_UP                ## Device flag
ip address: 192.168.12.26                    ## Device IP address
gw address: 192.168.10.1                     ## Device gateway address
net mask: 255.255.0.0                        ## Device subnet mask
dns server #0: 192.168.10.1                  ## DNS server address 0
dns server #1: 0.0.0.0                       ## DNS server address 1

After obtaining the IP address successfully, if the Ping command function is enabled, you can enter the command ping + domain name address in FinSH to test the network connection status, as shown below:

msh />wiz_ping baidu.com
32 bytes from 220.181.57.216 icmp_seq=0 ttl=128 time=31 ticks
32 bytes from 220.181.57.216 icmp_seq=1 ttl=128 time=31 ticks
32 bytes from 220.181.57.216 icmp_seq=2 ttl=128 time=32 ticks
32 bytes from 220.181.57.216 icmp_seq=3 ttl=128 time=32 ticks

The normal test of the ping command indicates that the WIZnet device is successfully connected to the network, and then you can use the standard BSD Socket APIs abstracted by SAL (Socket Abstraction Layer) for network development (MQTT, HTTP, MbedTLS, NTP, Iperf, etc.), WIZnet software package The supported protocol cluster types are: the primary protocol cluster is AF_WIZ, and the secondary protocol cluster is AF_INET (for specific differences and usage, please refer to SAL Programming Guide ).

4. Common problems

5. Matters needing attention

6. Contact & Thanks