完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 一只耳朵怪 于 2018-6-7 15:36 编辑
例程中的是通过调用sl_Recv()函数去查询是否有数据到来 请问当有网络数据来的时候 能不能以中断的形式通知。这样就能及时处理每个接收的网络数据并建立消息队列。 |
|
相关推荐
3个回答
|
|
|
|
|
|
可以通过NWP-IRO 唤醒M4内核 参考如下测试代码
unsigned char ucSyncMsg = 0; int iRetVal = 0; // // Displays the Application Banner // DisplayBanner(); // // creating the queue for signalling about connection events // iRetVal = osi_MsgQCreate(&g_tConnection, NULL, sizeof( unsigned char ), 3); if (iRetVal < 0) [ UART_PRINT("unable to create the msg queuenr"); LOOP_FOREVER(); ] // // starting the simplelink // iRetVal = sl_Start(NULL, NULL, NULL); if (iRetVal < 0) [ UART_PRINT("Failed to start the device nr"); LOOP_FOREVER(); ] // // Swtich to STA mode if device is not // SwitchToStaMode(iRetVal); // // Set the power management policy of NWP // iRetVal = sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0); if (iRetVal < 0) [ UART_PRINT("unable to configure network power policynr"); LOOP_FOREVER(); ] // // connecting to the Access Point // if(-1 == WlanConnect()) [ sl_Stop(SL_STOP_TIMEOUT); UART_PRINT("Connection to AP failednr"); ] else [ UART_PRINT("Connected to APnr"); // //signal the other task about the sl start and connection to the AP // iRetVal = osi_MsgQWrite(&g_tConnectionFlag, &ucSyncMsg,OSI_WAIT_FOREVER); if (iRetVal < 0) [ UART_PRINT("unable to create the msg queuenr"); LOOP_FOREVER(); ] ] // // Queue management related configurations // iRetVal = osi_MsgQCreate(&g_tWkupSignalQueue, NULL, sizeof( unsigned char ), 10); if (iRetVal < 0) [ UART_PRINT("unable to create the msg queuenr"); LOOP_FOREVER(); ] // // setting Timer as one of the wakeup source // tTimerHndl = SetTimerAsWkUp(); // // setting some GPIO as one of the wakeup source // tGPIOHndl = SetGPIOAsWkUp(); /* handles, if required, can be used to stop the timer, but not used here*/ UNUSED(tTimerHndl); UNUSED(tGPIOHndl); // // setting Apps power policy // lp3p0_setup_power_policy(POWER_POLICY_STANDBY); //设置M4内核低功耗模式=LPDS模式 //通过空闲回调函数vApplicationIdleHook()将该LPDS参数传递到CPU进入的低功耗模式 while(FOREVER) //当CPU进入LPDS后通过按键 /Timer /NWP-IRQ唤醒的 [ // // waits for the message from the various interrupt handlers(GPIO,Timer) and the UDPServerTask. // osi_MsgQRead(&g_tWkupSignalQueue, &ucQueueMsg, OSI_WAIT_FOREVER); switch(ucQueueMsg)[ case 1: UART_PRINT("timernr"); //通过定时器定时到后唤醒CPU,进入TimerCallback()回调函数写入队列信息进入该任务读取队列信息,打印该信息 break; case 2: UART_PRINT("GPIOnr"); //IO产生<中断>后进入gpio_intr_hndlr()入口函数写入队列信息进入该任务读取队列信息,打印该信息 break; //注意在idle_profile_nonos例程中配置的GPIO唤醒源,直接从CPU睡眠的地方进行唤醒的,并未进入中断函数执行! case 3: UART_PRINT("host irqnr"); //通过NWP收到数据后唤醒CPU-执行UDPServerTask写入信号量 Task creation for providing host_irq as a wake up source(LPDS) break; default: UART_PRINT("invalid msgnr"); break; ] ] ] //***************************************************************************** // //! brief Task Created by main fucntion. This task creates a udp server and //! wait for packets. Upon receiving the packet, signals the other task. //! //! param pvParameters is a general void pointer (not used here). //! //! return none // //***************************************************************************** void UDPServerTask(void *pvParameters) [ unsigned char ucSyncMsg; unsigned char ucQueueMsg = 3; //信号量为3 int iSockDesc = 0; int iRetVal = 0; sockaddr_in sLocalAddr; sockaddr_in sClientAddr; unsigned int iAddrSize = 0; // // waiting for the other task to start simplelink and connection to the AP // Blocked on a message from the Other Task(waiting for simplelink start and connection to AP) osi_MsgQRead(&g_tConnectionFlag, &ucSyncMsg, OSI_WAIT_FOREVER); osi_MsgQDelete(&g_tConnectionFlag); //----------------------------------------建立UDP服务器------------------------------------------ // // configure the Server // sLocalAddr.sin_family = SL_AF_INET; sLocalAddr.sin_port = sl_Htons((unsigned short)APP_UDP_PORT); //本机端口号 sLocalAddr.sin_addr.s_addr = 0; //忽略本地IP地址! iAddrSize = sizeof(sockaddr_in); // // creating a UDP socket // iSockDesc = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0); if(iSockDesc < 0) [ UART_PRINT("sock errornr"); LOOP_FOREVER(); ] // // binding the socket // iRetVal = sl_Bind(iSockDesc, (SlSockAddr_t *)&sLocalAddr, iAddrSize); if(iRetVal < 0) [ UART_PRINT("bind errornr"); LOOP_FOREVER(); ] //-------------------------------------------------------------------------------------------------- while(FOREVER) [ // NWP收到UDP的数据会自动唤醒M4内核 // waiting on a UDP packet // As soon as the NWP subsystem receives any UDP packet, it will bring the APPS subsystem out of LPDS, if not already. iRetVal = sl_RecvFrom(iSockDesc, g_cBuffer, BUFF_SIZE, 0,( SlSockAddr_t *)&sClientAddr,(SlSocklen_t*)&iAddrSize ); if(iRetVal > 0) [ // 收到数据后读取sl_RecvFrom() // signal the other task about receiving the UDP packet // osi_MsgQWrite(&g_tWkupSignalQueue, &ucQueueMsg, OSI_WAIT_FOREVER); //写入队列信号量=3 ] else [ UART_PRINT("recv errornr"); LOOP_FOREVER(); ] ] ] //**************************************************************************** // MAIN FUNCTION // 采用USE_FREERTOS //**************************************************************************** void main(void) [ int iRetVal; // // Board Initialization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Initialize the platform // platform_init(); // // Configuring UART // g_tUartHndl = uart_open(PRCM_UARTA0); #ifdef DEBUG_GPIO //打开了,在M4未进入LPDS时,GPIO 9一直点亮RED // // setting up GPIO for indicating the entry into LPDS // tGPIODbgHndl = cc_gpio_open(GPIO_09, GPIO_DIR_OUTPUT); //这个LED灯在lp3p0_back_up_soc_data/lp3p0_restore_soc_data中调用控制 cc_gpio_write(tGPIODbgHndl, GPIO_09, 1); #endif // // Start the SimpleLink Host // iRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(iRetVal < 0) [ UART_PRINT("could not create simplelink tasknr"); LOOP_FOREVER(); ] // // sync object for inter thread communication // iRetVal = osi_MsgQCreate(&g_tConnectionFlag, NULL, sizeof( unsigned char ), 1); if(iRetVal < 0) [ UART_PRINT("could not create msg queuenr"); LOOP_FOREVER(); ] // 注意M4唤醒后执行恢复寄存器函数resume_from_S3() // Task creation for providing host_irq as a wake up source(LPDS) // 在USR手机网络助手中(1)建立一个UDP client (2)增加CC3200的本机IP (3)向目的IP及端口号发送数据 iRetVal = osi_TaskCreate(UDPServerTask,(const signed char *)"UDP Server waiting to recv packets", OSI_STACK_SIZE, NULL, 1, NULL ); //任务优先级=1 if(iRetVal < 0) [ UART_PRINT("First Task creation failednr"); LOOP_FOREVER(); ] // // setting up timer and gpio as source for wake up from LPDS // iRetVal = osi_TaskCreate(TimerGPIOTask,(const signed char*)"Configuring Timer and GPIO as wake src", OSI_STACK_SIZE, NULL, 1, NULL );//任务优先级=1 if(iRetVal < 0) [ UART_PRINT("Second Task creation failednr"); LOOP_FOREVER(); ] // // Start the task scheduler // osi_start(); ] |
|
|
|
感谢您的回答,虽然没在其中找到解决方案 可能是我表述问题不够清晰 |
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
677 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
599 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1052 浏览 1 评论
736 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
523 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
160浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
123浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
124浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
122浏览 12评论
TPA6304-Q1: TPA6304 两片公用一组I2C的话,其中一片配置不成功怎么办
167浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 19:15 , Processed in 0.880544 second(s), Total 83, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号