ucos+lwip应用心得[社区]
nbsp;}
}
}
}
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u32_t timeout)
{
u32_t ucErr;
u16_t ucos_timeout;
//在 lwip中 ,timeout的单位是ms
// 在ucosII ,timeout 的单位是timer tick
ucos_timeout = 0;
if(timeout != 0){
ucos_timeout = (timeout )*( OS_TICKS_PER_SEC/1000);
if(ucos_timeout < 1)
ucos_timeout = 1;
else if(ucos_timeout > 65535)
ucos_timeout = 65535;
} &nbs
//如果data!=NULL就返回消息指针,
if(data != NULL){
*data = OSQPend( mbox->pQ, (u16_t)ucos_timeout, &ucErr );
}else{
OSQPend(mbox->pQ,(u16_t)ucos_timeout,&ucErr);
}
//这里修改了ucos中的OSQPend系统调用,
//原来的void *OSQPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
// err的返回值只有两种:收到消息就返回OS_NO_ERR,超时则返回OS_TIMEOUT
//这里先将err从8位数据改变成了16位数据 OSQPend(*pevent,timeout, INT16U *err)
//重新定义了OS_TIMEOUT
//在ucos中原有#define OS_TIMEOUT 20
//改为 #define OS_TIMEOUT -1
//err返回值的意义也改变了,如果超时返回OS_TIMEOUT
// 如果收到消息,则返回OSTCBCur->OSTCBDly修改部分代码如下
//if (msg != (void *)0) { /* Did we get a message? */
// OSTCBCur->OSTCBMsg = (void *)0;
// OSTCBCur->OSTCBStat = OS_STAT_RDY;
// OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
// *err = OSTCBCur->OSTCBDly;// zhangzs @2003.12.12
// OS_EXIT_CRITICAL();
// return (msg); /* Return message received */
// }
//关于ucos的OSTBCur->OSTCBDly的含义请查阅ucos的书籍
if( ucErr == OS_TIMEOUT ) {
timeout = SYS_ARCH_TIMEOUT;
} else {
if(*data == (void*)&pvNullPointer )
*data = NULL;
//单位转换,从ucos tick->ms
timeout = (ucos_timeout -ucErr)*(1000/ OS_TICK 《ucos+lwip应用心得[社区](第8页)》
本文链接地址:http://www.oyaya.net/fanwen/view/148424.html
}
}
}
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u32_t timeout)
{
u32_t ucErr;
u16_t ucos_timeout;
//在 lwip中 ,timeout的单位是ms
// 在ucosII ,timeout 的单位是timer tick
ucos_timeout = 0;
if(timeout != 0){
ucos_timeout = (timeout )*( OS_TICKS_PER_SEC/1000);
if(ucos_timeout < 1)
ucos_timeout = 1;
else if(ucos_timeout > 65535)
ucos_timeout = 65535;
} &nbs
p;
//如果data!=NULL就返回消息指针,
if(data != NULL){
*data = OSQPend( mbox->pQ, (u16_t)ucos_timeout, &ucErr );
}else{
OSQPend(mbox->pQ,(u16_t)ucos_timeout,&ucErr);
}
//这里修改了ucos中的OSQPend系统调用,
//原来的void *OSQPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
// err的返回值只有两种:收到消息就返回OS_NO_ERR,超时则返回OS_TIMEOUT
//这里先将err从8位数据改变成了16位数据 OSQPend(*pevent,timeout, INT16U *err)
//重新定义了OS_TIMEOUT
//在ucos中原有#define OS_TIMEOUT 20
//改为 #define OS_TIMEOUT -1
//err返回值的意义也改变了,如果超时返回OS_TIMEOUT
// 如果收到消息,则返回OSTCBCur->OSTCBDly修改部分代码如下
//if (msg != (void *)0) { /* Did we get a message? */
// OSTCBCur->OSTCBMsg = (void *)0;
// OSTCBCur->OSTCBStat = OS_STAT_RDY;
// OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
// *err = OSTCBCur->OSTCBDly;// zhangzs @2003.12.12
// OS_EXIT_CRITICAL();
// return (msg); /* Return message received */
// }
//关于ucos的OSTBCur->OSTCBDly的含义请查阅ucos的书籍
if( ucErr == OS_TIMEOUT ) {
timeout = SYS_ARCH_TIMEOUT;
} else {
if(*data == (void*)&pvNullPointer )
*data = NULL;
//单位转换,从ucos tick->ms
timeout = (ucos_timeout -ucErr)*(1000/ OS_TICK 《ucos+lwip应用心得[社区](第8页)》