lpc1768

Committer:
jh1cdv00
Date:
Tue Jan 27 01:38:19 2015 +0000
Revision:
0:f35dada1dac1
lpc1768

Who changed what in which revision?

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