亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? os_mbox.c

?? ucos如何移植到單片機mega128
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                       MESSAGE MAILBOX MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_MBOX.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "..\ucos2_application\includes.h"
#endif

#if OS_MBOX_EN > 0
/*
*********************************************************************************************************
*                                     ACCEPT MESSAGE FROM MAILBOX
*
* Description: This function checks the mailbox to see if a message is available.  Unlike OSMboxPend(),
*              OSMboxAccept() does not suspend the calling task if a message is not available.
*
* Arguments  : pevent        is a pointer to the event control block
*
* Returns    : != (void *)0  is the message in the mailbox if one is available.  The mailbox is cleared
*                            so the next time OSMboxAccept() is called, the mailbox will be empty.
*              == (void *)0  if the mailbox is empty or,
*                            if 'pevent' is a NULL pointer or,
*                            if you didn't pass the proper event pointer.
*********************************************************************************************************
*/

#if OS_MBOX_ACCEPT_EN > 0
void  *OSMboxAccept (OS_EVENT *pevent)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif    
    void      *msg;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                        /* Validate 'pevent'                         */
        return ((void *)0);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {      /* Validate event block type                 */
        return ((void *)0);
    }
#endif
    OS_ENTER_CRITICAL();
    msg                = pevent->OSEventPtr;
    pevent->OSEventPtr = (void *)0;                       /* Clear the mailbox                         */
    OS_EXIT_CRITICAL();
    return (msg);                                         /* Return the message received (or NULL)     */
}
#endif
/*$PAGE*/.
/*
*********************************************************************************************************
*                                        CREATE A MESSAGE MAILBOX
*
* Description: This function creates a message mailbox if free event control blocks are available.
*
* Arguments  : msg           is a pointer to a message that you wish to deposit in the mailbox.  If
*                            you set this value to the NULL pointer (i.e. (void *)0) then the mailbox
*                            will be considered empty.
*
* Returns    : != (OS_EVENT *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                                created mailbox
*              == (OS_EVENT *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT  *OSMboxCreate (void *msg)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    if (OSIntNesting > 0) {                      /* See if called from ISR ...                         */
        return ((OS_EVENT *)0);                  /* ... can't CREATE from an ISR                       */
    }
    OS_ENTER_CRITICAL();
    pevent = OSEventFreeList;                    /* Get next free event control block                  */
    if (OSEventFreeList != (OS_EVENT *)0) {      /* See if pool of free ECB pool was empty             */
        OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
    }
    OS_EXIT_CRITICAL();
    if (pevent != (OS_EVENT *)0) {
        pevent->OSEventType = OS_EVENT_TYPE_MBOX;
        pevent->OSEventCnt  = 0;
        pevent->OSEventPtr  = msg;               /* Deposit message in event control block             */
        OS_EventWaitListInit(pevent);
    }
    return (pevent);                             /* Return pointer to event control block              */
}
/*$PAGE*/.
/*
*********************************************************************************************************
*                                         DELETE A MAIBOX
*
* Description: This function deletes a mailbox and readies all tasks pending on the mailbox.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            mailbox.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete the mailbox ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the mailbox even if tasks are waiting.
*                                                    In this case, all the tasks pending will be readied.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               The call was successful and the mailbox was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the mailbox from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the mailbox
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a mailbox
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the mailbox was successfully deleted.
*
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the mailbox MUST check the return code of OSMboxPend().
*              2) OSMboxAccept() callers will not know that the intended mailbox has been deleted!
*              3) This call can potentially disable interrupts for a long time.  The interrupt disable
*                 time is directly proportional to the number of tasks waiting on the mailbox.
*              4) Because ALL tasks pending on the mailbox will be readied, you MUST be careful in
*                 applications where the mailbox is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the mailbox.
*********************************************************************************************************
*/

#if OS_MBOX_DEL_EN > 0
OS_EVENT  *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on mailbox      */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete mailbox only if no task waiting   */
             if (tasks_waiting == FALSE) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 OSEventFreeList     = pevent;             /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err = OS_NO_ERR;
                 return ((OS_EVENT *)0);                   /* Mailbox has been deleted                 */
             } else {
                 OS_EXIT_CRITICAL();
                 *err = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the mailbox                */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for mailbox      */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MBOX);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             OSEventFreeList     = pevent;                 /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err = OS_NO_ERR;
             return ((OS_EVENT *)0);                       /* Mailbox has been deleted                 */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);
    }
}
#endif

/*$PAGE*/.
/*
*********************************************************************************************************
*                                      PEND ON MAILBOX FOR A MESSAGE
*
* Description: This function waits for a message to be sent to a mailbox
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for a message to arrive at the mailbox up to the amount of time
*                            specified by this argument.  If you specify 0, however, your task will wait
*                            forever at the specified mailbox or, until a message arrives.
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_NO_ERR           The call was successful and your task received a
*                                                message.
*                            OS_TIMEOUT          A message was not received within the specified timeout
*                            OS_ERR_EVENT_TYPE   Invalid event type
*                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
*                                                would lead to a suspension.
*                            OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
*
* Returns    : != (void *)0  is a pointer to the message received
*              == (void *)0  if no message was received or,
*                            if 'pevent' is a NULL pointer or,
*                            if you didn't pass the proper pointer to the event control block.
*********************************************************************************************************
*/

void  *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr;
#endif    
    void      *msg;


    if (OSIntNesting > 0) {                           /* See if called from ISR ...                    */
        *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人免费视频| 亚洲电影激情视频网站| 久久99热狠狠色一区二区| 欧美丰满美乳xxx高潮www| 午夜成人在线视频| 2023国产精品自拍| 99热在这里有精品免费| 亚洲成精国产精品女| 精品入口麻豆88视频| jizzjizzjizz欧美| 免费三级欧美电影| 中文字幕免费不卡| 91精品国产入口| 粉嫩欧美一区二区三区高清影视| 亚洲最色的网站| 久久女同精品一区二区| 51精品秘密在线观看| 蜜臀精品一区二区三区在线观看| 中文字幕免费在线观看视频一区| 韩国欧美国产一区| 久久久久久夜精品精品免费| 91网址在线看| 亚洲chinese男男1069| 天天av天天翘天天综合网| 99久久伊人网影院| 色噜噜狠狠成人中文综合| 99视频超级精品| 97se亚洲国产综合自在线| 成人av高清在线| voyeur盗摄精品| 欧美在线免费观看亚洲| 成人亚洲精品久久久久软件| 国产91富婆露脸刺激对白| 亚洲精品乱码久久久久久久久| 久久久久久久久久久电影| 青草av.久久免费一区| 亚洲婷婷综合久久一本伊一区| 国产精品网友自拍| 欧美三区在线观看| 成人一区二区三区视频| 麻豆成人免费电影| 麻豆久久久久久久| 欧美一区二区免费视频| 国精产品一区一区三区mba桃花| 亚洲精品va在线观看| 婷婷夜色潮精品综合在线| 国产专区欧美精品| 在线观看视频欧美| 国产日韩欧美精品在线| 亚洲电影视频在线| 成人中文字幕在线| 欧美一区二区三区日韩视频| 一区在线观看视频| 久久69国产一区二区蜜臀| 91久久精品日日躁夜夜躁欧美| 日韩三级免费观看| 一区二区三区四区不卡在线| 国产在线播放一区| 欧美乱熟臀69xxxxxx| 一区免费观看视频| 国产一区二区三区四区在线观看| 欧美在线观看一二区| 国产日韩欧美电影| 免费在线观看不卡| 91国偷自产一区二区开放时间| 国产视频亚洲色图| 麻豆专区一区二区三区四区五区| 91麻豆精品视频| 国产婷婷一区二区| 久久精品国产精品亚洲精品| 欧美三级日本三级少妇99| 最新国产の精品合集bt伙计| 国内精品国产三级国产a久久| 欧美日韩免费观看一区二区三区| 国产精品久久影院| 国产一区二区成人久久免费影院| 在线91免费看| 亚洲成av人影院| 一本大道久久a久久精二百| 亚洲欧美日本在线| 成人v精品蜜桃久久一区| 亚洲精品一区在线观看| 亚洲成人资源网| 色噜噜狠狠色综合中国| 亚洲色图欧洲色图婷婷| 国产精品一二三四五| 欧美成人a视频| 奇米色777欧美一区二区| 欧美女孩性生活视频| 亚洲色图在线视频| 色综合色综合色综合色综合色综合 | 欧美精品丝袜久久久中文字幕| 中文字幕中文字幕一区二区| 国产精品一区二区在线看| 欧美精品一区二区三| 精品一区二区三区在线观看国产| 日韩欧美高清在线| 久久91精品久久久久久秒播| 日韩精品一区二区三区视频在线观看 | 国产色一区二区| 国产不卡视频一区二区三区| 国产日本一区二区| 粉嫩一区二区三区性色av| 国产精品美女视频| 成人av网址在线| 亚洲欧美二区三区| 欧美性色欧美a在线播放| 亚洲午夜免费视频| 欧美精品免费视频| 久久电影网电视剧免费观看| 久久综合九色综合久久久精品综合| 国产一区二区久久| 中文字幕五月欧美| 欧美中文字幕亚洲一区二区va在线| 亚洲高清在线视频| 欧美一区二区黄| 国产真实乱偷精品视频免| 亚洲国产精品ⅴa在线观看| 91丨九色丨国产丨porny| 夜夜精品视频一区二区| 欧美一区二区在线免费观看| 激情成人综合网| 国产精品二区一区二区aⅴ污介绍| 99r国产精品| 午夜影院久久久| 久久午夜色播影院免费高清| av欧美精品.com| 亚洲高清免费观看| 亚洲精品一区二区三区四区高清| 国产成人av福利| 亚洲精品欧美激情| 日韩免费高清电影| 成人手机电影网| 亚洲一卡二卡三卡四卡五卡| 日韩一区二区三区免费看 | 青青青爽久久午夜综合久久午夜| 久久一区二区三区四区| 91香蕉视频黄| 免费人成在线不卡| 国产欧美日韩一区二区三区在线观看| 一本色道a无线码一区v| 日本美女视频一区二区| 国产亚洲欧美一级| 欧美网站大全在线观看| 国产高清在线观看免费不卡| 亚洲精品国产精品乱码不99| 日韩片之四级片| 91香蕉国产在线观看软件| 久久爱www久久做| 亚洲精品成人精品456| 2欧美一区二区三区在线观看视频| 91麻豆国产福利精品| 久久精品99国产精品日本| 亚洲精品日韩一| 久久久影视传媒| 欧美猛男男办公室激情| 成人成人成人在线视频| 蜜桃精品视频在线| 亚洲在线中文字幕| 中文字幕乱码亚洲精品一区| 91麻豆精品久久久久蜜臀 | 亚洲女爱视频在线| 精品美女在线播放| 欧美理论电影在线| www.欧美色图| 国产美女精品一区二区三区| 亚洲mv大片欧洲mv大片精品| 国产精品人人做人人爽人人添| 日韩无一区二区| 91黄色免费看| 99久久久精品| 粉嫩蜜臀av国产精品网站| 日韩电影在线一区二区| 亚洲资源在线观看| 久久久亚洲综合| 日韩欧美的一区| 欧美日本在线观看| 色综合天天综合色综合av| 国产成人精品免费网站| 久久精品国产秦先生| 日韩二区在线观看| 亚洲成人激情综合网| 亚洲最快最全在线视频| 亚洲卡通动漫在线| 国产精品麻豆久久久| 国产亚洲欧美日韩在线一区| 日韩精品一区二区三区在线| 欧美丰满少妇xxxxx高潮对白| 欧美性受极品xxxx喷水| 91免费视频网| 色综合色综合色综合| 91亚洲男人天堂| 91视视频在线观看入口直接观看www| 国产精品888| 国产成人8x视频一区二区| 国产精品一区免费在线观看| 国产精品99久久久久久宅男| 国产在线精品视频| 国产精品99久久久久久宅男| 国产精品12区|