Prusa MINI Firmware overview
ethernetif.c File Reference
#include "main.h"
#include "lwip/opt.h"
#include "lwip/timeouts.h"
#include "netif/ethernet.h"
#include "netif/etharp.h"
#include "lwip/ethip6.h"
#include "ethernetif.h"
#include <string.h>
#include "cmsis_os.h"
#include "lwip/netifapi.h"
#include "otp.h"

Macros

#define TIME_WAITING_FOR_INPUT   (portMAX_DELAY)
 
#define INTERFACE_THREAD_STACK_SIZE   (350)
 
#define IFNAME0   's'
 
#define IFNAME1   't'
 

Functions

void HAL_ETH_MspInit (ETH_HandleTypeDef *ethHandle)
 
void HAL_ETH_MspDeInit (ETH_HandleTypeDef *ethHandle)
 
void HAL_ETH_RxCpltCallback (ETH_HandleTypeDef *heth)
 Ethernet Rx Transfer completed callback. More...
 
void ethernetif_link (const void *arg)
 
static void low_level_init (struct netif *netif)
 
static err_t low_level_output (struct netif *netif, struct pbuf *p)
 
static struct pbuflow_level_input (struct netif *netif)
 
void ethernetif_input (void const *argument)
 
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...
 

Variables

__ALIGN_BEGIN ETH_DMADescTypeDef DMARxDscrTab[ETH_RXBUFNB__ALIGN_END
 
osSemaphoreId s_xSemaphore = NULL
 
ETH_HandleTypeDef heth
 

Macro Definition Documentation

◆ TIME_WAITING_FOR_INPUT

#define TIME_WAITING_FOR_INPUT   (portMAX_DELAY)

File Name : ethernetif.c Description : This file provides code for the configuration of the ethernetif.c MiddleWare.

This notice applies to any and all portions of this file that are not between comment pairs USER CODE BEGIN and USER CODE END. Other portions of this file, whether inserted by the user or by software development tools are owned by their respective copyright owners.

Copyright (c) 2019 STMicroelectronics International N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:

  1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. 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.
  3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software without specific written permission.
  4. This software, including modifications and/or derivative works of this software, must execute solely and exclusively on microcontroller or microprocessor devices manufactured by or for STMicroelectronics.
  5. Redistribution and use of this software other than as permitted under this license is void and will automatically terminate your rights under this license.

THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS 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.

◆ INTERFACE_THREAD_STACK_SIZE

#define INTERFACE_THREAD_STACK_SIZE   (350)

◆ IFNAME0

#define IFNAME0   's'

◆ IFNAME1

#define IFNAME1   't'

Function Documentation

◆ HAL_ETH_MspInit()

void HAL_ETH_MspInit ( ETH_HandleTypeDef *  ethHandle)

ETH GPIO Configuration PC1 ---—> ETH_MDC PA1 ---—> ETH_REF_CLK PA2 ---—> ETH_MDIO PA7 ---—> ETH_CRS_DV PC4 ---—> ETH_RXD0 PC5 ---—> ETH_RXD1 PB11 ---—> ETH_TX_EN PB12 ---—> ETH_TXD0 PB13 ---—> ETH_TXD1

116  {
117  GPIO_InitTypeDef GPIO_InitStruct;
118  if (ethHandle->Instance == ETH) {
119  /* USER CODE BEGIN ETH_MspInit 0 */
120 
121  /* USER CODE END ETH_MspInit 0 */
122  /* Enable Peripheral clock */
123  __HAL_RCC_ETH_CLK_ENABLE();
124 
125  /**ETH GPIO Configuration
126  PC1 ------> ETH_MDC
127  PA1 ------> ETH_REF_CLK
128  PA2 ------> ETH_MDIO
129  PA7 ------> ETH_CRS_DV
130  PC4 ------> ETH_RXD0
131  PC5 ------> ETH_RXD1
132  PB11 ------> ETH_TX_EN
133  PB12 ------> ETH_TXD0
134  PB13 ------> ETH_TXD1
135  */
136  GPIO_InitStruct.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;
137  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
138  GPIO_InitStruct.Pull = GPIO_NOPULL;
139  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
140  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
141  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
142 
143  GPIO_InitStruct.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;
144  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
145  GPIO_InitStruct.Pull = GPIO_NOPULL;
146  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
147  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
148  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
149 
150  GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
151  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
152  GPIO_InitStruct.Pull = GPIO_NOPULL;
153  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
154  GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
155  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
156 
157  /* Peripheral interrupt init */
158  HAL_NVIC_SetPriority(ETH_IRQn, 5, 0);
159  HAL_NVIC_EnableIRQ(ETH_IRQn);
160  /* USER CODE BEGIN ETH_MspInit 1 */
161 
162  /* USER CODE END ETH_MspInit 1 */
163  }
164 }
Here is the call graph for this function:

◆ HAL_ETH_MspDeInit()

void HAL_ETH_MspDeInit ( ETH_HandleTypeDef *  ethHandle)

ETH GPIO Configuration PC1 ---—> ETH_MDC PA1 ---—> ETH_REF_CLK PA2 ---—> ETH_MDIO PA7 ---—> ETH_CRS_DV PC4 ---—> ETH_RXD0 PC5 ---—> ETH_RXD1 PB11 ---—> ETH_TX_EN PB12 ---—> ETH_TXD0 PB13 ---—> ETH_TXD1

166  {
167  if (ethHandle->Instance == ETH) {
168  /* USER CODE BEGIN ETH_MspDeInit 0 */
169 
170  /* USER CODE END ETH_MspDeInit 0 */
171  /* Peripheral clock disable */
172  __HAL_RCC_ETH_CLK_DISABLE();
173 
174  /**ETH GPIO Configuration
175  PC1 ------> ETH_MDC
176  PA1 ------> ETH_REF_CLK
177  PA2 ------> ETH_MDIO
178  PA7 ------> ETH_CRS_DV
179  PC4 ------> ETH_RXD0
180  PC5 ------> ETH_RXD1
181  PB11 ------> ETH_TX_EN
182  PB12 ------> ETH_TXD0
183  PB13 ------> ETH_TXD1
184  */
186 
188 
190 
191  /* Peripheral interrupt Deinit*/
192  HAL_NVIC_DisableIRQ(ETH_IRQn);
193 
194  /* USER CODE BEGIN ETH_MspDeInit 1 */
195 
196  /* USER CODE END ETH_MspDeInit 1 */
197  }
198 }
Here is the call graph for this function:

◆ HAL_ETH_RxCpltCallback()

void HAL_ETH_RxCpltCallback ( ETH_HandleTypeDef *  heth)

Ethernet Rx Transfer completed callback.

Parameters
hethETH handle
Return values
None
205  {
207 }
Here is the call graph for this function:

◆ ethernetif_link()

void ethernetif_link ( const void arg)
210  {
211  struct netif *netif = (struct netif *)arg;
212  uint8_t eth_link;
213  uint32_t phyreg = 0U;
214 
215  while (1) {
216  HAL_ETH_ReadPHYRegister(&heth, PHY_BSR, &phyreg);
217  eth_link = (phyreg & PHY_LINKED_STATUS) == PHY_LINKED_STATUS ? 1 : 0;
218 
219  if (eth_link != netif_is_link_up(netif)) {
220  if (eth_link) {
221  netifapi_netif_set_link_up(netif); // thread safe variant
222  osDelay(5000); // give some time to reconnect
223  } else {
224  netifapi_netif_set_link_down(netif);
225  }
226  }
227 
228  osDelay(200);
229  }
230 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
244  {
245  uint32_t regvalue = 0;
246  HAL_StatusTypeDef hal_eth_init_status;
247 
248  /* Init ETH */
249 
250  heth.Instance = ETH;
251  heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;
252  heth.Init.PhyAddress = LAN8742A_PHY_ADDRESS;
253  // set mac address from OTP memory
254  heth.Init.MACAddr = (uint8_t *)OTP_MAC_ADDRESS_ADDR;
255  heth.Init.RxMode = ETH_RXINTERRUPT_MODE;
256  heth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
257  heth.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII;
258 
259  /* USER CODE BEGIN MACADDRESS */
260 
261  /* USER CODE END MACADDRESS */
262 
263  hal_eth_init_status = HAL_ETH_Init(&heth);
264 
265  if (hal_eth_init_status == HAL_OK) {
266  /* Set netif link flag */
268  }
269  /* Initialize Tx Descriptors list: Chain Mode */
270  HAL_ETH_DMATxDescListInit(&heth, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
271 
272  /* Initialize Rx Descriptors list: Chain Mode */
273  HAL_ETH_DMARxDescListInit(&heth, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
274 
275 #if LWIP_ARP || LWIP_ETHERNET
276 
277  /* set MAC hardware address length */
279 
280  /* set MAC hardware address */
281  netif->hwaddr[0] = heth.Init.MACAddr[0];
282  netif->hwaddr[1] = heth.Init.MACAddr[1];
283  netif->hwaddr[2] = heth.Init.MACAddr[2];
284  netif->hwaddr[3] = heth.Init.MACAddr[3];
285  netif->hwaddr[4] = heth.Init.MACAddr[4];
286  netif->hwaddr[5] = heth.Init.MACAddr[5];
287 
288  /* maximum transfer unit */
289  netif->mtu = 1500;
290 
291  /* Accept broadcast address and ARP traffic */
292  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
293  #if LWIP_ARP
295  #else
297  #endif /* LWIP_ARP */
298 
299  /* create a binary semaphore used for informing ethernetif of frame reception */
300  osSemaphoreDef(SEM);
302 
303  /* create the task that handles the ETH_MAC */
305  osThreadCreate(osThread(EthIf), netif);
306  /* Enable MAC and DMA transmission and reception */
307  HAL_ETH_Start(&heth);
308 
309  /* USER CODE BEGIN PHY_PRE_CONFIG */
310  /* link check */
312  osThreadCreate(osThread(EthIfLink), netif);
313 
314  /* USER CODE END PHY_PRE_CONFIG */
315 
316  /* Read Register Configuration */
317  HAL_ETH_ReadPHYRegister(&heth, PHY_ISFR, &regvalue);
318  regvalue |= (PHY_ISFR_INT4);
319 
320  /* Enable Interrupt on change of link status */
321  HAL_ETH_WritePHYRegister(&heth, PHY_ISFR, regvalue);
322 
323  /* Read Register Configuration */
324  HAL_ETH_ReadPHYRegister(&heth, PHY_ISFR, &regvalue);
325 
326  /* USER CODE BEGIN PHY_POST_CONFIG */
327 
328  /* USER CODE END PHY_POST_CONFIG */
329 
330 #endif /* LWIP_ARP || LWIP_ETHERNET */
331 
332  /* USER CODE BEGIN LOW_LEVEL_INIT */
333 
334  /* USER CODE END LOW_LEVEL_INIT */
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).
353  {
354  err_t errval;
355  struct pbuf *q;
356  uint8_t *buffer = (uint8_t *)(heth.TxDesc->Buffer1Addr);
357  __IO ETH_DMADescTypeDef *DmaTxDesc;
358  uint32_t framelength = 0;
359  uint32_t bufferoffset = 0;
360  uint32_t byteslefttocopy = 0;
361  uint32_t payloadoffset = 0;
362  DmaTxDesc = heth.TxDesc;
363  bufferoffset = 0;
364 
365  /* copy frame from pbufs to driver buffers */
366  for (q = p; q != NULL; q = q->next) {
367  /* Is this buffer available? If not, goto error */
368  if ((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) {
369  errval = ERR_USE;
370  goto error;
371  }
372 
373  /* Get bytes in current lwIP buffer */
374  byteslefttocopy = q->len;
375  payloadoffset = 0;
376 
377  /* Check if the length of data to copy is bigger than Tx buffer size*/
378  while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE) {
379  /* Copy data to Tx buffer*/
380  memcpy((uint8_t *)((uint8_t *)buffer + bufferoffset), (uint8_t *)((uint8_t *)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset));
381 
382  /* Point to next descriptor */
383  DmaTxDesc = (ETH_DMADescTypeDef *)(DmaTxDesc->Buffer2NextDescAddr);
384 
385  /* Check if the buffer is available */
386  if ((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) {
387  errval = ERR_USE;
388  goto error;
389  }
390 
391  buffer = (uint8_t *)(DmaTxDesc->Buffer1Addr);
392 
393  byteslefttocopy = byteslefttocopy - (ETH_TX_BUF_SIZE - bufferoffset);
394  payloadoffset = payloadoffset + (ETH_TX_BUF_SIZE - bufferoffset);
395  framelength = framelength + (ETH_TX_BUF_SIZE - bufferoffset);
396  bufferoffset = 0;
397  }
398 
399  /* Copy the remaining bytes */
400  memcpy((uint8_t *)((uint8_t *)buffer + bufferoffset), (uint8_t *)((uint8_t *)q->payload + payloadoffset), byteslefttocopy);
401  bufferoffset = bufferoffset + byteslefttocopy;
402  framelength = framelength + byteslefttocopy;
403  }
404 
405  /* Prepare transmit descriptors to give to DMA */
406  HAL_ETH_TransmitFrame(&heth, framelength);
407 
408  errval = ERR_OK;
409 
410 error:
411 
412  /* When Transmit Underflow flag is set, clear it and issue a Transmit Poll Demand to resume transmission */
413  if ((heth.Instance->DMASR & ETH_DMASR_TUS) != (uint32_t)RESET) {
414  /* Clear TUS ETHERNET DMA flag */
415  heth.Instance->DMASR = ETH_DMASR_TUS;
416 
417  /* Resume DMA transmission*/
418  heth.Instance->DMATPDR = 0;
419  }
420  return errval;
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
431  {
432  struct pbuf *p = NULL;
433  struct pbuf *q = NULL;
434  uint16_t len = 0;
435  uint8_t *buffer;
436  __IO ETH_DMADescTypeDef *dmarxdesc;
437  uint32_t bufferoffset = 0;
438  uint32_t payloadoffset = 0;
439  uint32_t byteslefttocopy = 0;
440  uint32_t i = 0;
441 
442  /* get received frame */
443  if (HAL_ETH_GetReceivedFrame_IT(&heth) != HAL_OK)
444  return NULL;
445 
446  /* Obtain the size of the packet and put it into the "len" variable. */
447  len = heth.RxFrameInfos.length;
448  buffer = (uint8_t *)heth.RxFrameInfos.buffer;
449 
450  if (len > 0) {
451  /* We allocate a pbuf chain of pbufs from the Lwip buffer pool */
453  }
454 
455  if (p != NULL) {
456  dmarxdesc = heth.RxFrameInfos.FSRxDesc;
457  bufferoffset = 0;
458  for (q = p; q != NULL; q = q->next) {
459  byteslefttocopy = q->len;
460  payloadoffset = 0;
461 
462  /* Check if the length of bytes to copy in current pbuf is bigger than Rx buffer size*/
463  while ((byteslefttocopy + bufferoffset) > ETH_RX_BUF_SIZE) {
464  /* Copy data to pbuf */
465  memcpy((uint8_t *)((uint8_t *)q->payload + payloadoffset), (uint8_t *)((uint8_t *)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
466 
467  /* Point to next descriptor */
468  dmarxdesc = (ETH_DMADescTypeDef *)(dmarxdesc->Buffer2NextDescAddr);
469  buffer = (uint8_t *)(dmarxdesc->Buffer1Addr);
470 
471  byteslefttocopy = byteslefttocopy - (ETH_RX_BUF_SIZE - bufferoffset);
472  payloadoffset = payloadoffset + (ETH_RX_BUF_SIZE - bufferoffset);
473  bufferoffset = 0;
474  }
475  /* Copy remaining data in pbuf */
476  memcpy((uint8_t *)((uint8_t *)q->payload + payloadoffset), (uint8_t *)((uint8_t *)buffer + bufferoffset), byteslefttocopy);
477  bufferoffset = bufferoffset + byteslefttocopy;
478  }
479  }
480 
481  /* Release descriptors to DMA */
482  /* Point to first descriptor */
483  dmarxdesc = heth.RxFrameInfos.FSRxDesc;
484  /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
485  for (i = 0; i < heth.RxFrameInfos.SegCount; i++) {
486  dmarxdesc->Status |= ETH_DMARXDESC_OWN;
487  dmarxdesc = (ETH_DMADescTypeDef *)(dmarxdesc->Buffer2NextDescAddr);
488  }
489 
490  /* Clear Segment_Count */
491  heth.RxFrameInfos.SegCount = 0;
492 
493  /* When Rx Buffer unavailable flag is set: clear it and resume reception */
494  if ((heth.Instance->DMASR & ETH_DMASR_RBUS) != (uint32_t)RESET) {
495  /* Clear RBUS ETHERNET DMA flag */
496  heth.Instance->DMASR = ETH_DMASR_RBUS;
497  /* Resume DMA reception */
498  heth.Instance->DMARPDR = 0;
499  }
500  return p;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ethernetif_input()

void ethernetif_input ( void const argument)

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
512  {
513  struct pbuf *p;
514  struct netif *netif = (struct netif *)argument;
515 
516  for (;;) {
518  do {
519  p = low_level_input(netif);
520  if (p != NULL) {
521  if (netif->input(p, netif) != ERR_OK) {
522  pbuf_free(p);
523  }
524  }
525  } while (p != NULL);
526  }
527  }
Here is the call graph for this function:
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 ...
537  {
538  err_t errval;
539  errval = ERR_OK;
540 
541  /* USER CODE BEGIN 5 */
542 
543  /* USER CODE END 5 */
544 
545  return errval;
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
561  {
562  LWIP_ASSERT("netif != NULL", (netif != NULL));
563 
564 #if LWIP_NETIF_HOSTNAME
565  /* Initialize interface hostname */
566  netif->hostname = "lwip";
567 #endif /* LWIP_NETIF_HOSTNAME */
568 
569  netif->name[0] = IFNAME0;
570  netif->name[1] = IFNAME1;
571  /* We directly use etharp_output() here to save a function call.
572  * You can instead declare your own function an call etharp_output()
573  * from it if you have to do some checks before sending (e.g. if link
574  * is available...) */
575 
576 #if LWIP_IPV4
577  #if LWIP_ARP || LWIP_ETHERNET
578  #if LWIP_ARP
579  netif->output = etharp_output;
580  #else
581  /* The user should write ist own code in low_level_output_arp_off function */
583  #endif /* LWIP_ARP */
584  #endif /* LWIP_ARP || LWIP_ETHERNET */
585 #endif /* LWIP_IPV4 */
586 
587 #if LWIP_IPV6
588  netif->output_ip6 = ethip6_output;
589 #endif /* LWIP_IPV6 */
590 
592 
593  /* initialize the hardware */
595 
596  return ERR_OK;
Here is the call graph for this function:
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
Time
607  {
608  return HAL_GetTick();
Here is the call graph for this function:

Variable Documentation

◆ __ALIGN_END

__ALIGN_BEGIN uint8_t Tx_Buff [ETH_TXBUFNB][ETH_TX_BUF_SIZE] __ALIGN_END

< IAR Compiler

◆ s_xSemaphore

osSemaphoreId s_xSemaphore = NULL

◆ heth

ETH_HandleTypeDef heth
PBUF_POOL
Definition: pbuf.h:123
OTP_MAC_ADDRESS_ADDR
#define OTP_MAC_ADDRESS_ADDR
Definition: otp.h:18
PHY_ISFR_INT4
#define PHY_ISFR_INT4
Definition: stm32f4xx_hal_conf.h:230
GPIO_MODE_AF_PP
#define GPIO_MODE_AF_PP
Definition: stm32f4xx_hal_gpio.h:138
pbuf::len
u16_t len
Definition: pbuf.h:159
auto_build.error
bool error
Definition: auto_build.py:637
osThreadDef
#define osThreadDef(name, thread, priority, instances, stacksz)
Definition: cmsis_os.h:468
HAL_OK
Definition: stm32f4xx_hal_def.h:57
LWIP_ASSERT
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
PBUF_RAW
Definition: pbuf.h:94
RESET
#define RESET
Definition: dac_mcp4728.h:34
osSemaphore
#define osSemaphore(name)
Definition: cmsis_os.h:709
osSemaphoreWait
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
Definition: cmsis_os.c:822
GPIO_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f4xx_hal_gpio.h:68
GPIO_PIN_13
#define GPIO_PIN_13
Definition: stm32f4xx_hal_gpio.h:115
GPIO_PIN_7
#define GPIO_PIN_7
Definition: stm32f4xx_hal_gpio.h:109
netif::input
netif_input_fn input
Definition: netif.h:244
GPIO_PIN_2
#define GPIO_PIN_2
Definition: stm32f4xx_hal_gpio.h:104
NETIF_FLAG_ETHARP
#define NETIF_FLAG_ETHARP
Definition: netif.h:91
netif::hwaddr
u8_t hwaddr[NETIF_MAX_HWADDR_LEN]
Definition: netif.h:303
GPIO_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f4xx_hal_gpio.h:77
i
uint8_t i
Definition: screen_test_graph.c:72
pbuf::next
struct pbuf * next
Definition: pbuf.h:144
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f4xx_hal_gpio.h:71
pbuf_free
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:715
netif::mtu
u16_t mtu
Definition: netif.h:299
HAL_GPIO_DeInit
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
netif::flags
u8_t flags
Definition: netif.h:305
heth
ETH_HandleTypeDef heth
Definition: ethernetif.c:108
TIME_WAITING_FOR_INPUT
#define TIME_WAITING_FOR_INPUT
Definition: ethernetif.c:69
NULL
#define NULL
Definition: usbd_def.h:53
netif::linkoutput
netif_linkoutput_fn linkoutput
Definition: netif.h:255
ETH_TX_BUF_SIZE
#define ETH_TX_BUF_SIZE
Definition: stm32f4xx_hal_conf.h:187
PHY_LINKED_STATUS
#define PHY_LINKED_STATUS
Definition: stm32f4xx_hal_conf.h:220
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
INTERFACE_THREAD_STACK_SIZE
#define INTERFACE_THREAD_STACK_SIZE
Definition: ethernetif.c:71
osSemaphoreCreate
osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, int32_t count)
Create and Initialize a Semaphore object used for managing resources.
Definition: cmsis_os.c:755
osSemaphoreDef
#define osSemaphoreDef(name)
Definition: cmsis_os.h:700
netif_is_link_up
#define netif_is_link_up(netif)
Definition: netif.h:413
pbuf_alloc
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
Definition: pbuf.c:248
GPIO_PIN_12
#define GPIO_PIN_12
Definition: stm32f4xx_hal_gpio.h:114
osOK
function completed; no error or event occurred.
Definition: cmsis_os.h:235
ETH_TXBUFNB
#define ETH_TXBUFNB
Definition: stm32f4xx_hal_conf.h:189
low_level_output_arp_off
static err_t low_level_output_arp_off(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
Definition: ethernetif.c:536
ETH_RXBUFNB
#define ETH_RXBUFNB
Definition: stm32f4xx_hal_conf.h:188
netif
Definition: netif.h:225
netif::hwaddr_len
u8_t hwaddr_len
Definition: netif.h:301
HAL_GPIO_Init
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
GPIO_PIN_1
#define GPIO_PIN_1
Definition: stm32f4xx_hal_gpio.h:103
HAL_NVIC_SetPriority
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
netif::name
char name[2]
Definition: netif.h:307
GPIO_NOPULL
#define GPIO_NOPULL
Definition: stm32f4xx_hal_gpio.h:170
IFNAME1
#define IFNAME1
Definition: ethernetif.c:74
if
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
GPIO_SPEED_FREQ_VERY_HIGH
#define GPIO_SPEED_FREQ_VERY_HIGH
Definition: stm32f4xx_hal_gpio.h:161
ethernetif_input
void ethernetif_input(void const *argument)
Definition: ethernetif.c:511
s_xSemaphore
osSemaphoreId s_xSemaphore
Definition: ethernetif.c:106
LAN8742A_PHY_ADDRESS
#define LAN8742A_PHY_ADDRESS
Definition: stm32f4xx_hal_conf.h:194
low_level_init
static void low_level_init(struct netif *netif)
Definition: ethernetif.c:243
uint8_t
const uint8_t[]
Definition: 404_html.c:3
osPriorityRealtime
priority: realtime (highest)
Definition: cmsis_os.h:224
low_level_input
static struct pbuf * low_level_input(struct netif *netif)
Definition: ethernetif.c:430
ERR_OK
Definition: err.h:63
HAL_NVIC_EnableIRQ
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
err_t
s8_t err_t
Definition: err.h:57
IFNAME0
#define IFNAME0
Definition: ethernetif.c:73
GPIO_PIN_5
#define GPIO_PIN_5
Definition: stm32f4xx_hal_gpio.h:107
osPriorityLow
priority: low
Definition: cmsis_os.h:219
PHY_ISFR
#define PHY_ISFR
Definition: stm32f4xx_hal_conf.h:229
GPIO_InitTypeDef::Pin
uint32_t Pin
Definition: stm32f4xx_hal_gpio.h:65
GPIO_InitTypeDef::Speed
uint32_t Speed
Definition: stm32f4xx_hal_gpio.h:74
HAL_NVIC_DisableIRQ
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
NETIF_FLAG_LINK_UP
#define NETIF_FLAG_LINK_UP
Definition: netif.h:87
PHY_BSR
#define PHY_BSR
Definition: stm32f4xx_hal_conf.h:206
ERR_USE
Definition: err.h:79
ETH_HWADDR_LEN
#define ETH_HWADDR_LEN
Definition: ethernet.h:50
GPIO_PIN_11
#define GPIO_PIN_11
Definition: stm32f4xx_hal_gpio.h:113
ethernetif_link
void ethernetif_link(const void *arg)
Definition: ethernetif.c:210
pbuf
Definition: pbuf.h:142
ETH_RX_BUF_SIZE
#define ETH_RX_BUF_SIZE
Definition: stm32f4xx_hal_conf.h:186
low_level_output
static err_t low_level_output(struct netif *netif, struct pbuf *p)
Definition: ethernetif.c:352
osThreadCreate
osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *argument)
Create a thread and add it to Active Threads and set it to state READY.
Definition: cmsis_os.c:245
GPIO_InitTypeDef
GPIO Init structure definition.
Definition: stm32f4xx_hal_gpio.h:63
pbuf::payload
void * payload
Definition: pbuf.h:147
osSemaphoreRelease
osStatus osSemaphoreRelease(osSemaphoreId semaphore_id)
Release a Semaphore token.
Definition: cmsis_os.c:862
osThread
#define osThread(name)
Definition: cmsis_os.h:478
NETIF_FLAG_BROADCAST
#define NETIF_FLAG_BROADCAST
Definition: netif.h:81
GPIO_PIN_4
#define GPIO_PIN_4
Definition: stm32f4xx_hal_gpio.h:106