⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_mbox.ls1

📁 uCOS-II_2.52在51上的移植程序
💻 LS1
📖 第 1 页 / 共 4 页
字号:
                                           */
                     309     ;         *err = OS_ERR_PEND_ISR;                       /* ... can't PEND from an ISR      
                                           */
                     310     ;         return ((void *)0);
                     311     ;     }
                     312     ; #if OS_ARG_CHK_EN > 0
                     313     ;     if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'               
A51 MACRO ASSEMBLER  OS_MBOX                                                              08/08/2005 11:36:44 PAGE     7

                                           */
                     314     ;         *err = OS_ERR_PEVENT_NULL;
                     315     ;         return ((void *)0);
                     316     ;     }
                     317     ;     if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type       
                                           */
                     318     ;         *err = OS_ERR_EVENT_TYPE;
                     319     ;         return ((void *)0);
                     320     ;     }
                     321     ; #endif
                     322     ;     OS_ENTER_CRITICAL();
                     323     ;     msg = pevent->OSEventPtr;
                     324     ;     if (msg != (void *)0) {                           /* See if there is already a messag
                             e             */
                     325     ;         pevent->OSEventPtr = (void *)0;               /* Clear the mailbox               
                                           */
                     326     ;         OS_EXIT_CRITICAL();
                     327     ;         *err = OS_NO_ERR;
                     328     ;         return (msg);                                 /* Return the message received (or 
                             NULL)         */
                     329     ;     }
                     330     ;     OSTCBCur->OSTCBStat |= OS_STAT_MBOX;              /* Message not available, task will
                              pend         */
                     331     ;     OSTCBCur->OSTCBDly   = timeout;                   /* Load timeout in TCB             
                                           */
                     332     ;     OS_EventTaskWait(pevent);                         /* Suspend task until event or time
                             out occurs    */
                     333     ;     OS_EXIT_CRITICAL();
                     334     ;     OS_Sched();                                       /* Find next highest priority task 
                             ready to run  */
                     335     ;     OS_ENTER_CRITICAL();
                     336     ;     msg = OSTCBCur->OSTCBMsg;
                     337     ;     if (msg != (void *)0) {                           /* See if we were given the message
                                           */
                     338     ;         OSTCBCur->OSTCBMsg      = (void *)0;          /* Yes, clear message received     
                                           */
                     339     ;         OSTCBCur->OSTCBStat     = OS_STAT_RDY;
                     340     ;         OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;      /* No longer waiting for event     
                                           */
                     341     ;         OS_EXIT_CRITICAL();
                     342     ;         *err                    = OS_NO_ERR;
                     343     ;         return (msg);                                 /* Return the message received     
                                           */
                     344     ;     }
                     345     ;     OS_EventTO(pevent);                               /* Timed out, Make task ready      
                                           */
                     346     ;     OS_EXIT_CRITICAL();
                     347     ;     *err = OS_TIMEOUT;                                /* Indicate that a timeout occured 
                                           */
                     348     ;     return ((void *)0);                               /* Return a NULL message           
                                           */
                     349     ; }
                     350     ; /*$PAGE*/
                     351     ; /*
                     352     ; *****************************************************************************************
                             ****************
                     353     ; *                                       POST MESSAGE TO A MAILBOX
                     354     ; *
                     355     ; * Description: This function sends a message to a mailbox
                     356     ; *
                     357     ; * Arguments  : pevent        is a pointer to the event control block associated with the 
                             desired mailbox
                     358     ; *
                     359     ; *              msg           is a pointer to the message to send.  You MUST NOT send a NU
                             LL pointer.
                     360     ; *
A51 MACRO ASSEMBLER  OS_MBOX                                                              08/08/2005 11:36:44 PAGE     8

                     361     ; * Returns    : OS_NO_ERR            The call was successful and the message was sent
                     362     ; *              OS_MBOX_FULL         If the mailbox already contains a message.  You can c
                             an only send one
                     363     ; *                                   message at a time and thus, the message MUST be consu
                             med before you
                     364     ; *                                   are allowed to send another one.
                     365     ; *              OS_ERR_EVENT_TYPE    If you are attempting to post to a non mailbox.
                     366     ; *              OS_ERR_PEVENT_NULL   If 'pevent' is a NULL pointer
                     367     ; *              OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
                     368     ; *****************************************************************************************
                             ****************
                     369     ; */
                     370     ; 
                     371     ; #if OS_MBOX_POST_EN > 0
                     372     ; INT8U  OSMboxPost (OS_EVENT *pevent, void *msg)
                     373     ; {
                     374     ;   
                     375     ;     
                     376     ;     
                     377     ; #if OS_ARG_CHK_EN > 0
                     378     ;     if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'               
                                           */
                     379     ;         return (OS_ERR_PEVENT_NULL);
                     380     ;     }
                     381     ;     if (msg == (void *)0) {                           /* Make sure we are not posting a N
                             ULL pointer   */
                     382     ;         return (OS_ERR_POST_NULL_PTR);
                     383     ;     }
                     384     ;     if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type       
                                           */
                     385     ;         return (OS_ERR_EVENT_TYPE);
                     386     ;     }
                     387     ; #endif
                     388     ;     OS_ENTER_CRITICAL();
                     389     ;     if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailb
                             ox            */
                     390     ;         OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);   /* Ready highest priority task wait
                             ing on event  */
                     391     ;         OS_EXIT_CRITICAL();
                     392     ;         OS_Sched();                                   /* Find highest priority task ready
                              to run       */
                     393     ;         return (OS_NO_ERR);
                     394     ;     }
                     395     ;     if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't alread
                             y have a msg  */
                     396     ;         OS_EXIT_CRITICAL();
                     397     ;         return (OS_MBOX_FULL);
                     398     ;     }
                     399     ;     pevent->OSEventPtr = msg;                         /* Place message in mailbox        
                                           */
                     400     ;     OS_EXIT_CRITICAL();
                     401     ;     return (OS_NO_ERR);
                     402     ; }
                     403     ; #endif
                     404     ; 
                     405     ; /*$PAGE*/
                     406     ; /*
                     407     ; *****************************************************************************************
                             ****************
                     408     ; *                                       POST MESSAGE TO A MAILBOX
                     409     ; *
                     410     ; * Description: This function sends a message to a mailbox
                     411     ; *
                     412     ; * Arguments  : pevent        is a pointer to the event control block associated with the 
                             desired mailbox
                     413     ; *
A51 MACRO ASSEMBLER  OS_MBOX                                                              08/08/2005 11:36:44 PAGE     9

                     414     ; *              msg           is a pointer to the message to send.  You MUST NOT send a NU
                             LL pointer.
                     415     ; *
                     416     ; *              opt           determines the type of POST performed:
                     417     ; *                            OS_POST_OPT_NONE         POST to a single waiting task 
                     418     ; *                                                     (Identical to OSMboxPost())
                     419     ; *                            OS_POST_OPT_BROADCAST    POST to ALL tasks that are waiting 
                             on the mailbox
                     420     ; *
                     421     ; * Returns    : OS_NO_ERR            The call was successful and the message was sent
                     422     ; *              OS_MBOX_FULL         If the mailbox already contains a message.  You can c
                             an only send one
                     423     ; *                                   message at a time and thus, the message MUST be consu
                             med before you
                     424     ; *                                   are allowed to send another one.
                     425     ; *              OS_ERR_EVENT_TYPE    If you are attempting to post to a non mailbox.
                     426     ; *              OS_ERR_PEVENT_NULL   If 'pevent' is a NULL pointer
                     427     ; *              OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
                     428     ; *
                     429     ; * Warning    : Interrupts can be disabled for a long time if you do a 'broadcast'.  In fa
                             ct, the 
                     430     ; *              interrupt disable time is proportional to the number of tasks waiting on t
                             he mailbox.
                     431     ; *****************************************************************************************
                             ****************
                     432     ; */
                     433     ; 
                     434     ; #if OS_MBOX_POST_OPT_EN > 0
                     435     ; INT8U  OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt)
                     436     ; {
                     437     ; 
                     438     ;     
                     439     ; #if OS_ARG_CHK_EN > 0
                     440     ;     if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'               
                                           */
                     441     ;         return (OS_ERR_PEVENT_NULL);
                     442     ;     }
                     443     ;     if (msg == (void *)0) {                           /* Make sure we are not posting a N
                             ULL pointer   */
                     444     ;         return (OS_ERR_POST_NULL_PTR);
                     445     ;     }
                     446     ;     if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type       
                                           */
                     447     ;         return (OS_ERR_EVENT_TYPE);
                     448     ;     }
                     449     ; #endif
                     450     ;     OS_ENTER_CRITICAL();
                     451     ;     if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailb
                             ox            */
                     452     ;         if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL wa
                             iting tasks ? */
                     453     ;             while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting o
                             n mailbox     */           
                     454     ;                 OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    
                     455     ;             }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -