WiFi Host Driver Board Support Package Integration (whd-bsp-integration)
WiFi Initialization

General Description

Macros to abstract out whether the LEDs & Buttons are wired high or active low.

Basic integration code for interfacing the WiFi Host Driver (WHD) with the Board Support Packages (BSPs).

Macros

#define CY_WIFI_THREAD_STACK_SIZE   (5120)
 Defines the amount of stack memory available for the wifi thread.
 
#define CY_WIFI_THREAD_PRIORITY   (CY_RTOS_PRIORITY_HIGH)
 Defines the priority of the thread that services wifi packets. More...
 
#define CY_WIFI_COUNTRY   (WHD_COUNTRY_AUSTRALIA)
 Defines the country this will operate in for wifi initialization parameters. More...
 
#define CY_WIFI_OOB_INTR_PRIORITY   (2)
 Defines the priority of the interrupt that handles out-of-band notifications from the wifi chip. More...
 
#define CY_USE_OOB_INTR   (1u)
 Defines whether to use the out-of-band pin to allow the WIFI chip to wake up the MCU.
 
#define CYBSP_WIFI_WL_REG_ON_GPIO_DRIVE_MODE   (CYHAL_GPIO_DRIVE_PULLUP)
 Default GPIO drive mode for CYBSP_WIFI_WL_REG_ON. More...
 
#define CYBSP_WIFI_WL_HOSTWAKE_DRIVE_MODE   (CYHAL_GPIO_DRIVE_NONE)
 Default GPIO drive mode for CYBSP_WIFI_WL_HOSTWAKE. More...
 
#define CYBSP_WIFI_WL_HOSTWAKE_INIT_STATE   (WHD_FALSE)
 Default GPIO drive mode for CYBSP_WIFI_WL_HOSTWAKE. More...
 
#define CYBSP_RSLT_WIFI_INIT_FAILED    (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 0))
 Initialization of the WiFi driver failed.
 
#define CYBSP_RSLT_WIFI_SDIO_ENUM_TIMEOUT    (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 1))
 SDIO enumeration failed.
 
#define CYBSP_RSLT_WIFI_SDIO_ENUM_IO_NOT_SUPPORTED    (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 2))
 SD device does not support IO functionality.
 
#define CYBSP_RSLT_WIFI_SDIO_ENUM_NOT_READY    (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 3))
 SDIO device is not ready.
 
#define CYBSP_RSLT_WIFI_SDIO_HS_SWITCH_FAILED    (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION, 4))
 SDIO switch to High Speed mode failed.
 

Functions

cy_rslt_t cybsp_wifi_init_primary_extended (whd_interface_t *interface, whd_init_config_t *init_config, whd_resource_source_t *resource_if, whd_buffer_funcs_t *buffer_if, whd_netif_funcs_t *netif_if)
 Initializes the primary interface for the WiFi driver on the board. More...
 
static cy_rslt_t cybsp_wifi_init_primary (whd_interface_t *interface)
 Initializes the primary interface for the WiFi driver on the board using the default configuration, resource, buffer, and network interfaces. More...
 
cy_rslt_t cybsp_wifi_init_secondary (whd_interface_t *interface, whd_mac_t *mac_address)
 This function initializes and adds a secondary interface to the WiFi driver. More...
 
cy_rslt_t cybsp_wifi_deinit (whd_interface_t interface)
 De-initializes all WiFi interfaces and the WiFi driver. More...
 
whd_driver_t cybsp_get_wifi_driver (void)
 Gets the wifi driver instance initialized by the driver. More...
 

Macro Definition Documentation

◆ CY_WIFI_THREAD_PRIORITY

#define CY_WIFI_THREAD_PRIORITY   (CY_RTOS_PRIORITY_HIGH)

Defines the priority of the thread that services wifi packets.

Legal values are defined by the RTOS being used.

◆ CY_WIFI_COUNTRY

#define CY_WIFI_COUNTRY   (WHD_COUNTRY_AUSTRALIA)

Defines the country this will operate in for wifi initialization parameters.

See the wifi-host-driver's whd_country_code_t for legal options.

◆ CY_WIFI_OOB_INTR_PRIORITY

#define CY_WIFI_OOB_INTR_PRIORITY   (2)

Defines the priority of the interrupt that handles out-of-band notifications from the wifi chip.

Legal values are defined by the MCU running this code.

◆ CYBSP_WIFI_WL_REG_ON_GPIO_DRIVE_MODE

#define CYBSP_WIFI_WL_REG_ON_GPIO_DRIVE_MODE   (CYHAL_GPIO_DRIVE_PULLUP)

Default GPIO drive mode for CYBSP_WIFI_WL_REG_ON.

Override with Makefile define

◆ CYBSP_WIFI_WL_HOSTWAKE_DRIVE_MODE

#define CYBSP_WIFI_WL_HOSTWAKE_DRIVE_MODE   (CYHAL_GPIO_DRIVE_NONE)

Default GPIO drive mode for CYBSP_WIFI_WL_HOSTWAKE.

Override with Makefile define

◆ CYBSP_WIFI_WL_HOSTWAKE_INIT_STATE

#define CYBSP_WIFI_WL_HOSTWAKE_INIT_STATE   (WHD_FALSE)

Default GPIO drive mode for CYBSP_WIFI_WL_HOSTWAKE.

Override with Makefile define

Function Documentation

◆ cybsp_wifi_init_primary_extended()

cy_rslt_t cybsp_wifi_init_primary_extended ( whd_interface_t *  interface,
whd_init_config_t *  init_config,
whd_resource_source_t *  resource_if,
whd_buffer_funcs_t *  buffer_if,
whd_netif_funcs_t *  netif_if 
)

Initializes the primary interface for the WiFi driver on the board.

This sets up the WHD interface to use the Buffer management APIs and to communicate over the SDIO interface on the board. This function does the following:
1) Initializes the WiFi driver.
2) Turns on the WiFi chip.

Note
This function cannot be called multiple times. If the interface needs to be reinitialized, cybsp_wifi_deinit must be called before calling this function again.
Parameters
[out]interfaceInterface to be initialized
[in]init_configPointer to the configuration parameters to initialize the driver. Passing NULL will use default values.
[in]resource_ifPointer to resource interface to provide resources to the driver initialization process. Passing NULL will use the default.
[in]buffer_ifPointer to a buffer interface to provide buffer related services to the driver instance. Passing NULL will use the default.
[in]netif_ifPointer to a whd_netif_funcs_t to provide network stack services to the driver instance. Passing NULL will use the default.
Returns
CY_RSLT_SUCCESS for successful initialization or error if initialization failed.

◆ cybsp_wifi_init_primary()

static cy_rslt_t cybsp_wifi_init_primary ( whd_interface_t *  interface)
inlinestatic

Initializes the primary interface for the WiFi driver on the board using the default configuration, resource, buffer, and network interfaces.

See cybsp_wifi_init_primary_extended() for more details.

Parameters
[out]interfaceInterface to be initialized
Returns
CY_RSLT_SUCCESS for successful initialization or error if initialization failed.

◆ cybsp_wifi_init_secondary()

cy_rslt_t cybsp_wifi_init_secondary ( whd_interface_t *  interface,
whd_mac_t *  mac_address 
)

This function initializes and adds a secondary interface to the WiFi driver.

Note
This function does not initialize the WiFi driver or turn on the WiFi chip. That is required to be done by first calling cybsp_wifi_init_primary.
Parameters
[out]interfaceInterface to be initialized
[in]mac_addressMac address for secondary interface
Returns
CY_RSLT_SUCCESS for successful initialization or error if initialization failed.

◆ cybsp_wifi_deinit()

cy_rslt_t cybsp_wifi_deinit ( whd_interface_t  interface)

De-initializes all WiFi interfaces and the WiFi driver.

This function does the following:
1) Deinitializes all WiFi interfaces.
2) Deinitializes the WiFi driver.
3) Turns off the WiFi chip.

Parameters
[in]interfaceEither the Primary or Secondary interface.
Returns
CY_RSLT_SUCCESS for successful de-initialization or error if de-initialization failed.

◆ cybsp_get_wifi_driver()

whd_driver_t cybsp_get_wifi_driver ( void  )

Gets the wifi driver instance initialized by the driver.

This should only be called after being initialized by cybsp_wifi_init_primary() and before being deinitialized by cybsp_wifi_deinit(). This is also the only time where the driver reference is valid.

Returns
Wifi driver instance pointer.