Norimasa Okamoto / WIZ820ioNetIf
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WIZ820ioNetIf.h Source File

WIZ820ioNetIf.h

Go to the documentation of this file.
00001 // WIZ820ioNetIf.h 2013/3/24
00002 
00003 /** \file
00004 WIZ820io network interface header file
00005 */
00006 #pragma once
00007 #include "MyNetIf.h"
00008 
00009 ///W5200 network interface return codes
00010 enum W5200Err
00011 {
00012   __W5200_MIN = -0xFFFF,
00013   W5200_TIMEOUT, ///<Timeout during setup
00014   W5200_SETUP_ERR,
00015   W5200_SETUP_ERR_LINK_DOWN,
00016   W5200_OK = 0 ///<Success
00017 };
00018 
00019 ///WIZ820io network interface
00020 class WIZ820ioNetIf : public MyNetIf {
00021 public:
00022     /** Create a WIZ820io ethernet interface
00023      *
00024      * @param mosi SPI mosi pin connected to WIZ820io
00025      * @param miso SPI miso pin conencted to WIZ820io
00026      * @param sclk SPI sclk pin connected to WIZ820io
00027      * @param cs   DigitalOut pin used as WIZ820io select
00028      * @param reset DigitalOut pin WIZ820io hardware reset 
00029      */
00030     WIZ820ioNetIf(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset);
00031     void config(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP
00032     ///Brings the interface up
00033     /**
00034     Uses DHCP if necessary
00035     @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
00036     @return : 0 on success or -1 on timeout
00037     */    
00038     int setup(int timeout_ms = 15000);
00039     W5200Err IPrenew(int timeout_ms = 15000);
00040     W5200Err IPrelease(int timeout_ms = 15000);
00041     IpAddr m_dns;
00042 private:
00043     void pin_assign(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset);
00044     bool m_useDhcp;
00045     IpAddr m_netmask;
00046     IpAddr m_gateway;
00047     const char* m_hostname;
00048 };