// ============================================================================= // 函数功能:看门狗监视任务 // 输入参数: // 输出参数: // 返回值 : // 说明 : // ============================================================================= static ptu32_t Wdt_Service(void) { s64 timenow; tagWdt *wdt; u32 waittime; tagWdtMsg wdtmsg; //将硬件狗从裸狗中接管过来 WdtHal_BootEnd(); // deal all the msg cached in the msgbox timenow = DjyGetTime(); while(MsgQ_Receive(ptWdtMsgBox,(u8 *)&wdtmsg,sizeof(tagWdtMsg),0)) { __Wdt_DealMsg(&wdtmsg); //all the wdt will be queued in the wdt queue } //now we come into the never get out loop, deal all the msg and timeout wdt while(1) { //preapara the wait time wdt = ptWdtHead; if((NULL == wdt)||(wdt->deadtime == CN_WDT_YIP_NEVER)) { waittime = CN_TIMEOUT_FOREVER; } else { timenow = DjyGetTime(); waittime = (u32)(wdt->deadtime - timenow); } //ok, now we wait the msg box during the expect time if(MsgQ_Receive(ptWdtMsgBox,(u8 *)&wdtmsg,sizeof(tagWdtMsg),waittime)) { //must look out that:there maybe more than one msgs in the msgbox //some app has send some msg to the __Wdt_DealMsg(&wdtmsg); //all the wdt will be queued in the wdt queue // deal all the msg cached in the msgbox while(MsgQ_Receive(ptWdtMsgBox,(u8 *)&wdtmsg,sizeof(tagWdtMsg),0)) { __Wdt_DealMsg(&wdtmsg); //all the wdt will be queued in the wdt queue } } //scan the queue to deal the timeout wdt __Wdt_ScanWdtQueque(); } return 1; //if no exp, this could not be reached }
//----从默认队列读取消息------------------------------------------------------- //功能: 从默认输入消息队列中读取输入消息 //参数: MsgBuf, 保存接收到的消息的缓冲区 // TimeOut, 如果消息队列空, 等候消息的时限 //返回: true=成功,false=失败,一般是因为输入设备未安装。 //----------------------------------------------------------------------------- bool_t Stddev_ReadDefaultMsg(struct tagInputDeviceMsg *MsgBuf,u32 TimeOut) { return MsgQ_Receive(tg_pStdinInputMsgQ,(u8*)MsgBuf,sizeof(struct tagInputDeviceMsg),TimeOut); }
//----读取消息----------------------------------------------------------------- //功能: 从输入消息队列中读取输入消息 //参数: InputMsgQ, 接收消息的消息队列 // MsgBuf, 保存接收到的消息的缓冲区 // TimeOut, 如果消息队列空, 等候消息的时限 //返回: true=成功,false=失败,一般是因为输入设备未安装。 //----------------------------------------------------------------------------- bool_t Stddev_ReadMsg(tpInputMsgQ InputMsgQ, struct tagInputDeviceMsg *MsgBuf,u32 TimeOut) { return MsgQ_Receive(InputMsgQ,(u8*)MsgBuf,sizeof(struct tagInputDeviceMsg),TimeOut); }