STM32F4: FreeRTOS OS + LwIP Wi-Fi FMAC Driver Example

This demo example runs the Wi-Fi FMAC driver to communicate with the WF200/WFM200 Silicon Labs Wi-Fi transceivers. The example includes the LwIP IP stack, a Web server, DHCP client and server, and a TCP iPerf server/client implementation. This example is a FreeRTOS OS-based implementation of the FMAC driver.

Requirements

Hardware Requirements

Software Requirements

In addition to the previous hardware, a user needs software listed below:

Getting Started

After you have the above resources, follow the steps described below (you can refer to the image below):

  1. Connect the Arduino/Nucleo interposer board to the NUCLEO-F429ZI board.
  2. Connect the WF200 expansion kit to the Arduino/Nucleo interposer board.
  3. Make sure the "Power" switch on the WF200 expansion kit is in the "On Board LDO" position.
  4. Select SPI or SDIO on the bus switch depending on the bus you want to use.
  5. Connect the NUCLEO board to your PC using the USB cable. The board should appear as a mass storage device named "NODE_F429ZI".

Using the Binary Files

The first option to run the demo is to use the precompiled binaries provided under wfx-fullMAC-tools/Examples/STM32/Projects/WF200_driver_F429ZI_FreeRTOS-LwIP/Binaries/. Depending on the bus selected on the switch, choose the corresponding binary file:

To use this method, drag-and-drop or copy the WF200_driver_F429ZI_FreeRTOS-LwIP_xxx.bin file to the "NODE_F429ZI" mass storage. After the STM32 is successfully flashed, jump to the Using the Demo section.

Compiling the Project

Alternatively, you can use your preferred IDE to compile and flash the project into the NUCLEO board.

  1. Open the project with either IAR or TrueSTUDIO IDEs.
  2. Select the bus configuration (SPI or SDIO). Make sure it matches the switch position on the WF200 EXP board.
  3. To modify the default Wi-Fi settings, open the header file WF200_driver_F429ZI_FreeRTOS-LwIP/Inc/lwip_freertos.h. Using the defines, change the information used by the example and the default mode in which the WF200 starts (station or softAP mode).
#define SOFT_AP_MODE_DEFAULT    1 ///< If set to 1, default Wi-Fi is softAP mode (requires static IP)
#define USE_DHCP_CLIENT_DEFAULT 0 ///< If defined, DHCP is enabled, otherwise static address below is used

#define WLAN_SSID_DEFAULT       "AP_name"                         ///< Wi-Fi SSID for client mode
#define WLAN_PASSKEY_DEFAULT    "passkey"                         ///< Wi-Fi password for client mode
#define WLAN_SECURITY_DEFAULT   WFM_SECURITY_MODE_WPA2_PSK        ///< Wi-Fi security mode for client mode
#define SOFTAP_SSID_DEFAULT     "WF200_AP"                        ///< Wi-Fi SSID for soft AP mode
#define SOFTAP_PASSKEY_DEFAULT  "12345678"                        ///< Wi-Fi password for soft AP mode
#define SOFTAP_SECURITY_DEFAULT WFM_SECURITY_MODE_WPA2_PSK        ///< Wi-Fi security for soft AP mode
#define SOFTAP_CHANNEL_DEFAULT  6                                 ///< Wi-Fi channel for soft AP mode
  1. Build the project.
  2. Flash the project to the NUCLEO-F429ZI board.

After the STM32 is successfully flashed, jump to the Using the Demo section.

Using the Demo

  1. Open a serial terminal and connect to the COM port of the NUCLEO board using 115200 bps for speed.
  2. Reset the NUCLEO board using the black button.
  3. You should be prompted in the serial terminal. If you do not enter any key for 5 seconds, the example starts in softAP mode:
Press enter within 5 seconds to configure the demo...

Starting demo...
AP mode
SSID = WF200_AP
Passkey = 12345678
IP address = 192.168.0.1
WF200 init successful
AP started
  1. By default the example starts in the SoftAp mode using the SSID and passkey below:

You can use this information to join the network established by the WF200.

To use the example in station mode, a user has two possibilities. The first is to use the serial terminal to enter the Wi-Fi access point information by pressing "enter" after the example resets.

Press enter within 5 seconds to configure the demo...
"enter key pressed"
Choose mode:
1. Station
2. AP
Type 1 or 2:
"1"
Station mode selected

Enter SSID:
"Access_Point"

Enter passkey:
"password"

Choose security mode:
1. OPEN
2. WEP
3. WPA2 WPA1 PSK
4. WPA2 PSK
"4"

Starting demo...
Station mode
SSID = Access_Point
Passkey = password

WF200 init successful
Connected
IP address : 192.168.  1.244

"Key pressed by user"

The second option is to recompile the project using IAR or TrueSTUDIO IDEs by changing the example configuration in the header file "lwip_freertos.h" as explained in Compiling the Project section. The example behaves the same as in softAP mode with the difference that it needs to connect to a Wi-Fi Access Point and retrieve its IP address using DHCP.

  1. In both cases, a Web page is hosted in the STM32. It gives control over the board LEDs. After the board is connected to an access point or you are connected to the WF200 access point, open a Web browser and either type 192.168.0.1 or the IP address is displayed on the serial interface in case the example acts as station. You should see the Web page below appear.

Toggling the On/Off buttons switches the corresponding LED state and displays a message on the serial interface.

  1. Finally, using the same IP address, you can start an iPerf TCP test between the WF200 and another device. First install iPerf on your machine. After it is installed, call the command below on your machine:
iperf -c [IP address displayed] -i 1

By default, the test is 10 seconds long. After the iPerf test is over, a report is output on the serial interface.

Iperf Client Report:
Duration 10034ms
Bytes transferred 28311576
22568 kbit/s

Additional information

For customer support:

  1. Register on https://www.silabs.com/.
  2. Go to Community & Support → Technical Support → E-mail Support Request.