Initialization and Configuration
The steps described below are implemented inside the FMAC driver in the function sl_wfx_init() . During the initialization, the driver calls functions part of the HOST_API group. Those functions are implemented by the host depending on the MCU, RTOS, the communication bus used, and so on. The initialization phase follows the steps listed below:
- Bus configuration (SPI or SDIO)
- Chip initialization
- Firmware download
- Receive startup indication
- Sending PDS configuration
1. Bus Configuration
The bus configuration is handled by sl_wfx_host_init_bus() function implemented by the host. It has a specific implementation depending on the bus used. More information in the Host Interface (HIF) .
SPI Bus
During the SPI initialization, the host follows the steps below:
- Reset the WFx
- Read the configuration register to make sure the communication with the WF200 is available.
- Write the configuration register with the SPI bus configuration settings preferred (e.g., word mode, high-frequency SPI enabled, and so on).
SDIO Bus
During the SPI initialization, the host follows the steps below:
-
Send SDIO command 0
- Warning
- The host is required to wait a response from this command before issuing another command even if not part of the standard.
- Send SDIO command 8.
- Send SDIO command 3.
- Send SDIO command 7.
- Enable function cmd 53 in CCCR register .
- Enable the interrupt.
- Configure the SDIO bus to function in 4-bit mode.
- Switch to high-speed mode (up to 50 MHz).
- Set the block size used by the host in the FBR register .
2. WFx Initialization
The WFx initialization is handled by sl_wfx_init_chip() . During this phase, the host interacts with the registers described in WF200 Registers .
- The first step performed is to set the correct values in the General purpose registers. Those values are linked to the crystal used by the hardware.
- Set the wake-up bit (bit 12) in the control register .
- Wait for the wlan_rdy bit (bit 13) to be set in the control register .
- Check if the access mode bit (bit 10) in the configuration register is at 1 (direct access mode).
3. Firmware Download
First, the WF200 clock is enabled in sl_wfx_download_run_bootloader() .
The firmware download is handled by sl_wfx_download_run_firmware() . A firmware needs to be loaded in the chip at power-up. The firmware is signed and encrypted. The firmware data is retrieved through the host implemented APIs sl_wfx_host_get_firmware_size() and sl_wfx_host_get_firmware_data() . During the initialization phase, the driver calls sl_wfx_host_get_firmware_size() once to retrieve the size of the firmware image to be loaded. After this is done, the driver calls sl_wfx_host_get_firmware_data() multiple times to retrieve firmware data chunks (the "data_size" parameter being the size requested in byte). Below is a diagram listing the steps followed by sl_wfx_download_run_firmware() to load the firmware.
After the host notifies the "OK_TO_JUMP" state, the WFx chip issues a startup indication when ready.
4. Startup Indication
If the initialization process has been successful up to now, the host receives the startup indication from the chip.
The start up indication is described in the sl_wfx_startup_ind_body_t structure.
5. PDS Configuration
After the startup indication is received, the host can send to WFx chip the PDS configuration (Platform Data Set). The PDS contains information regarding the WFx environment. Below are some examples:
- I/O configuration
- XTAL tune
- TX power control
- RF output configuration
During this phase, the driver calls the functions sl_wfx_host_get_pds_data() and sl_wfx_host_get_pds_size() . The sl_wfx_host_get_pds_size() is used to inform the driver on the number of PDS lines to be sent. Once done, the FMAC driver calls sl_wfx_host_get_pds_data() the number of time requested in sl_wfx_host_get_pds_size() to get the PDS sections. The PDS is sent using a dedicated function sl_wfx_send_configuration() . You can find more information about the PDS in the dedicated page Platform Data Set .