WebRadioApp  0.1
ETHERNETIF
Collaboration diagram for ETHERNETIF:

Macros

#define IFNAME0   's'
 
#define IFNAME1   't'
 
#define ETH_DMA_TRANSMIT_TIMEOUT   (20U)
 

Functions

 LWIP_MEMPOOL_DECLARE (RX_POOL, 10, sizeof(struct pbuf_custom), "Zero-copy RX PBUF pool")
 
int32_t ETH_PHY_IO_Init (void)
 Initializes the MDIO interface GPIO and clocks. More...
 
int32_t ETH_PHY_IO_DeInit (void)
 De-Initializes the MDIO interface . More...
 
int32_t ETH_PHY_IO_ReadReg (uint32_t DevAddr, uint32_t RegAddr, uint32_t *pRegVal)
 Read a PHY register through the MDIO interface. More...
 
int32_t ETH_PHY_IO_WriteReg (uint32_t DevAddr, uint32_t RegAddr, uint32_t RegVal)
 Write a value to a PHY register through the MDIO interface. More...
 
int32_t ETH_PHY_IO_GetTick (void)
 Get the time in millisecons used for internal PHY driver process. More...
 
void pbuf_free_custom (struct pbuf *p)
 Custom Rx pbuf free callback. More...
 
void Error_Handler (void)
 This function is executed in case of error occurrence. More...
 
void HAL_ETH_MspInit (ETH_HandleTypeDef *ethHandle)
 
void HAL_ETH_MspDeInit (ETH_HandleTypeDef *ethHandle)
 
static void low_level_init (struct netif *netif)
 In this function, the hardware should be initialized. Called from ethernetif_init(). More...
 
static err_t low_level_output (struct netif *netif, struct pbuf *p)
 
static struct pbuf * low_level_input (struct netif *netif)
 
void ethernetif_input (struct netif *netif)
 
static err_t low_level_output_arp_off (struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
 
err_t ethernetif_init (struct netif *netif)
 
u32_t sys_jiffies (void)
 Returns the current time in milliseconds when LWIP_TIMERS == 1 and NO_SYS == 1. More...
 
u32_t sys_now (void)
 Returns the current time in milliseconds when LWIP_TIMERS == 1 and NO_SYS == 1. More...
 
void ethernet_link_check_state (struct netif *netif)
 Check the ETH link state then update ETH driver and netif link accordingly. More...
 

Variables

ETH_HandleTypeDef heth
 
ETH_TxPacketConfig TxConfig
 
lan8742_Object_t LAN8742
 
lan8742_IOCtx_t LAN8742_IOCtx
 

Detailed Description

Macro Definition Documentation

◆ ETH_DMA_TRANSMIT_TIMEOUT

#define ETH_DMA_TRANSMIT_TIMEOUT   (20U)

◆ IFNAME0

#define IFNAME0   's'

◆ IFNAME1

#define IFNAME1   't'

Function Documentation

◆ Error_Handler()

void Error_Handler ( void  )

This function is executed in case of error occurrence.

Return values
None
Here is the caller graph for this function:

◆ ETH_PHY_IO_DeInit()

int32_t ETH_PHY_IO_DeInit ( void  )

De-Initializes the MDIO interface .

Parameters
None
Return values
0if OK, -1 if ERROR

◆ ETH_PHY_IO_GetTick()

int32_t ETH_PHY_IO_GetTick ( void  )

Get the time in millisecons used for internal PHY driver process.

Return values
Timevalue

◆ ETH_PHY_IO_Init()

int32_t ETH_PHY_IO_Init ( void  )

Initializes the MDIO interface GPIO and clocks.

Parameters
None
Return values
0if OK, -1 if ERROR

References heth.

◆ ETH_PHY_IO_ReadReg()

int32_t ETH_PHY_IO_ReadReg ( uint32_t  DevAddr,
uint32_t  RegAddr,
uint32_t *  pRegVal 
)

Read a PHY register through the MDIO interface.

Parameters
DevAddrPHY port address
RegAddrPHY register address
pRegValpointer to hold the register value
Return values
0if OK -1 if Error

References heth.

◆ ETH_PHY_IO_WriteReg()

int32_t ETH_PHY_IO_WriteReg ( uint32_t  DevAddr,
uint32_t  RegAddr,
uint32_t  RegVal 
)

Write a value to a PHY register through the MDIO interface.

Parameters
DevAddrPHY port address
RegAddrPHY register address
RegValValue to be written
Return values
0if OK -1 if Error

References heth.

◆ ethernet_link_check_state()

void ethernet_link_check_state ( struct netif *  netif)

Check the ETH link state then update ETH driver and netif link accordingly.

Parameters
argumentnetif
Return values
None

References heth, and LAN8742.

Here is the caller graph for this function:

◆ 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

References IFNAME0, IFNAME1, low_level_init(), low_level_output(), and low_level_output_arp_off().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ethernetif_input()

void ethernetif_input ( struct netif *  netif)

This function should be called 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

References err, low_level_input(), and p.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HAL_ETH_MspDeInit()

void HAL_ETH_MspDeInit ( ETH_HandleTypeDef *  ethHandle)

ETH GPIO Configuration PG11 ---—> ETH_TX_EN PG12 ---—> ETH_TXD1 PG13 ---—> ETH_TXD0 PC1 ---—> ETH_MDC PA2 ---—> ETH_MDIO PA1 ---—> ETH_REF_CLK PA7 ---—> ETH_CRS_DV PC4 ---—> ETH_RXD0 PC5 ---—> ETH_RXD1

◆ HAL_ETH_MspInit()

void HAL_ETH_MspInit ( ETH_HandleTypeDef *  ethHandle)

ETH GPIO Configuration PG11 ---—> ETH_TX_EN PG12 ---—> ETH_TXD1 PG13 ---—> ETH_TXD0 PC1 ---—> ETH_MDC PA2 ---—> ETH_MDIO PA1 ---—> ETH_REF_CLK PA7 ---—> ETH_CRS_DV PC4 ---—> ETH_RXD0 PC5 ---—> ETH_RXD1

◆ 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

References Error_Handler(), ethernet_link_check_state(), heth, LAN8742, LAN8742_IOCtx, and TxConfig.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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

References heth, p, and pbuf_free_custom().

Here is the call graph for this function:
Here is the caller graph for this function:

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

References ETH_DMA_TRANSMIT_TIMEOUT, heth, p, and TxConfig.

Here is the caller graph for this function:

◆ low_level_output_arp_off()

static err_t low_level_output_arp_off ( struct netif *  netif,
struct pbuf *  q,
const ip4_addr_t *  ipaddr 
)
static

This function has to be completed by user in case of ARP OFF.

Parameters
netifthe lwip network interface structure for this ethernetif
Returns
ERR_OK if ...
Here is the caller graph for this function:

◆ LWIP_MEMPOOL_DECLARE()

LWIP_MEMPOOL_DECLARE ( RX_POOL  ,
10  ,
sizeof(struct pbuf_custom)  ,
"Zero-copy RX PBUF pool"   
)

◆ pbuf_free_custom()

void pbuf_free_custom ( struct pbuf *  p)

Custom Rx pbuf free callback.

Parameters
pbufpbuf to be freed
Return values
None

References p.

Here is the caller graph for this function:

◆ sys_jiffies()

u32_t sys_jiffies ( void  )

Returns the current time in milliseconds when LWIP_TIMERS == 1 and NO_SYS == 1.

Parameters
None
Return values
CurrentTime value

◆ sys_now()

u32_t sys_now ( void  )

Returns the current time in milliseconds when LWIP_TIMERS == 1 and NO_SYS == 1.

Parameters
None
Return values
CurrentTime value

Variable Documentation

◆ heth

ETH_HandleTypeDef heth

< IAR Compiler

◆ LAN8742

lan8742_Object_t LAN8742

◆ LAN8742_IOCtx

lan8742_IOCtx_t LAN8742_IOCtx

◆ TxConfig

ETH_TxPacketConfig TxConfig
ETH_PHY_IO_DeInit
int32_t ETH_PHY_IO_DeInit(void)
De-Initializes the MDIO interface .
Definition: ethernetif.c:609
ETH_PHY_IO_GetTick
int32_t ETH_PHY_IO_GetTick(void)
Get the time in millisecons used for internal PHY driver process.
Definition: ethernetif.c:651
ETH_PHY_IO_ReadReg
int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t *pRegVal)
Read a PHY register through the MDIO interface.
Definition: ethernetif.c:621
ETH_PHY_IO_Init
int32_t ETH_PHY_IO_Init(void)
Initializes the MDIO interface GPIO and clocks.
Definition: ethernetif.c:592
ETH_PHY_IO_WriteReg
int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t RegVal)
Write a value to a PHY register through the MDIO interface.
Definition: ethernetif.c:638