Skip to content

Code example to demonstrate the use of a small and simple HTTP server code that comes with Wiznet's ioDriver package.

Notifications You must be signed in to change notification settings

avinash-gupta-in/stm32f051-w5500-simple-http-server

Repository files navigation

STM32 W5500 HTTP WebServer Example

The Wiznet IO (Ethernet Offload) library comes with a simple and small HTTP web server code. In this chapter we will understand its structure and working. Then we will use it to serve a small webpage from our STM32 to a web browser that is running on our PC.

W5500 Web Server

The HTTP Server Init function takes the number of sockets to use and an array of socket IDs. So, we define some constants and this array.

#define MAX_HTTPSOCK	6
uint8_t socknumlist[] = {2, 3, 4, 5, 6, 7};

The init function also need two statically allocated data buffers, one for RX and one for TX, both are 1KB long in the example program.

//name of this macro is important as it is used by httpservr module
#define DATA_BUF_SIZE 1024 //Both Rx and Tx
///////////////////////////////////////////////////////////////////////////
// Static Buffer for HTTP Server
///////////////////////////////////////////////////////////////////////////
uint8_t http_rx_buff[DATA_BUF_SIZE];
uint8_t http_tx_buff[DATA_BUF_SIZE];

Initialize the HTTP Server

httpServer_init(http_tx_buff, http_rx_buff, MAX_HTTPSOCK, socknumlist);
reg_httpServer_cbfunc(NULL, NULL);

Hardware Details

w5500 module STM32 Discovery Kit

The code is written to run on a STM32F051 ARM Cortex M0 MCU. The W5500 is attached to the SPI Port and shown in table below.

W5500 STM32
MISO PA6
MOSI PA7
SCLK PA5
SCS PA1
RST PA0
INT NC

NC=No Connection SCS=Chip Select (Active Low)

To view the debug output of the program we need a USB to Serial convertor like FT232RL (3.3V Version only) The debug messages comes out on the TX pin of the USART2 peripheral of the STM32F051. This is PA2. The baud rate is 38400. User RealTerm to view the outputs.

real term showing output of http webserver

You will need STM32CubeIDE (Free from ST Microelectronics) to compile, build, flash (burn) and debug this project.

STM32CubeIDE Popup

More information

To learn more about w5500 Ethernet controller and its interface with STM32, please subsribe to our course on Udemy. Udemy's course on W5500 Interfacing

About

Code example to demonstrate the use of a small and simple HTTP server code that comes with Wiznet's ioDriver package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published