Wiznet makers

Aimee0

Published January 02, 2024 ©

17 UCC

12 WCC

8 VAR

0 Contests

0 Followers

0 Following

Original Link

Nucleo-G031 W5500 mongoose

This is a project that uses the mongoose library to perform network communication over the W5500 Ethernet controller.

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION

This is a project that uses the mongoose library to perform network communication over the W5500 Ethernet controller.

What is mongoose?

Mongoose is a lightweight web server and web framework library used in embedded systems and IoT devices. Based on event-based and non-blocking architecture, it supports various protocols such as TCP, UDP, HTTP, WebSocket, and MQTT.

 

#main.c

  // Initialise Mongoose network stack
  spi_init(&spi_pins);
  struct mg_tcpip_spi spi = {
      .begin = (void (*)(void *)) spi_begin,
      .end = (void (*)(void *)) spi_end,
      .txn = (uint8_t(*)(void *, uint8_t)) spi_txn,
      .spi = &spi_pins,
  };
  struct mg_tcpip_if mif = {.mac = GENERATE_LOCALLY_ADMINISTERED_MAC(),
                            // Uncomment below for static configuration:
                            // .ip = mg_htonl(MG_U32(192, 168, 0, 223)),
                            // .mask = mg_htonl(MG_U32(255, 255, 255, 0)),
                            // .gw = mg_htonl(MG_U32(192, 168, 0, 1)),
                            .driver = &mg_tcpip_driver_w5500,
                            .driver_data = &spi};
  mg_tcpip_init(&mgr, &mif);

Initializes SPI and initializes settings for the network interface. If you look at “mif.driver”, it is connected to the mg_tcpip_driver_w5500 structure and the structure is defined in mongose/src/drivers/w5500.c.
 

  for (;;) {
    mg_mgr_poll(&mgr, 0);
  }

Continue polling the Event Manager in the for(;;).

 

 

 

 

Documents
  • mongoose

Comments Write