Microchip® Advanced Software Framework

ethernet_sam.c File Reference

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"
#include "httpd.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 (   ...)

typedef struct timers_info timers_info_t

Timer for calling lwIP tmr functions without system.

static void ethernet_configure_interface ( void  )
static
void ethernet_task ( void  )

Periodically retrigger timeout process.

Manage the ethernet packets, if any received process them.

After managing the lwIP timers. trigger corresponding ethernet process.

References ethernetif_input(), gs_net_if, and timers_update().

Referenced by webserver_task().

void init_ethernet ( void  )

Create ethernet task, for ethernet management.

Initialize the ethernet interface.

Initialize lwIP

Set hw and IP parameters, initialize MAC too

Bring up the web server

References ethernet_configure_interface(), http_init(), and lwip_init().

Referenced by gfx_task().

void status_callback ( struct netif netif)

Status callback used to print address given by DHCP.

Parameters
netifInstance to network interface.

References g_c_ipconfig, g_ip_mode, inet_ntoa, netif::ip_addr, netif_is_up, and TRACE_DEBUG.

Referenced by ethernet_configure_interface(), and netif_set_status_callback().

static void timers_update ( void  )
static

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, ...)

Referenced by ethernet_configure_interface(), and ethernet_task().

timers_info_t gs_timers_table[]
static
Initial value:
= {
}
#define DHCP_COARSE_TIMER_MSECS
period (in milliseconds) of the application calling dhcp_coarse_tmr()
Definition: dhcp.h:21
#define IP_TMR_INTERVAL
Definition: ip_frag.h:49
void ip_reass_tmr(void)
Reassembly timer base function for both NO_SYS == 0 and 1 (!).
Definition: ip_frag.c:122
#define ARP_TMR_INTERVAL
5 seconds period
Definition: etharp.h:135
void etharp_tmr(void)
Clears expired entries in the ARP table.
Definition: etharp.c:206
void tcp_tmr(void)
Called periodically to dispatch TCP timers.
Definition: tcp.c:141
void dhcp_coarse_tmr()
The DHCP timer that checks for lease renewal/rebind timeouts.
Definition: dhcp.c:337
void dhcp_fine_tmr()
DHCP transaction timeout handling.
Definition: dhcp.c:369
#define DHCP_FINE_TIMER_MSECS
period (in milliseconds) of the application calling dhcp_fine_tmr()
Definition: dhcp.h:23
#define TCP_TMR_INTERVAL
Definition: tcp_impl.h:117

LwIP tmr functions list.

Referenced by timers_update().