HPM APP
HPMicro Application solution
ethernetif.c File Reference
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "netif/etharp.h"
#include "lwip/err.h"
#include "lwip/timeouts.h"
#include "ethernetif.h"
#include "lwip.h"
#include "hpm_enet_drv.h"
#include "board.h"
#include "netconf.h"
#include <string.h>
#include "lwip/netif.h"
#include "FreeRTOS.h"
#include "semphr.h"

Macros

#define netifMTU   (1500)
 
#define netifINTERFACE_TASK_STACK_SIZE   (350)
 
#define netifINTERFACE_TASK_PRIORITY   (configMAX_PRIORITIES - 1)
 
#define netifGUARD_BLOCK_TIME   (250)
 
#define emacBLOCK_TIME_WAITING_FOR_INPUT   ((portTickType)100)
 
#define IFNAME0   'e'
 
#define IFNAME1   'n'
 

Functions

static void low_level_init (struct netif *netif)
 
static err_t low_level_output (struct netif *netif, struct pbuf *p)
 
static struct pbuf * low_level_input (struct netif *netif)
 
void ethernetif_input (void *pvParameters)
 
err_t ethernetif_init (struct netif *netif)
 

Variables

static struct netif * s_pxNetIf = NULL
 
xSemaphoreHandle s_xSemaphore = NULL
 

Detailed Description

Ethernet Interface Skeleton

Macro Definition Documentation

◆ emacBLOCK_TIME_WAITING_FOR_INPUT

#define emacBLOCK_TIME_WAITING_FOR_INPUT   ((portTickType)100)

◆ IFNAME0

#define IFNAME0   'e'

◆ IFNAME1

#define IFNAME1   'n'

◆ netifGUARD_BLOCK_TIME

#define netifGUARD_BLOCK_TIME   (250)

◆ netifINTERFACE_TASK_PRIORITY

#define netifINTERFACE_TASK_PRIORITY   (configMAX_PRIORITIES - 1)

◆ netifINTERFACE_TASK_STACK_SIZE

#define netifINTERFACE_TASK_STACK_SIZE   (350)

◆ netifMTU

#define netifMTU   (1500)

Function Documentation

◆ ethernetif_init()

err_t ethernetif_init ( struct netif *  netif)

Should be called at the beginning of the program to set up the network interface. It calls the function low_level_init() to do the actual setup of the hardware.

This function should be passed as a parameter to netif_add().

Parameters
netifthe lwip network interface structure for this ethernetif
Returns
ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error

◆ ethernetif_input()

void ethernetif_input ( void *  pvParameters)

This function is the ethernetif_input task, it is processed when a packet is ready to be read from the interface. It uses the function low_level_input() that should handle the actual reception of bytes from the network interface. Then the type of the received packet is determined and the appropriate input function is called.

Parameters
netifthe lwip network interface structure for this ethernetif

◆ low_level_init()

static void low_level_init ( struct netif *  netif)
static

In this function, the hardware should be initialized. Called from ethernetif_init().

Parameters
netifthe already initialized lwip network interface structure for this ethernetif

◆ low_level_input()

static struct pbuf* low_level_input ( struct netif *  netif)
static

Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf.

Parameters
netifthe lwip network interface structure for this ethernetif
Returns
a pbuf filled with the received packet (including MAC header) NULL on memory error

◆ low_level_output()

static err_t low_level_output ( struct netif *  netif,
struct pbuf *  p 
)
static

This function should do the actual transmission of the packet. The packet is contained in the pbuf that is passed to the function. This pbuf might be chained.

Parameters
netifthe lwip network interface structure for this ethernetif
pthe MAC packet to send (e.g. IP packet including MAC addresses and type)
Returns
ERR_OK if the packet could be sent an err_t value if the packet couldn't be sent
Note
Returning ERR_MEM here if a DMA queue of your MAC is full can lead to strange results. You might consider waiting for space in the DMA queue to become availale since the stack doesn't retry to send a packet dropped because of memory failure (except for the TCP timers).

Variable Documentation

◆ s_pxNetIf

struct netif* s_pxNetIf = NULL
static

◆ s_xSemaphore

xSemaphoreHandle s_xSemaphore = NULL