Soohwan Kim
Published © Apache-2.0

WIZnetInterface for ARMmbed

This is WIZnet Ethernet Interface using Hardware TCP/IP chip, W5500 and TCP/IP Offload Engine, W7500.

BeginnerFull instructions provided499
WIZnetInterface for ARMmbed

Things used in this project

Hardware components

W7500
WIZnet W7500
×1

Story

Read more

Code

Code

Plain text
#if defined(TARGET_WIZwiki_W7500)
#include "W7500x_toe.h"
#define __DEF_USED_IC101AG__  //For using IC+101AG@WIZwiki-W7500
#else
#include "W5500.h"            // W5500 Ethernet Shield 
//#define USE_WIZ550IO_MAC    // WIZ550io; using the MAC address
#endif

Code

Plain text
 /*
  * Sets the speed and duplex parameters of an ethernet link.
  *
  * @returns true if successful
  */
  void set_link(PHYMode phymode);

Code

Plain text
#define _DHCP_
EthernetInterface eth;  /*1. Creat eth object from EthernetInteface class*/

main()
{
  uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};  

  /*2. Set MAC, IP, Gatway address and Subnet Mask*/
#ifdef _DHCP_
  /*2.1 Set  MAC address, Initialize the interface with DHCP*/
  eth.init(mac_addr); 
#else   
  /*2.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
  eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address 
#endif

  /*3. Check Ethernet Link-Done */
  printf("Check Ethernet Link\r\n");
  if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
  else {printf("- Ethernet PHY Link- Fail\r\n");}

  /*4. Set IP addresses ,start DHCP if needed  */
  eth.connect();
  printf("Connected, IP: %s\n\r", eth.getIPAddress());
  printf("MASK: %s\n\r", eth.getNetworkMask());
  printf("GW: %s\n\r",eth.getGateway());
  ...

  /* Your application 
     Visit for examples - https://developer.mbed.org/teams/WIZnet/
  */

}

Code

Plain text
#define _DHCP_
/* 0. Set SPI Interface with SPI API*/
SPI spi(D11, D12, D13);                  // mosi, miso, sclk
/*1. Creat eth object from EthernetInteface class*/
EthernetInterface eth(&spi, D10, D9);    // spi, cs, reset

main()
{
  uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x1D, 0x62, 0x11}; 
  /*2. Set MAC, IP, Gatway address and Subnet Mask*/
#ifdef _DHCP_
  /*2.1 Set  MAC address, Initialize the interface with DHCP*/
  eth.init(mac_addr); 
#else
  /*2.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
  eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address 
#endif

  /*3. Check Ethernet Link-Done */
  printf("Check Ethernet Link\r\n");
  if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
  else {printf("- Ethernet PHY Link- Fail\r\n");}

  /*4. Set IP addresses ,start DHCP if needed  */
  eth.connect();
  printf("Connected, IP: %s\n\r", eth.getIPAddress());
  printf("MASK: %s\n\r", eth.getNetworkMask());
  printf("GW: %s\n\r",eth.getGateway());
  ...

  /* Your application 
     Visit for examples - https://developer.mbed.org/teams/WIZnet/
  */

}

Code

Plain text
#if defined(TARGET_WIZwiki_W7500)
#include "W7500x_toe.h"
#define __DEF_USED_IC101AG__  //For using IC+101AG@WIZwiki-W7500
#else
#include "W5500.h"            // W5500 Ethernet Shield 
//#define USE_WIZ550IO_MAC    // WIZ550io; using the MAC address
#endif

Code

Plain text
 /*
  * Sets the speed and duplex parameters of an ethernet link.
  *
  * @returns true if successful
  */
  void set_link(PHYMode phymode);

Code

Plain text
#define _DHCP_
EthernetInterface eth;  /*1. Creat eth object from EthernetInteface class*/

main()
{
  uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};  

  /*2. Set MAC, IP, Gatway address and Subnet Mask*/
#ifdef _DHCP_
  /*2.1 Set  MAC address, Initialize the interface with DHCP*/
  eth.init(mac_addr); 
#else   
  /*2.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
  eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address 
#endif

  /*3. Check Ethernet Link-Done */
  printf("Check Ethernet Link\r\n");
  if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
  else {printf("- Ethernet PHY Link- Fail\r\n");}

  /*4. Set IP addresses ,start DHCP if needed  */
  eth.connect();
  printf("Connected, IP: %s\n\r", eth.getIPAddress());
  printf("MASK: %s\n\r", eth.getNetworkMask());
  printf("GW: %s\n\r",eth.getGateway());
  ...

  /* Your application 
     Visit for examples - https://developer.mbed.org/teams/WIZnet/
  */

}

Code

Plain text
#define _DHCP_
/* 0. Set SPI Interface with SPI API*/
SPI spi(D11, D12, D13);                  // mosi, miso, sclk
/*1. Creat eth object from EthernetInteface class*/
EthernetInterface eth(&spi, D10, D9);    // spi, cs, reset

main()
{
  uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x1D, 0x62, 0x11}; 
  /*2. Set MAC, IP, Gatway address and Subnet Mask*/
#ifdef _DHCP_
  /*2.1 Set  MAC address, Initialize the interface with DHCP*/
  eth.init(mac_addr); 
#else
  /*2.2 Set  MAC address and Set MAC, IP, Gatway address and Subnet Mask with string type */
  eth.init(mac_addr, "192.168.77.34", "255.255.255.0", "192.168.77.1"); //Use fixed IP address 
#endif

  /*3. Check Ethernet Link-Done */
  printf("Check Ethernet Link\r\n");
  if(eth.link() == true) { printf("- Ethernet PHY Link-Done \r\n"); }
  else {printf("- Ethernet PHY Link- Fail\r\n");}

  /*4. Set IP addresses ,start DHCP if needed  */
  eth.connect();
  printf("Connected, IP: %s\n\r", eth.getIPAddress());
  printf("MASK: %s\n\r", eth.getNetworkMask());
  printf("GW: %s\n\r",eth.getGateway());
  ...

  /* Your application 
     Visit for examples - https://developer.mbed.org/teams/WIZnet/
  */

}

Credits

Soohwan Kim

Soohwan Kim

6 projects • 7 followers
Embedded System, ARM mbed, Arduino, TCP/IP, SoC, Open Source Hardware

Comments