CC3200 module first article - wlan_ap routine test[Copy link]
1. This time, Lierda's CC3200 module is used. The CC3200 main clock is 80M. There is no internal flash and an external SPI Flash must be connected. This test uses Lierda Technology's CC3200 baseboard and module (left). Burn and connect the 6 lines of VCC, GND, RXD, TXD, SOP2, and RST to complete the download. SOP2 needs to be pulled up when the serial port is downloading, and SOP2 is left blank during normal operation.
2. Use the IAR tool to open the project and look at the main code. I don't understand what the VStartSimpleLinkSpawnTask function is? SimpleLink is a registered trademark of TI. CC3200 is CC3200SimpleLinkWi-Fi Copy code 1 void main() 2 { 3 long lRetVal = -1; 4 // Board initialization configuration 5 BoardInit(); 6 // Pin multiplexing configuration 7 PinMuxConfig(); 8 // Initialize the port 9 InitTerm(); 10 // Start SimpleLink Host 11 lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); 12 if(lRetVal < 0) 13 { 14 ERR_PRINT(lRetVal); 15 LOOP_FOREVER(); 16 } 17 // Start WlanAPMode task 18 lRetVal = osi_TaskCreate( WlanAPMode, \ 19 (const signed char*)"wireless LAN in AP mode", \ 20 OSI_STACK_SIZE, NULL, 1, NULL ); 21 if(lRetVal < 0) 22 { 23 ERR_PRINT(lRetVal); 24 LOOP_FOREVER(); 25 } 26 // Start task scheduling 27 osi_start(); 28 } Copy code 3. Go deep into the first function to see what it does. It creates a queue and a task. Currently, we don’t know what the task is used for. Secondly, where is the 2048 task space allocated from? As the stack space, the current environment variables of the task are saved when the task is switched. Copy code 1 OsiReturnVal_e VStartSimpleLinkSpawnTask(unsigned portBASE_TYPE uxPriority) 2 { 3 xSimpleLinkSpawnQueue = xQueueCreate( slQUEUE_SIZE, sizeof( tSimpleLinkSpawnMsg ) ); 4 if(0 == xSimpleLinkSpawnQueue) 5 { 6 return OSI_OPERATION_FAILED; 7 } 8 if(pdPASS == xTaskCreate( vSimpleLinkSpawnTask, ( portCHAR * ) "SLSPAWN",\ 9 (2048/sizeof( portSTACK_TYPE )), NULL, uxPriority, &xSimpleLinkSpawnTaskHndl )) 10 { 11 return OSI_OK; 12 } 13 return OSI_OPERATION_FAILED; 14 } Copy code 4. Extend a question, are the temporary variables and data in the task and the malloc in the task allocated from the stack allocated when the task is created? The book says it is stack space, and malloc is allocated from the heap. The unit of 2048/sizeof(portSTACK_TYPE) is word, 4 bytes, so it should be multiplied by 4 in reality. 5. STM32 has 2 stack pointers, MSP and PSP, one is the system stack pointer MSP, and the other is the task stack pointer PSP. What is the task stack used for? Save local variables, nest functions, save kernel registers (saved at the high address of the stack) and the current state of the task (local variables are saved at the low address) when switching tasks. How should the stack size be calculated? The local variables in the task are saved in the task stack. 6. Continue to look at this code, keep looping the receiving queue, tSimpleLinkSpawnMsg Msg; This should be the message queue returned to the application processor by the wifi network processor. This structure has 2 parameters, a function and a data, both of which are transmitted through the queue. Copy code 1 void vSimpleLinkSpawnTask(void *pvParameters) 2 { 3 tSimpleLinkSpawnMsg Msg; 4 portBASE_TYPE ret=pdFAIL; 5 for(;;) 6 { 7 ret = xQueueReceive( xSimpleLinkSpawnQueue, &Msg, portMAX_DELAY ); 8 if(ret == pdPASS) 9 { 10 Msg.pEntry(Msg.pValue); 11 } 12 } 13 } Copy code 7. Look at the setting code of AP mode Copy code void WlanAPMode( void *pvParameters ) { int iTestResult = 0; unsigned char ucDHCP; long lRetVal = -1; InitializeAppVariables(); //Restore to default mode lRetVal = ConfigureSimpleLinkToDefaultState(); if(lRetVal < 0) { if (DEVICE_NOT_IN_STATION_MODE == lRetVal) UART_PRINT("Failed to configure the device in its default state \n\r"); LOOP_FOREVER(); } UART_PRINT("Device is configured in default state \n\r"); //Start the network lRetVal = sl_Start(NULL,NULL,NULL); if (lRetVal < 0) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(); } UART_PRINT("Device started as STATION \n\r"); //Configure to AP modeif(lRetVal != ROLE_AP) { if(ConfigureMode(lRetVal) != ROLE_AP) { sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); } } //In AP mode, whether to obtain its own IP addresswhile(!IS_IP_ACQUIRED(g_ulStatus)) { //looping till ip is acquired } unsigned char len = sizeof(SlNetCfgIpV4Args_t); SlNetCfgIpV4Args_t ipV4 = {0}; // Get network configurationlRetVal = sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&ucDHCP,&len, (unsigned char *)&ipV4); if (lRetVal < 0) { UART_PRINT("Failed to get network configuration \n\r"); LOOP_FOREVER(); } //Wait for STA device to connect and assign IP address to STA while(!IS_IP_LEASED(g_ulStatus)) { } //Establish TCP connection with STA device lRetVal = BsdTcpClient(PORT_NUM); if(lRetVal < 0) { UART_PRINT("TCP Client failed\n\r"); LOOP_FOREVER(); } while(1); } Copy code to view the setting function of AP mode Copy code 1 static int ConfigureMode(int iMode) 2 { 3 char pcSsidName[33] = "cc3200_tcptest"; 4 long lRetVal = -1; 5 6 //Set to AP mode 7 lRetVal = sl_WlanSetMode(ROLE_AP); 8 ASSERT_ON_ERROR(lRetVal); 9 //Set the SSID of AP mode 10 lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName), 11 (unsigned char*)pcSsidName); 12 ASSERT_ON_ERROR(lRetVal); 13 14 UART_PRINT("Device is configured in AP mode\n\r"); 15 16 /* Restart Network processor */ 17 lRetVal = sl_Stop(SL_STOP_TIMEOUT); 18 19 // reset status bits 20 CLR_STATUS_BIT_ALL(g_ulStatus); 21 return sl_Start(NULL,NULL,NULL); 22 } Copy code 8. This project contains 3 library files, among which simplelink.a is quite special. Find this related project in SDK and open it. The question is what does sl_start start? How does it communicate with the WiFi network processor? 1 $PROJ_DIR$/../../../simplelink/ewarm/OS/Exe/simplelink.a 2 $PROJ_DIR$/../../../driverlib/ewarm/Release/Exe/driverlib.a 3 $PROJ_DIR$/../../../oslib/ewarm/free_rtos/Exe/free_rtos.a 9. Continue to the next step Copy code 1 _i16 sl_WlanSetMode(const _u8 mode) 2 { 3 _SlwlanSetModeMsg_u Msg; 4 Msg.Cmd.mode = mode; 5 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 6 return (_i16)Msg.Rsp.status; 7 } Copy code 10. Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 // Take sl_WlanSet as an example, call it layer by layer, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to set up a TCP server on the computer to test it. The previous test of CC3200's TCP transmission speed was only 100KB per second. I don't know the reason. I will test it again when I have the chance.IS_IP_ACQUIRED(g_ulStatus)) { //looping till ip is acquired } unsigned char len = sizeof(SlNetCfgIpV4Args_t); SlNetCfgIpV4Args_t ipV4 = {0}; // Get network configuration lRetVal = sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&ucDHCP,&len, (unsigned char *)&ipV4); if (lRetVal < 0) { UART_PRINT("Failed to get network configuration \n\r"); LOOP_FOREVER(); } //Wait for STA device to connect and assign IP address to STA while(!IS_IP_LEASED(g_ulStatus)) { } //Establish TCP connection with STA device lRetVal = BsdTcpClient(PORT_NUM); if(lRetVal < 0) { UART_PRINT("TCP Client failed\n\r"); LOOP_FOREVER(); } while(1); } Copy the code to view the setting function of AP mode Copy code 1 static int ConfigureMode(int iMode) 2 { 3 char pcSsidName[33] = "cc3200_tcptest"; 4 long lRetVal = -1; 5 6 //Set to AP mode 7 lRetVal = sl_WlanSetMode(ROLE_AP); 8 ASSERT_ON_ERROR(lRetVal); 9 //Set SSID of AP mode 10 lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName), 11 (unsigned char*)pcSsidName); 12 ASSERT_ON_ERROR(lRetVal); 13 14 UART_PRINT("Device is configured in AP mode\n\r"); 15 16 /* Restart Network processor */ 17 lRetVal = sl_Stop(SL_STOP_TIMEOUT); 18 19 // reset status bits 20 CLR_STATUS_BIT_ALL(g_ulStatus); 21 return sl_Start(NULL,NULL,NULL); 22 } Copy code 8. This project contains 3 library files, among which simplelink.a is quite special. Find this related project in SDK and open it. The question is what does sl_start start? How does it communicate with the wifi network processor? 1 $PROJ_DIR$/../../../simplelink/ewarm/OS/Exe/simplelink.a 2 $PROJ_DIR$/../../../driverlib/ewarm/Release/Exe/driverlib.a 3 $PROJ_DIR$/../../../oslib/ewarm/free_rtos/Exe/free_rtos.a 9. Continue to the next step Copy code 1 _i16 sl_WlanSetMode(const _u8 mode) 2 { 3 _SlwlanSetModeMsg_u Msg; 4 Msg.Cmd.mode = mode; 5 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 6 return (_i16)Msg.Rsp.status; 7 } Copy code 10. Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 // Take sl_WlanSet as an example, call it layer by layer, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to set up a TCP server on the computer to test it. The previous test of CC3200's TCP transmission speed was only 100KB per second. I don't know the reason. I will test it again when I have the chance.IS_IP_ACQUIRED(g_ulStatus)) { //looping till ip is acquired } unsigned char len = sizeof(SlNetCfgIpV4Args_t); SlNetCfgIpV4Args_t ipV4 = {0}; // Get network configuration lRetVal = sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&ucDHCP,&len, (unsigned char *)&ipV4); if (lRetVal < 0) { UART_PRINT("Failed to get network configuration \n\r"); LOOP_FOREVER(); } //Wait for STA device to connect and assign IP address to STA while(!IS_IP_LEASED(g_ulStatus)) { } //Establish TCP connection with STA device lRetVal = BsdTcpClient(PORT_NUM); if(lRetVal < 0) { UART_PRINT("TCP Client failed\n\r"); LOOP_FOREVER(); } while(1); } Copy the code to view the setting function of AP mode Copy code 1 static int ConfigureMode(int iMode) 2 { 3 char pcSsidName[33] = "cc3200_tcptest"; 4 long lRetVal = -1; 5 6 //Set to AP mode 7 lRetVal = sl_WlanSetMode(ROLE_AP); 8 ASSERT_ON_ERROR(lRetVal); 9 //Set SSID of AP mode 10 lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName), 11 (unsigned char*)pcSsidName); 12 ASSERT_ON_ERROR(lRetVal); 13 14 UART_PRINT("Device is configured in AP mode\n\r"); 15 16 /* Restart Network processor */ 17 lRetVal = sl_Stop(SL_STOP_TIMEOUT); 18 19 // reset status bits 20 CLR_STATUS_BIT_ALL(g_ulStatus); 21 return sl_Start(NULL,NULL,NULL); 22 } Copy code 8. This project contains 3 library files, among which simplelink.a is quite special. Find this related project in SDK and open it. The question is what does sl_start start? How does it communicate with the wifi network processor? 1 $PROJ_DIR$/../../../simplelink/ewarm/OS/Exe/simplelink.a 2 $PROJ_DIR$/../../../driverlib/ewarm/Release/Exe/driverlib.a 3 $PROJ_DIR$/../../../oslib/ewarm/free_rtos/Exe/free_rtos.a 9. Continue to the next step Copy code 1 _i16 sl_WlanSetMode(const _u8 mode) 2 { 3 _SlwlanSetModeMsg_u Msg; 4 Msg.Cmd.mode = mode; 5 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 6 return (_i16)Msg.Rsp.status; 7 } Copy code 10. Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 // Take sl_WlanSet as an example, call it layer by layer, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to set up a TCP server on the computer to test it. The previous test of CC3200's TCP transmission speed was only 100KB per second. I don't know the reason. I will test it again when I have the chance.IS_IP_LEASED(g_ulStatus)) { } //Establish a TCP connection with the STA device lRetVal = BsdTcpClient(PORT_NUM); if(lRetVal < 0) { UART_PRINT("TCP Client failed\n\r"); LOOP_FOREVER(); } while(1); } Copy the code to view the setting function of AP mode Copy code 1 static int ConfigureMode(int iMode) 2 { 3 char pcSsidName[33] = "cc3200_tcptest"; 4 long lRetVal = -1; 5 6 //Set to AP mode 7 lRetVal = sl_WlanSetMode(ROLE_AP); 8 ASSERT_ON_ERROR(lRetVal); 9 //Set the SSID of AP mode 10 lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName), 11 (unsigned char*)pcSsidName); 12 ASSERT_ON_ERROR(lRetVal); 13 14 UART_PRINT("Device is configured in AP mode\n\r"); 15 16 /* Restart Network processor */ 17 lRetVal = sl_Stop(SL_STOP_TIMEOUT); 18 19 // reset status bits 20 CLR_STATUS_BIT_ALL(g_ulStatus); 21 return sl_Start(NULL,NULL,NULL); 22 } Copy code 8. This project contains 3 library files, among which simplelink.a is quite special. Find this related project in SDK and open it. The question is what does sl_start start? How does it communicate with the wifi network processor? 1 $PROJ_DIR$/../../../simplelink/ewarm/OS/Exe/simplelink.a 2 $PROJ_DIR$/../../../driverlib/ewarm/Release/Exe/driverlib.a 3 $PROJ_DIR$/../../../oslib/ewarm/free_rtos/Exe/free_rtos.a 9. Continue to the next step Copy code 1 _i16 sl_WlanSetMode(const _u8 mode) 2 { 3 _SlwlanSetModeMsg_u Msg; 4 Msg.Cmd.mode = mode; 5 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 6 return (_i16)Msg.Rsp.status; 7 } Copy code 10. Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 // Take sl_WlanSet as an example, call it layer by layer, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to set up a TCP server on the computer to test it. The previous test of CC3200's TCP transmission speed was only 100KB per second. I don't know the reason. I will test it again when I have the chance.IS_IP_LEASED(g_ulStatus)) { } //Establish a TCP connection with the STA device lRetVal = BsdTcpClient(PORT_NUM); if(lRetVal < 0) { UART_PRINT("TCP Client failed\n\r"); LOOP_FOREVER(); } while(1); } Copy the code to view the setting function of AP mode Copy code 1 static int ConfigureMode(int iMode) 2 { 3 char pcSsidName[33] = "cc3200_tcptest"; 4 long lRetVal = -1; 5 6 //Set to AP mode 7 lRetVal = sl_WlanSetMode(ROLE_AP); 8 ASSERT_ON_ERROR(lRetVal); 9 //Set the SSID of AP mode 10 lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName), 11 (unsigned char*)pcSsidName); 12 ASSERT_ON_ERROR(lRetVal); 13 14 UART_PRINT("Device is configured in AP mode\n\r"); 15 16 /* Restart Network processor */ 17 lRetVal = sl_Stop(SL_STOP_TIMEOUT); 18 19 // reset status bits 20 CLR_STATUS_BIT_ALL(g_ulStatus); 21 return sl_Start(NULL,NULL,NULL); 22 } Copy code 8. This project contains 3 library files, among which simplelink.a is quite special. Find this related project in SDK and open it. The question is what does sl_start start? How does it communicate with the wifi network processor? 1 $PROJ_DIR$/../../../simplelink/ewarm/OS/Exe/simplelink.a 2 $PROJ_DIR$/../../../driverlib/ewarm/Release/Exe/driverlib.a 3 $PROJ_DIR$/../../../oslib/ewarm/free_rtos/Exe/free_rtos.a 9. Continue to the next step Copy code 1 _i16 sl_WlanSetMode(const _u8 mode) 2 { 3 _SlwlanSetModeMsg_u Msg; 4 Msg.Cmd.mode = mode; 5 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 6 return (_i16)Msg.Rsp.status; 7 } Copy code 10. Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 // Take sl_WlanSet as an example, call it layer by layer, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to set up a TCP server on the computer to test it. The previous test of CC3200's TCP transmission speed was only 100KB per second. I don't know the reason. I will test it again when I have the chance.Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 //Take sl_WlanSet as an example, call the following layers, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to establish a tcp on the computer Test the server. Previously, the TCP transmission speed of CC3200 was only 100KB per second. I don’t know the reason. I will test it again when I have the chance.Study how the application processor sends data to the wifi network processor, but the following may be wrong Copy code 1 //Take sl_WlanSet as an example, call the following layers, and finally send it through the SPI interface 2 Step 1: sl_WlanSet 3 Step 2: VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); 4 Step 3: _SlDrvMsgWrite 5 Step 4: NWP_IF_WRITE_CHECK 6 Step 5: spi_Write 7 Step 6: spi_Write_CPU Copy code 11. Use uniflash to burn and test it, but next time I have to spend time to study the memory allocation of CC3200, which involves serial port upgrades, OTA upgrades, etc. 12. You need to establish a tcp on the computer Test the server. Previously, the TCP transmission speed of CC3200 was only 100KB per second. I don’t know the reason. I will test it again when I have the chance.