WIZnet Developer Forum

W5500 + ioLibrary + starting an aplication (C language problem)

Hi guys,

Apologies for wasting your time with such chillness, but I am getting crazy with my C code.
I am using W5500 with ioLibrary and about SPI interface and where put my code to exchange packets with W5500 is working very well.

Now, I am trying to initialize the W5500 and right after it, start the DHCP function.

My “C language"is limited”…

int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg) what is arg ??? and what kind and how I should fill values on it ?

e.g.: trying CW_INIT_WIZCHIP

void wizchip_setnetinfo(wiz_NetInfo* pnetinfo)

or

setSHAR(pnetinfo->mac);

or
setSHAR(wiz_NetInfo.mac);

how should I put values on mac ??? or call the function wizchip_setnetinfo ??

I am able to get the MAC address from another memory right now … in other words, I have the values ready, but I don’t know how use it or call the functions with.

the main error that I am getting is

      not a variable identifier "wiz_NetInfo"

Sorry guys, I really tried hard solve it instead write here…

Please, any suggestion will be perfect … and if someone want to take a look on my code … just ask me, I send for you.

Thanks a lot.

Hi, I know this is old but maybe it will help someone.
I face kind of the same issue in the past. My c abilities are limited, The great thing is that the ioLibrary basically do everything for you. If you have SPI working is really easy to set the information you need. Take your time and check some of the files in the library so you can understand more.

In you main file include:
#include “wizchip_conf.h”
#include “w5500.h”
#include “socket.h”

Those are provided by the ioLibrary.

For DHCP you need sockets and your wiznet needs a mac address (you can fake it, at least for testing).

wiz_NetInfo wiz_net_info={
{0x11,0x22,0x33,0x44,0x55,0x66} // Source Mac Address
};

DHCP need to run a specific function every 1 sec. something like this.

/*

  • Runs every sec.
  • this function is called every 1 sec for a timer that you need to create.
    */
    void timer_one_second(void)
    {
    DHCP_time_handler(); //this function needs to be called every 1 sec (is used for timeouts, etc.)
    }

    inside your main function call:

setSHAR(wiz_net_info.mac); // set the mac address

Then you have to initialize DHCP:

DHCP_init(0,buffer); // initializes dhcp on socket 0, W5500 have 0-7 sockets;

After that in your main loop call:

DHCP_run();

That should make dhcp works.

1 Like

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.