Chinaunix首页 | 论坛 | 博客
  • 博客访问: 542075
  • 博文数量: 150
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-17 00:19
文章分类

全部博文(150)

文章存档

2011年(1)

2009年(14)

2008年(135)

我的朋友

分类:

2008-04-11 10:55:31

修改后的部分函数

static INT8U OSQPost (OS_EVENT *pevent, void *msg)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
    OS_CPU_SR cpu_sr;
#endif
    OS_Q *pq;
/*
****************************************************
*
* Modify area begin
*
****************************************************
*/


char display_post[20];
if( post_flag>=255){ post_flag=0;}//post_flay is a global variable

 post_flag++;

sprintf(display_post,"%d ", post_flag);
PC_DispStr(15,23,display_post,font_color);

/*
*****************************************************
*
* Modify area end
*
*****************************************************
*/

#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
        return (OS_ERR_PEVENT_NULL);
    }
    if (msg == (void *)0) { /* Make sure we are not posting a NULL pointer */
        return (OS_ERR_POST_NULL_PTR);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
        return (OS_ERR_EVENT_TYPE);
    }
#endif
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue */
        OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* Ready highest priority task waiting on event */
        OS_EXIT_CRITICAL();
        OS_Sched(); /* Find highest priority task ready to run */
        return (OS_NO_ERR);
    }
    pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block */
    if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full */
/*
*****************************************************
*
* Modify area below
*if full time delay 500 ticks //notice the os_EXIT_CRITICAL Wheather to modify
*****************************************************
*/

       OS_EXIT_CRITICAL();//author

     OSTimeDly(2);//modify 1

    OS_ENTER_CRITICAL();//add modify 3

    if (pq->OSQEntries >= pq->OSQSize)//modify 2 back after 200 ticks

        {//modify 3

        return (OS_Q_FULL);//author return 进入满

        }//modify4

     OS_EXIT_CRITICAL();//add modify 4

    }
    *pq->OSQIn++ = msg; /* Insert message into queue */
    pq->OSQEntries++; /* Update the nbr of entries in the queue */
    if (pq->OSQIn == pq->OSQEnd) { /* Wrap IN ptr if we are at end of queue */
        pq->OSQIn = pq->OSQStart;
    }
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}
*/
        pq->OSQIn = pq->OSQStart;
    }
    OS_EXIT_CRITICAL();
    return (OS_NO_ERR);
}

阅读(1059) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~