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

📄 ucos_ii.lis

📁 mega16 ucos操作系统
💻 LIS
📖 第 1 页 / 共 5 页
字号:
 0000           ; #endif
 0000           ; 
 0000           ; static  void  OS_InitTCBList(void);
 0000           ; 
 0000           ; static  void  OS_SchedNew(void);
 0000           ; 
 0000           ; 
 0000           ; /*
 0000           ; *********************************************************************************************************
 0000           ; *                         GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
 0000           ; *
 0000           ; * Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
 0000           ; *
 0000           ; * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
 0000           ; *                        a mutex, a mailbox or a queue.  Where this function is concerned, the actual
 0000           ; *                        type is irrelevant.
 0000           ; *
 0000           ; *              pname     is a pointer to an ASCII string that will receive the name of the semaphore,
 0000           ; *                        mutex, mailbox or queue.  The string must be able to hold at least
 0000           ; *                        OS_EVENT_NAME_SIZE characters.
 0000           ; *
 0000           ; *              perr      is a pointer to an error code that can contain one of the following values:
 0000           ; *
 0000           ; *                        OS_ERR_NONE                if the name was copied to 'pname'
 0000           ; *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event
 0000           ; *                                                   control block type.
 0000           ; *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 0000           ; *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
 0000           ; *                        OS_ERR_NAME_GET_ISR        if you are trying to call this function from an ISR
 0000           ; *
 0000           ; * Returns    : The length of the string or 0 if the 'pevent' is a NULL pointer.
 0000           ; *********************************************************************************************************
 0000           ; */
 0000           ; 
 0000           ; #if (OS_EVENT_EN) && (OS_EVENT_NAME_SIZE > 1)
 0000           ; INT8U  OSEventNameGet (OS_EVENT *pevent, INT8U *pname, INT8U *perr)
 0000           ; {
 0000           ;     INT8U      len;
 0000           ; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 0000           ;     OS_CPU_SR  cpu_sr = 0;
 0000           ; #endif
 0000           ; 
 0000           ; 
 0000           ; 
 0000           ; #if OS_ARG_CHK_EN > 0
 0000           ;     if (perr == (INT8U *)0) {                    /* Validate 'perr'                                    */
 0000           ;         return (0);
 0000           ;     }
 0000           ;     if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
 0000           ;         *perr = OS_ERR_PEVENT_NULL;
 0000           ;         return (0);
 0000           ;     }
 0000           ;     if (pname == (INT8U *)0) {                   /* Is 'pname' a NULL pointer?                         */
 0000           ;         *perr = OS_ERR_PNAME_NULL;
 0000           ;         return (0);
 0000           ;     }
 0000           ; #endif
 0000           ;     if (OSIntNesting > 0) {                      /* See if trying to call from an ISR                  */
 0000           ;         *perr  = OS_ERR_NAME_GET_ISR;
 0000           ;         return (0);
 0000           ;     }
 0000           ;     switch (pevent->OSEventType) {
 0000           ;         case OS_EVENT_TYPE_SEM:
 0000           ;         case OS_EVENT_TYPE_MUTEX:
 0000           ;         case OS_EVENT_TYPE_MBOX:
 0000           ;         case OS_EVENT_TYPE_Q:
 0000           ;              break;
 0000           ; 
 0000           ;         default:
 0000           ;              *perr = OS_ERR_EVENT_TYPE;
 0000           ;              return (0);
 0000           ;     }
 0000           ;     OS_ENTER_CRITICAL();
 0000           ;     len   = OS_StrCopy(pname, pevent->OSEventName);   /* Copy name from OS_EVENT                       */
 0000           ;     OS_EXIT_CRITICAL();
 0000           ;     *perr = OS_ERR_NONE;
 0000           ;     return (len);
 0000           ; }
 0000           ; #endif
 0000           ; 
 0000           ; /*
 0000           ; *********************************************************************************************************
 0000           ; *                         ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
 0000           ; *
 0000           ; * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
 0000           ; *
 0000           ; * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
 0000           ; *                        a mutex, a mailbox or a queue.  Where this function is concerned, it doesn't
 0000           ; *                        matter the actual type.
 0000           ; *
 0000           ; *              pname     is a pointer to an ASCII string that will be used as the name of the semaphore,
 0000           ; *                        mutex, mailbox or queue.  The string must be able to hold at least
 0000           ; *                        OS_EVENT_NAME_SIZE characters.
 0000           ; *
 0000           ; *              perr      is a pointer to an error code that can contain one of the following values:
 0000           ; *
 0000           ; *                        OS_ERR_NONE                if the requested task is resumed
 0000           ; *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event
 0000           ; *                                                   control block type.
 0000           ; *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 0000           ; *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
 0000           ; *                        OS_ERR_NAME_SET_ISR        if you called this function from an ISR
 0000           ; *
 0000           ; * Returns    : None
 0000           ; *********************************************************************************************************
 0000           ; */
 0000           ; 
 0000           ; #if (OS_EVENT_EN) && (OS_EVENT_NAME_SIZE > 1)
 0000           ; void  OSEventNameSet (OS_EVENT *pevent, INT8U *pname, INT8U *perr)
 0000           ; {
 0000           ;     INT8U      len;
 0000           ; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 0000           ;     OS_CPU_SR  cpu_sr = 0;
 0000           ; #endif
 0000           ; 
 0000           ; 
 0000           ; 
 0000           ; #if OS_ARG_CHK_EN > 0
 0000           ;     if (perr == (INT8U *)0) {                    /* Validate 'perr'                                    */
 0000           ;         return;
 0000           ;     }
 0000           ;     if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
 0000           ;         *perr = OS_ERR_PEVENT_NULL;
 0000           ;         return;
 0000           ;     }
 0000           ;     if (pname == (INT8U *)0) {                   /* Is 'pname' a NULL pointer?                         */
 0000           ;         *perr = OS_ERR_PNAME_NULL;
 0000           ;         return;
 0000           ;     }
 0000           ; #endif
 0000           ;     if (OSIntNesting > 0) {                      /* See if trying to call from an ISR                  */
 0000           ;         *perr = OS_ERR_NAME_SET_ISR;
 0000           ;         return;
 0000           ;     }
 0000           ;     switch (pevent->OSEventType) {
 0000           ;         case OS_EVENT_TYPE_SEM:
 0000           ;         case OS_EVENT_TYPE_MUTEX:
 0000           ;         case OS_EVENT_TYPE_MBOX:
 0000           ;         case OS_EVENT_TYPE_Q:
 0000           ;              break;
 0000           ; 
 0000           ;         default:
 0000           ;              *perr = OS_ERR_EVENT_TYPE;
 0000           ;              return;
 0000           ;     }
 0000           ;     OS_ENTER_CRITICAL();
 0000           ;     len = OS_StrLen(pname);                           /* Can we fit the string in the storage area?    */
 0000           ;     if (len > (OS_EVENT_NAME_SIZE - 1)) {             /* No                                            */
 0000           ;         OS_EXIT_CRITICAL();
 0000           ;         *perr = OS_ERR_EVENT_NAME_TOO_LONG;
 0000           ;         return;
 0000           ;     }
 0000           ;     (void)OS_StrCopy(pevent->OSEventName, pname);     /* Yes, copy name to the event control block     */
 0000           ;     OS_EXIT_CRITICAL();
 0000           ;     *perr = OS_ERR_NONE;
 0000           ; }
 0000           ; #endif
 0000           ; 
 0000           ; 
 0000           ; /*
 0000           ; *********************************************************************************************************
 0000           ; *                                      PEND ON MULTIPLE EVENTS
 0000           ; *
 0000           ; * Description: This function waits for multiple events.  If multiple events are ready at the start of the
 0000           ; *              pend call, then all available events are returned as ready.  If the task must pend on the
 0000           ; *              multiple events, then only the first posted or aborted event is returned as ready.
 0000           ; *
 0000           ; * Arguments  : pevents_pend  is a pointer to a NULL-terminated array of event control blocks to wait for.
 0000           ; *
 0000           ; *              pevents_rdy   is a pointer to an array to return which event control blocks are available
 0000           ; *                            or ready.  The size of the array MUST be greater than or equal to the size
 0000           ; *                            of the 'pevents_pend' array, including terminating NULL.
 0000           ; *
 0000           ; *              pmsgs_rdy     is a pointer to an array to return messages from any available message-type
 0000           ; *                            events.  The size of the array MUST be greater than or equal to the size of
 0000           ; *                            the 'pevents_pend' array, excluding the terminating NULL.  Since NULL
 0000           ; *                            messages are valid messages, this array cannot be NULL-terminated.  Instead,
 0000           ; *                            every available message-type event returns its messages in the 'pmsgs_rdy'
 0000           ; *                            array at the same index as the event is returned in the 'pevents_rdy' array.
 0000           ; *                            All other 'pmsgs_rdy' array indices are filled with NULL messages.
 0000           ; *
 0000           ; *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
 0000           ; *                            wait for the resources up to the amount of time specified by this argument.
 0000           ; *                            If you specify 0, however, your task will wait forever for the specified
 0000           ; *                            events or, until the resources becomes available (or the events occur).
 0000           ; *
 0000           ; *              perr          is a pointer to where an error message will be deposited.  Possible error
 0000           ; *                            messages are:
 0000           ; *
 0000           ; *                            OS_ERR_NONE         The call was successful and your task owns the resources
 0000           ; *                                                or, the events you are waiting for occurred; check the
 0000           ; *                                                'pevents_rdy' array for which events are available.
 0000           ; *                            OS_ERR_PEND_ABORT   The wait on the events was aborted; check the
 0000           ; *                                                'pevents_rdy' array for which events were aborted.
 0000           ; *                            OS_ERR_TIMEOUT      The events were not received within the specified
 0000           ; *                                                'timeout'.
 0000           ; *                            OS_ERR_PEVENT_NULL  If 'pevents_pend', 'pevents_rdy', or 'pmsgs_rdy' is a
 0000           ; *                                                NULL pointer.
 0000           ; *                            OS_ERR_EVENT_TYPE   If you didn't pass a pointer to an array of semaphores,
 0000           ; *                                                mailboxes, and/or queues.
 0000           ; *                            OS_ERR_PEND_ISR     If you called this function from an ISR and the result
 0000           ; *                                                would lead to a suspension.
 0000           ; *                            OS_ERR_PEND_LOCKED  If you called this function when the scheduler is locked.
 0000           ; *
 0000           ; * Returns    : >  0          the number of events returned as ready or aborted.
 0000           ; *              == 0          if no events are returned as ready because of timeout or upon error.
 0000           ; *
 0000           ; * Notes      : 1) a. Validate 'pevents_pend' array as valid OS_EVENTs :
 0000           ; *
 0000           ; *                        semaphores, mailboxes, queues
 0000           ; *
 0000           ; *                 b. Return ALL available events and messages, if any
 0000           ; *
 0000           ; *                 c. Add    current task priority as pending to   each events's wait list
 0000           ; *                      Performed in OS_EventTaskWaitMulti()
 0000           ; *
 0000           ; *                 d. Wait on any of multiple events
 0000           ; *
 0000           ; *                 e. Remove current task priority as pending from each events's wait list
 0000           ; *                      Performed in OS_EventTaskRdy(), if events posted or aborted
 0000           ; *
 0000           ; *                 f. Return any event posted or aborted, if any
 0000           ; *                      else
 0000           ; *                    Return timeout
 0000           ; *
 0000           ; *              2) 'pevents_rdy' initialized to NULL PRIOR to all other validation or function handling in
 0000           ; *                 case of any error(s).
 0000           ; *********************************************************************************************************
 0000           ; */
 0000           ; 
 0000           ; #if ((OS_EVENT_EN) && (OS_EVENT_MULTI_EN > 0))
 0000           ; INT16U  OSEventPendMulti (OS_EVENT **pevents_pend, OS_EVENT **pevents_rdy, void **pmsgs_rdy, INT16U timeout, INT8U *perr)
 0000           ; {
 0000           ;     OS_EVENT  **pevents;
 0000           ;     OS_EVENT   *pevent;
 0000           ; #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0))
 0000           ;     OS_Q       *pq;
 0000           ; #endif
 0000           ;     BOOLEAN     events_rdy;
 0000           ;     INT16U      events_rdy_nbr;
 0000           ;     INT8U       events_stat;
 0000           ; #if (OS_CRITICAL_METHOD == 3)                           /* Allocate storage for CPU status register    */
 0000           ;     OS_CPU_SR   cpu_sr = 0;

⌨️ 快捷键说明

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