code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.

Dependencies:   mbed

Committer:
eqon
Date:
Thu Jun 07 05:44:29 2012 +0000
Revision:
0:0ce833f21e63

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eqon 0:0ce833f21e63 1
eqon 0:0ce833f21e63 2 /*
eqon 0:0ce833f21e63 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
eqon 0:0ce833f21e63 4
eqon 0:0ce833f21e63 5 Permission is hereby granted, free of charge, to any person obtaining a copy
eqon 0:0ce833f21e63 6 of this software and associated documentation files (the "Software"), to deal
eqon 0:0ce833f21e63 7 in the Software without restriction, including without limitation the rights
eqon 0:0ce833f21e63 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
eqon 0:0ce833f21e63 9 copies of the Software, and to permit persons to whom the Software is
eqon 0:0ce833f21e63 10 furnished to do so, subject to the following conditions:
eqon 0:0ce833f21e63 11
eqon 0:0ce833f21e63 12 The above copyright notice and this permission notice shall be included in
eqon 0:0ce833f21e63 13 all copies or substantial portions of the Software.
eqon 0:0ce833f21e63 14
eqon 0:0ce833f21e63 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
eqon 0:0ce833f21e63 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
eqon 0:0ce833f21e63 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
eqon 0:0ce833f21e63 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
eqon 0:0ce833f21e63 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
eqon 0:0ce833f21e63 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
eqon 0:0ce833f21e63 21 THE SOFTWARE.
eqon 0:0ce833f21e63 22 */
eqon 0:0ce833f21e63 23
eqon 0:0ce833f21e63 24 /** \file
eqon 0:0ce833f21e63 25 Ethernet network interface header file
eqon 0:0ce833f21e63 26 */
eqon 0:0ce833f21e63 27
eqon 0:0ce833f21e63 28 #ifndef ETHERNETNETIF_H
eqon 0:0ce833f21e63 29 #define ETHERNETNETIF_H
eqon 0:0ce833f21e63 30
eqon 0:0ce833f21e63 31 struct netif;
eqon 0:0ce833f21e63 32
eqon 0:0ce833f21e63 33 #include "mbed.h"
eqon 0:0ce833f21e63 34
eqon 0:0ce833f21e63 35 #include "if/lwip/LwipNetIf.h"
eqon 0:0ce833f21e63 36
eqon 0:0ce833f21e63 37 ///Ethernet network interface return codes
eqon 0:0ce833f21e63 38 enum EthernetErr
eqon 0:0ce833f21e63 39 {
eqon 0:0ce833f21e63 40 __ETH_MIN = -0xFFFF,
eqon 0:0ce833f21e63 41 ETH_TIMEOUT, ///<Timeout during setup
eqon 0:0ce833f21e63 42 ETH_OK = 0 ///<Success
eqon 0:0ce833f21e63 43 };
eqon 0:0ce833f21e63 44
eqon 0:0ce833f21e63 45 ///Ethernet network interface
eqon 0:0ce833f21e63 46 /**
eqon 0:0ce833f21e63 47 This class provides Ethernet connectivity to the stack
eqon 0:0ce833f21e63 48 */
eqon 0:0ce833f21e63 49 class EthernetNetIf : public LwipNetIf
eqon 0:0ce833f21e63 50 {
eqon 0:0ce833f21e63 51 public:
eqon 0:0ce833f21e63 52 ///Instantiates the Interface and register it against the stack, DHCP will be used
eqon 0:0ce833f21e63 53 EthernetNetIf(); //W/ DHCP
eqon 0:0ce833f21e63 54
eqon 0:0ce833f21e63 55 ///Instantiates the Interface and register it against the stack, DHCP will not be used
eqon 0:0ce833f21e63 56 /**
eqon 0:0ce833f21e63 57 IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address.
eqon 0:0ce833f21e63 58 */
eqon 0:0ce833f21e63 59 EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP
eqon 0:0ce833f21e63 60 virtual ~EthernetNetIf();
eqon 0:0ce833f21e63 61
eqon 0:0ce833f21e63 62 ///Brings the interface up
eqon 0:0ce833f21e63 63 /**
eqon 0:0ce833f21e63 64 Uses DHCP if necessary
eqon 0:0ce833f21e63 65 @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
eqon 0:0ce833f21e63 66 @return : ETH_OK on success or ETH_TIMEOUT on timeout
eqon 0:0ce833f21e63 67 */
eqon 0:0ce833f21e63 68 EthernetErr setup(int timeout_ms = 15000);
eqon 0:0ce833f21e63 69
eqon 0:0ce833f21e63 70 virtual void poll();
eqon 0:0ce833f21e63 71
eqon 0:0ce833f21e63 72 private:
eqon 0:0ce833f21e63 73 Timer m_ethArpTimer;
eqon 0:0ce833f21e63 74 Timer m_dhcpCoarseTimer;
eqon 0:0ce833f21e63 75 Timer m_dhcpFineTimer;
eqon 0:0ce833f21e63 76 Timer m_igmpTimer;
eqon 0:0ce833f21e63 77
eqon 0:0ce833f21e63 78 bool m_useDhcp;
eqon 0:0ce833f21e63 79
eqon 0:0ce833f21e63 80 netif* m_pNetIf;
eqon 0:0ce833f21e63 81
eqon 0:0ce833f21e63 82 IpAddr m_netmask;
eqon 0:0ce833f21e63 83 IpAddr m_gateway;
eqon 0:0ce833f21e63 84
eqon 0:0ce833f21e63 85 const char* m_hostname;
eqon 0:0ce833f21e63 86
eqon 0:0ce833f21e63 87 };
eqon 0:0ce833f21e63 88
eqon 0:0ce833f21e63 89 #endif
eqon 0:0ce833f21e63 90