Prusa MINI Firmware overview
ethernetif.h File Reference
#include "lwip/err.h"
#include "lwip/netif.h"
#include "cmsis_os.h"

Go to the source code of this file.

Functions

err_t ethernetif_init (struct netif *netif)
 
void ethernetif_input (void const *argument)
 
void ethernetif_update_config (struct netif *netif)
 
void ethernetif_notify_conn_changed (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...
 

Function Documentation

◆ ethernetif_init()

err_t ethernetif_init ( struct netif netif)

File Name : ethernetif.h Description : This file provides initialization code for LWIP 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.

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:

◆ 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:

◆ ethernetif_update_config()

void ethernetif_update_config ( struct netif netif)
Here is the caller graph for this function:

◆ ethernetif_notify_conn_changed()

void ethernetif_notify_conn_changed ( struct netif netif)

◆ 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();

◆ 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
Time
617  {
618  return HAL_GetTick();
LWIP_ASSERT
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
osSemaphoreWait
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
Definition: cmsis_os.c:822
netif::input
netif_input_fn input
Definition: netif.h:244
pbuf_free
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:715
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
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
osOK
function completed; no error or event occurred.
Definition: cmsis_os.h:235
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
netif
Definition: netif.h:225
netif::name
char name[2]
Definition: netif.h:307
IFNAME1
#define IFNAME1
Definition: ethernetif.c:74
s_xSemaphore
osSemaphoreId s_xSemaphore
Definition: ethernetif.c:106
low_level_init
static void low_level_init(struct netif *netif)
Definition: ethernetif.c:243
low_level_input
static struct pbuf * low_level_input(struct netif *netif)
Definition: ethernetif.c:430
ERR_OK
Definition: err.h:63
IFNAME0
#define IFNAME0
Definition: ethernetif.c:73
pbuf
Definition: pbuf.h:142
low_level_output
static err_t low_level_output(struct netif *netif, struct pbuf *p)
Definition: ethernetif.c:352