Skip to content

Introduce the lwip-interface into the core mbed repo #2231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Jul 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b032d18
Preparing new layout - moving lwip
Apr 5, 2016
697ac55
Matched changes NetworkSocketAPI
geky Apr 6, 2016
498add7
lwip - fix size of sys mutex for RTX 4.79
0xc0170 Apr 11, 2016
a25aeea
Move to asynch lwip sockets based on armmbed/sal-stack-lwip
geky Mar 13, 2016
41d7277
Remove shutdown parameter from close call
geky Mar 13, 2016
db8495c
Move to single state-change interrupt
geky Mar 13, 2016
e47bb97
Renamed NetworkInterface create/destroy methods to match Socket methods
geky Mar 13, 2016
1aa0b6c
Added better support for SocketAddress/string addresses/ports
geky Mar 13, 2016
e51f157
Revised stack specific configurations
geky Mar 13, 2016
3850933
Standardized comment style
geky Apr 19, 2016
def3b40
Rename Interface -> Stack
geky Apr 19, 2016
a7c0799
Separate Stack/Interface concept into two distinct classes
geky Apr 20, 2016
0d0d008
Match changes to NSAPI in LWIPInterface
geky May 10, 2016
a263b91
Add rudimentary support for server side
geky May 10, 2016
c9d0447
Incrase netif_up semaphore timeout from 1500ms to 2500ms
urutva May 26, 2016
59f444f
Remove hal
c1728p9 May 25, 2016
3b32e53
Pull in lwip-eth updates from mbedmicro/mbed
c1728p9 May 25, 2016
05b21d7
Fixed uninitialized port in lwip dragged in by KSDK2
geky Jun 7, 2016
b251c59
Added support for NSAPI_KEEPALIVE in LWIPInterface
geky Jun 7, 2016
864c73b
Implement the NSAPI_KEEPINTVL in the LWIPInterface
geky Jun 8, 2016
5334934
Added NSAPI_KEEPIDLE option to the socket API and LWIPInterface
geky Jun 8, 2016
9eac510
Fixed behaviour of get_ip_address and get_mac_address for LWIPInterface
geky Jun 9, 2016
df5c05f
Added handling for already connected sockets in LWIPInterface::connect
geky Jun 9, 2016
d82bbb1
Fixed incorrect semaphore handling on lwip connect and socket_connect
geky Jun 10, 2016
68365a9
Increased lwip connect timeout to 5 seconds by default
geky Jun 10, 2016
f4e3ab4
add IAR placement for LPC1768 and lwip buffers
sg- Jun 11, 2016
89d02fa
added default placement macro for all boards and toolchains
sg- Jun 11, 2016
3fe5d32
Fix LPC1768 tests
c1728p9 Jun 12, 2016
6762ead
add lwip to all c files that come from the lwip codebase to reduce du…
sg- Jun 26, 2016
35ca7d1
Separate interface from stack for ethernet
c1728p9 Jun 24, 2016
59a1829
Workshop st: Add IPV4 feature to NUCLEO_F746ZG platform (#438)
adustm Jul 14, 2016
41629b4
Added stddef.h include to cc.h in lwip for size_t define
geky Jul 19, 2016
004750b
Move to lwip netconn api to correctly synchronize multiple threads
geky Jun 30, 2016
3b20e4b
Moved to static declaration of LWIPStack and refactored a bit
geky Jun 30, 2016
c412a0c
Adopted SingletonPtr to avoid vtable leak in lwip
geky Jul 18, 2016
f49aa23
Adopted nsapi header in lwip
geky Jul 19, 2016
a40c23d
Adopted the nsapi_socket_t type in lwip
geky Jul 20, 2016
63e816f
Adopted nsapi_stack_t in lwip
geky Jul 20, 2016
1fcc023
Add 'features/net/FEATURE_IPV4/lwip-interface/' from commit '63e816f0…
geky Jul 22, 2016
ebf42f0
Add includes so lwip compiles
c1728p9 Jul 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions features/net/FEATURE_IPV4/lwip-interface/EthernetInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* LWIP implementation of NetworkInterfaceAPI
* Copyright (c) 2015 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "EthernetInterface.h"
#include "lwip_stack.h"


/* Interface implementation */
int EthernetInterface::connect()
{
return lwip_bringup();
}

int EthernetInterface::disconnect()
{
lwip_bringdown();
return 0;
}

const char *EthernetInterface::get_ip_address()
{
return lwip_get_ip_address();
}

const char *EthernetInterface::get_mac_address()
{
return lwip_get_mac_address();
}

NetworkStack *EthernetInterface::get_stack()
{
return nsapi_create_stack(&lwip_stack);
}
63 changes: 63 additions & 0 deletions features/net/FEATURE_IPV4/lwip-interface/EthernetInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* LWIP implementation of NetworkInterfaceAPI
* Copyright (c) 2015 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ETHERNET_INTERFACE_H
#define ETHERNET_INTERFACE_H

#include "nsapi.h"
#include "rtos.h"
#include "lwip/netif.h"

// Forward declaration
class NetworkStack;


/** EthernetInterface class
* Implementation of the NetworkStack for LWIP
*/
class EthernetInterface : public EthInterface
{
public:
/** Start the interface
* @return 0 on success, negative on failure
*/
virtual int connect();

/** Stop the interface
* @return 0 on success, negative on failure
*/
virtual int disconnect();

/** Get the internally stored IP address
* @return IP address of the interface or null if not yet connected
*/
virtual const char *get_ip_address();

/** Get the internally stored MAC address
* @return MAC address of the interface
*/
virtual const char *get_mac_address();

protected:
/** Provide access to the underlying stack
*
* @return The underlying network stack
*/
virtual NetworkStack *get_stack();
};


#endif
41 changes: 41 additions & 0 deletions features/net/FEATURE_IPV4/lwip-interface/eth_arch.h
Original file line number Diff line number Diff line change
@@ -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_

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "fsl_port.h"

/*******************************************************************************
* Code
******************************************************************************/
void k64f_init_eth_hardware(void)
{
port_pin_config_t configENET = {0};

/* Disable MPU. */
MPU->CESR &= ~MPU_CESR_VLD_MASK;

CLOCK_EnableClock(kCLOCK_PortC);
CLOCK_EnableClock(kCLOCK_PortB);
/* Affects PORTC_PCR16 register */
PORT_SetPinMux(PORTC, 16u, kPORT_MuxAlt4);
/* Affects PORTC_PCR17 register */
PORT_SetPinMux(PORTC, 17u, kPORT_MuxAlt4);
/* Affects PORTC_PCR18 register */
PORT_SetPinMux(PORTC, 18u, kPORT_MuxAlt4);
/* Affects PORTC_PCR19 register */
PORT_SetPinMux(PORTC, 19u, kPORT_MuxAlt4);
/* Affects PORTB_PCR1 register */
PORT_SetPinMux(PORTB, 1u, kPORT_MuxAlt4);

configENET.openDrainEnable = kPORT_OpenDrainEnable;
configENET.mux = kPORT_MuxAlt4;
configENET.pullSelect = kPORT_PullUp;
/* Ungate the port clock */
CLOCK_EnableClock(kCLOCK_PortA);
/* Affects PORTB_PCR0 register */
PORT_SetPinConfig(PORTB, 0u, &configENET);

/* Affects PORTA_PCR13 register */
PORT_SetPinMux(PORTA, 13u, kPORT_MuxAlt4);
/* Affects PORTA_PCR12 register */
PORT_SetPinMux(PORTA, 12u, kPORT_MuxAlt4);
/* Affects PORTA_PCR14 register */
PORT_SetPinMux(PORTA, 14u, kPORT_MuxAlt4);
/* Affects PORTA_PCR5 register */
PORT_SetPinMux(PORTA, 5u, kPORT_MuxAlt4);
/* Affects PORTA_PCR16 register */
PORT_SetPinMux(PORTA, 16u, kPORT_MuxAlt4);
/* Affects PORTA_PCR17 register */
PORT_SetPinMux(PORTA, 17u, kPORT_MuxAlt4);
/* Affects PORTA_PCR15 register */
PORT_SetPinMux(PORTA, 15u, kPORT_MuxAlt4);
/* Affects PORTA_PCR28 register */
PORT_SetPinMux(PORTA, 28u, kPORT_MuxAlt4);

/* Select the Ethernet timestamp clock source */
CLOCK_SetEnetTime0Clock(0x2);
}

/*******************************************************************************
* EOF
******************************************************************************/


Loading