mbed IP library over Ethernet2
Dependencies: Socket lwip-eth lwip-sys lwip
Fork of EthernetInterface by
Revision 37:926eb6517318, committed 2014-04-24
- Comitter:
- mbed_official
- Date:
- Thu Apr 24 10:45:57 2014 +0100
- Parent:
- 36:6a67d2bddc7c
- Child:
- 38:f6ec7a025939
- Commit message:
- Synchronized with git revision 94fd2228fb4a382fb98d0115f6691fc0b659eea8
Full URL: https://github.com/mbedmicro/mbed/commit/94fd2228fb4a382fb98d0115f6691fc0b659eea8/
Currently NET_7 (HttpClient test) and NET_8 (NTP test) fail for
unknown reasons.
Changed in this revision
--- a/EthernetInterface.cpp Wed Jan 08 08:31:01 2014 +0000 +++ b/EthernetInterface.cpp Thu Apr 24 10:45:57 2014 +0100 @@ -22,14 +22,13 @@ #include "lwip/netif.h" #include "netif/etharp.h" #include "lwip/dhcp.h" -#include "arch/lpc17_emac.h" -#include "lpc_phy.h" +#include "eth_arch.h" #include "lwip/tcpip.h" #include "mbed.h" /* TCP/IP and Network Interface Initialisation */ -static struct netif lpcNetif; +static struct netif netif; static char mac_addr[19]; static char ip_addr[17] = "\0"; @@ -64,12 +63,12 @@ tcpip_init(tcpip_init_done, NULL); tcpip_inited.wait(); - memset((void*) &lpcNetif, 0, sizeof(lpcNetif)); - netif_add(&lpcNetif, ipaddr, netmask, gw, NULL, lpc_enetif_init, tcpip_input); - netif_set_default(&lpcNetif); + memset((void*) &netif, 0, sizeof(netif)); + netif_add(&netif, ipaddr, netmask, gw, NULL, eth_arch_enetif_init, tcpip_input); + netif_set_default(&netif); - netif_set_link_callback (&lpcNetif, netif_link_callback); - netif_set_status_callback(&lpcNetif, netif_status_callback); + netif_set_link_callback (&netif, netif_link_callback); + netif_set_status_callback(&netif, netif_status_callback); } static void set_mac_address(void) { @@ -106,18 +105,17 @@ } int EthernetInterface::connect(unsigned int timeout_ms) { - NVIC_SetPriority(ENET_IRQn, ((0x01 << 3) | 0x01)); - NVIC_EnableIRQ(ENET_IRQn); - + eth_arch_enable_interrupts(); + int inited; if (use_dhcp) { - dhcp_start(&lpcNetif); + dhcp_start(&netif); // Wait for an IP Address // -1: error, 0: timeout inited = netif_up.wait(timeout_ms); } else { - netif_set_up(&lpcNetif); + netif_set_up(&netif); // Wait for the link up inited = netif_linked.wait(timeout_ms); @@ -128,13 +126,13 @@ int EthernetInterface::disconnect() { if (use_dhcp) { - dhcp_release(&lpcNetif); - dhcp_stop(&lpcNetif); + dhcp_release(&netif); + dhcp_stop(&netif); } else { - netif_set_down(&lpcNetif); + netif_set_down(&netif); } - NVIC_DisableIRQ(ENET_IRQn); + eth_arch_disable_interrupts(); return 0; }
--- a/EthernetInterface.h Wed Jan 08 08:31:01 2014 +0000 +++ b/EthernetInterface.h Thu Apr 24 10:45:57 2014 +0100 @@ -20,8 +20,8 @@ #ifndef ETHERNETINTERFACE_H_ #define ETHERNETINTERFACE_H_ -#if !defined(TARGET_LPC1768) && !defined(TARGET_LPC4088) -#error The Ethernet Interface library is supported only on the mbed NXP LPC1768 +#if !defined(TARGET_LPC1768) && !defined(TARGET_LPC4088) && !defined(TARGET_K64F) +#error The Ethernet Interface library is not supported on this target #endif #include "rtos.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eth_arch.h Thu Apr 24 10:45:57 2014 +0100 @@ -0,0 +1,41 @@ +/* EthernetInterface.h */ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Architecture specific Ethernet interface +// Must be implemented by each target + +#ifndef ETHARCH_H_ +#define ETHARCH_H_ + +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void eth_arch_enable_interrupts(void); +void eth_arch_disable_interrupts(void); +err_t eth_arch_enetif_init(struct netif *netif); + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef ETHARCHINTERFACE_H_ +
--- a/lwipopts_conf.h Wed Jan 08 08:31:01 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* Copyright (C) 2012 mbed.org, MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef LWIPOPTS_CONF_H -#define LWIPOPTS_CONF_H - -#define LWIP_TRANSPORT_ETHERNET 1 - -#endif