Ethernet management for the standalone lwIP example.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include "board.h"
#include "ethernet_sam.h"
#include "gmac.h"
#include "ethernet_phy.h"
#include "timer_mgt_sam.h"
#include "sysclk.h"
#include "lwip/sys.h"
#include "lwip/api.h"
#include "lwip/tcp.h"
#include "lwip/tcpip.h"
#include "lwip/memp.h"
#include "lwip/dhcp.h"
#include "lwip/dns.h"
#include "lwip/stats.h"
#include "lwip/init.h"
#include "lwip/ip_frag.h"
#include "lwip/inet.h"
#include "lwip/tcp_impl.h"
#include "netif/etharp.h"
#include "netif/sam4e_gmac.h"
Data Structures | |
struct | timers_info |
Timer for calling lwIP tmr functions without system. More... | |
Macros | |
#define | TRACE_DEBUG(...) |
Typedefs | |
typedef struct timers_info | timers_info_t |
Timer for calling lwIP tmr functions without system. More... | |
Functions | |
static void | ethernet_configure_interface (void) |
Set ethernet config. More... | |
void | ethernet_task (void) |
Periodically retrigger timeout process. More... | |
void | init_ethernet (void) |
Create ethernet task, for ethernet management. More... | |
void | status_callback (struct netif *netif) |
Status callback used to print address given by DHCP. More... | |
static void | timers_update (void) |
Process timing functions. More... | |
Variables | |
int8_t | g_c_ipconfig [] |
uint32_t | g_ip_mode |
IP mode: 0 unselected, 1 static, 2 dhcp. More... | |
struct netif | gs_net_if |
Global variable containing MAC Config (hw addr, IP, GW, ...) More... | |
static timers_info_t | gs_timers_table [] |
LwIP tmr functions list. More... | |
#define TRACE_DEBUG | ( | ... | ) |
Referenced by ethernet_configure_interface(), and status_callback().
typedef struct timers_info timers_info_t |
Timer for calling lwIP tmr functions without system.
|
static |
Set ethernet config.
Default ip addr
Default subnet mask
Default gateway addr
Add data to netif
Make it the default interface
Setup callback function for netif status change
Bring it up
DHCP mode
Static mode
References ip_addr::addr, ERR_OK, ethernetif_init(), g_ip_mode, gs_net_if, IP4_ADDR, netif_add(), netif_set_default(), netif_set_up(), NULL, status_callback(), and TRACE_DEBUG.
Referenced by init_ethernet().
void ethernet_task | ( | void | ) |
Periodically retrigger timeout process.
Manage the ethernet packets, if any received process them.
Process incoming ethernet frames, then update timers.
After managing the lwIP timers. trigger corresponding ethernet process.
References ethernetif_input(), gs_net_if, and timers_update().
void init_ethernet | ( | void | ) |
Create ethernet task, for ethernet management.
Initialize the ethernet interface.
Initialize the lwIP TCP/IP stack with the network interface driver.
Initialize lwIP
Set hw and IP parameters, initialize MAC too
References ethernet_configure_interface(), http_init(), and lwip_init().
void status_callback | ( | struct netif * | netif | ) |
Status callback used to print address given by DHCP.
Callback function used to print the given IP address when the link is up.
netif | Instance to network interface. |
References g_c_ipconfig, g_ip_mode, inet_ntoa, netif::ip_addr, netif_is_up, and TRACE_DEBUG.
|
static |
Process timing functions.
References gs_timers_table, sys_get_ms(), timers_info::timer, timers_info::timer_func, and timers_info::timer_interval.
Referenced by ethernet_task().
int8_t g_c_ipconfig[] |
Referenced by gfx_task(), and status_callback().
uint32_t g_ip_mode |
IP mode: 0 unselected, 1 static, 2 dhcp.
Referenced by ethernet_configure_interface(), event_handler(), gfx_task(), qtouch_task(), and status_callback().
struct netif gs_net_if |
Global variable containing MAC Config (hw addr, IP, GW, ...)
|
static |
LwIP tmr functions list.
Referenced by timers_update().