To avoid above condition, you have to call the WCM APIs from a task created using the “xTaskCreate” like in Code Snippet 2. You need to initialize WCM library by calling “cy_wcm_init” before calling any other WCM API.
Snippet 1:
#include "cy_wcm.h"
int main(void)
{
// Your code
cy_rslt_t result;
cy_wcm_config_t config;
config.interface = CY_WCM_INTERFACE_TYPE_AP;
// Initialize Wi-Fi connection manager
result = cy_wcm_init(&config);
// Your code
}
Snippet 2:
#include "cy_wcm.h"
TaskHandle_t Task_handle;
#define Task_stack_size (2048u)
#define Task_priority (3u)
int main(void)
{
// Your code
xTaskCreate(Task_code, ”Task name”, Task_stack_size, NULL, Task_priority, Task_handle);
// Start the FreeRTOS scheduler
vTaskStartScheduler();
// Should never get here
CY_ASSERT(0);
}
void Task_code(void *args)
{
// Your code
cy_rslt_t result;
cy_wcm_config_t config;
config.interface = CY_WCM_INTERFACE_TYPE_AP;
// Initialize Wi-Fi connection manager
result = cy_wcm_init(&config);
// Your code
}